Skip to content
This repository has been archived by the owner on Jun 26, 2021. It is now read-only.

Commit

Permalink
Update travis config and code cleaning.
Browse files Browse the repository at this point in the history
  • Loading branch information
ghillairet committed Jul 27, 2015
1 parent 969f298 commit 4882106
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
@@ -1 +1,3 @@
language: java
sudo: false

Expand Up @@ -11,21 +11,19 @@
*/
package org.emfjson.jackson.junit.tests;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EcoreFactory;
import org.eclipse.emf.ecore.EcorePackage;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.junit.Test;

import org.emfjson.jackson.module.EMFModule;
import org.emfjson.jackson.resource.JsonResource;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import org.junit.Before;
import org.junit.Test;

import java.io.IOException;

Expand All @@ -35,14 +33,19 @@ public class ModuleTest {

private final ObjectMapper mapper = new ObjectMapper();

@Before
public void setUp() {
ResourceSetImpl resourceSet = new ResourceSetImpl();
resourceSet.getPackageRegistry().put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);
mapper.registerModule(new EMFModule(resourceSet));
}

@Test
public void testSaveWithModule() throws JsonProcessingException {
JsonNode expected = mapper.createObjectNode()
.put("eClass", "http://www.eclipse.org/emf/2002/Ecore#//EClass")
.put("name", "A");

mapper.registerModule(new EMFModule(new ResourceSetImpl()));

EClass c = EcoreFactory.eINSTANCE.createEClass();
c.setName("A");

Expand All @@ -55,7 +58,6 @@ public void testReadWithModule() throws IOException {
.put("eClass", "http://www.eclipse.org/emf/2002/Ecore#//EClass")
.put("name", "A");

mapper.registerModule(new EMFModule(new ResourceSetImpl()));
EClass result = (EClass) mapper.treeToValue(data, EObject.class);

assertEquals("A", result.getName());
Expand All @@ -67,9 +69,6 @@ public void testSaveResourceWithModule() throws JsonProcessingException {
.put("eClass", "http://www.eclipse.org/emf/2002/Ecore#//EClass")
.put("name", "A");

mapper.registerModule(new EMFModule(new ResourceSetImpl()));
mapper.configure(SerializationFeature.INDENT_OUTPUT, true);

Resource r = new JsonResource();
EClass c = EcoreFactory.eINSTANCE.createEClass();
c.setName("A");
Expand All @@ -84,7 +83,6 @@ public void testReadResourceWithModule() throws IOException {
.put("eClass", "http://www.eclipse.org/emf/2002/Ecore#//EClass")
.put("name", "A");

mapper.registerModule(new EMFModule(new ResourceSetImpl()));
Resource result = mapper.treeToValue(data, Resource.class);

assertEquals(1, result.getContents().size());
Expand Down

0 comments on commit 4882106

Please sign in to comment.