Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Taal2015-12-07 17:46:49 -0500
committerMartin Taal2015-12-07 17:46:49 -0500
commit07e69515577c2bebd0c3798b209239f4659446c0 (patch)
tree5524ac0674e06da305214cb1918b3bb431002c7a
parentddac1314cfc2a3481f6232309971169baa4cca50 (diff)
downloadorg.eclipse.emf.texo-07e69515577c2bebd0c3798b209239f4659446c0.tar.gz
org.eclipse.emf.texo-07e69515577c2bebd0c3798b209239f4659446c0.tar.xz
org.eclipse.emf.texo-07e69515577c2bebd0c3798b209239f4659446c0.zip
Solve failing EMFResourceObjectStore tests
-rw-r--r--core/org.eclipse.emf.texo.json/src/org/eclipse/emf/texo/json/JSONEObjectStore.java8
-rwxr-xr-xcore/org.eclipse.emf.texo/src/org/eclipse/emf/texo/converter/EMFModelConverter.java1
-rwxr-xr-xcore/org.eclipse.emf.texo/src/org/eclipse/emf/texo/model/ModelResolver.java26
-rw-r--r--core/org.eclipse.emf.texo/src/org/eclipse/emf/texo/store/EMFResourceObjectStore.java1
-rw-r--r--core/org.eclipse.emf.texo/src/org/eclipse/emf/texo/store/MemoryObjectStore.java23
-rw-r--r--core/org.eclipse.emf.texo/src/org/eclipse/emf/texo/store/TexoEMFResourceURIConverter.java8
-rw-r--r--infra/org.eclipse.emf.texo.releng.buckminster/build.xml4
-rw-r--r--infra/org.eclipse.emf.texo.releng.buckminster/test/texo_test.xml1
-rw-r--r--tests/org.eclipse.emf.texo.server.test/src/org/eclipse/emf/texo/server/test/XMLReadTest.java3
-rw-r--r--tests/org.eclipse.emf.texo.server.test/src/org/eclipse/emf/texo/server/test/issues/Bz391624EPersistenceResourceTest.java8
-rw-r--r--tests/org.eclipse.emf.texo.server.test/src/org/eclipse/emf/texo/server/test/issues/Bz391624Test.java16
-rw-r--r--tests/org.eclipse.emf.texo.server.test/src/org/eclipse/emf/texo/server/test/store/EMFResourceObjectStoreTest.java62
-rw-r--r--tests/org.eclipse.emf.texo.server.test/src/org/eclipse/emf/texo/server/test/ws/EMFResourceObjectStoreWSTest.java12
13 files changed, 132 insertions, 41 deletions
diff --git a/core/org.eclipse.emf.texo.json/src/org/eclipse/emf/texo/json/JSONEObjectStore.java b/core/org.eclipse.emf.texo.json/src/org/eclipse/emf/texo/json/JSONEObjectStore.java
index 0a05a860..e2c2a168 100644
--- a/core/org.eclipse.emf.texo.json/src/org/eclipse/emf/texo/json/JSONEObjectStore.java
+++ b/core/org.eclipse.emf.texo.json/src/org/eclipse/emf/texo/json/JSONEObjectStore.java
@@ -62,13 +62,17 @@ public class JSONEObjectStore extends EObjectStore {
private static final String POST_METHOD = "POST"; //$NON-NLS-1$
private static final String GET_METHOD = "GET"; //$NON-NLS-1$
- public JSONEObjectStore() {
- setUseWebServiceUriFormat(true);
+ public static void initEPackages() {
// dummy calls to initialize
RequestPackage.eINSTANCE.getActionType();
ResponsePackage.eINSTANCE.getDocumentRoot();
}
+ public JSONEObjectStore() {
+ setUseWebServiceUriFormat(true);
+ initEPackages();
+ }
+
protected String doHTTPRequest(String urlStr, String method, String content) throws Exception {
String localUrlStr = urlStr == null ? getUri().toString() : urlStr;
final URL url = new URL(adaptUrl(localUrlStr));
diff --git a/core/org.eclipse.emf.texo/src/org/eclipse/emf/texo/converter/EMFModelConverter.java b/core/org.eclipse.emf.texo/src/org/eclipse/emf/texo/converter/EMFModelConverter.java
index 8c76584d..9e894fe6 100755
--- a/core/org.eclipse.emf.texo/src/org/eclipse/emf/texo/converter/EMFModelConverter.java
+++ b/core/org.eclipse.emf.texo/src/org/eclipse/emf/texo/converter/EMFModelConverter.java
@@ -132,7 +132,6 @@ public class EMFModelConverter implements TexoComponent {
final Object target = objectMapping.get(eObject);
final ModelObject<?> modelObject = ModelResolver.getInstance().getModelObject(target);
-
for (final EStructuralFeature eStructuralFeature : modelObject.eClass().getEAllStructuralFeatures()) {
if (!eStructuralFeature.isChangeable() || eStructuralFeature.isVolatile()) {
continue;
diff --git a/core/org.eclipse.emf.texo/src/org/eclipse/emf/texo/model/ModelResolver.java b/core/org.eclipse.emf.texo/src/org/eclipse/emf/texo/model/ModelResolver.java
index 5bfa69f3..e16ac9fb 100755
--- a/core/org.eclipse.emf.texo/src/org/eclipse/emf/texo/model/ModelResolver.java
+++ b/core/org.eclipse.emf.texo/src/org/eclipse/emf/texo/model/ModelResolver.java
@@ -52,9 +52,9 @@ import org.eclipse.emf.texo.utils.Check;
* {@link ModelPackage}.
*
* The ModelResolver is maintained in a static member (which can be overwritten with your own implementation). It is
- * also maintainable by thread. If you want a specific thread to use a different ModelResolver then call {@;ink
- * #setThreadInstance(ModelResolver)}. Note that you should take care to call this method with a null value (to clear
- * the {@link ThreadLocal}) at the end of the thread to clean up the thread ModelResolver (some environments, for
+ * also maintainable by thread. If you want a specific thread to use a different ModelResolver then call
+ * {@;ink #setThreadInstance(ModelResolver)}. Note that you should take care to call this method with a null value (to
+ * clear the {@link ThreadLocal}) at the end of the thread to clean up the thread ModelResolver (some environments, for
* example Tomcat, re-uses Thread objects!).
*
* @author <a href="mtaal@elver.org">Martin Taal</a>
@@ -106,7 +106,7 @@ public class ModelResolver implements TexoStaticSingleton {
/**
* Registers a {@link ModelPackage} in this registry.
*
- * @param ecoreModelPackage
+ * @param modelPackage
* to register, not <code>NULL</code>
*/
public void registerModelPackage(final ModelPackage modelPackage) {
@@ -116,6 +116,16 @@ public class ModelResolver implements TexoStaticSingleton {
}
/**
+ * Should be called after a modelPackage was deregistered and needs to be reregistered.
+ */
+ public void registerModelPackageContent(final ModelPackage modelPackage) {
+ for (EClassifier eClassifier : modelPackage.getEPackage().getEClassifiers()) {
+ final Class<?> clz = modelPackage.getEClassifierClass(eClassifier);
+ registerClassModelMapping(clz, eClassifier, modelPackage);
+ }
+ }
+
+ /**
* Return a {@link ModelPackage} on the basis of the NsUri
*
* @param nsURI
@@ -312,8 +322,8 @@ public class ModelResolver implements TexoStaticSingleton {
final String nsuri = eFeature.getEContainingClass().getEPackage().getNsURI();
final ModelPackage modelPackage = getModelPackage(nsuri);
if (modelPackage == null) {
- final DynamicModelFeatureMapEntry fmEntry = ComponentProvider.getInstance().newInstance(
- DynamicModelFeatureMapEntry.class);
+ final DynamicModelFeatureMapEntry fmEntry = ComponentProvider.getInstance()
+ .newInstance(DynamicModelFeatureMapEntry.class);
fmEntry.setEStructuralFeature(eFeature);
return fmEntry;
}
@@ -332,8 +342,8 @@ public class ModelResolver implements TexoStaticSingleton {
final String nsuri = eFeature.getEContainingClass().getEPackage().getNsURI();
final ModelPackage modelPackage = getModelPackage(nsuri);
if (modelPackage == null) {
- final DynamicModelFeatureMapEntry fmEntry = ComponentProvider.getInstance().newInstance(
- DynamicModelFeatureMapEntry.class);
+ final DynamicModelFeatureMapEntry fmEntry = ComponentProvider.getInstance()
+ .newInstance(DynamicModelFeatureMapEntry.class);
fmEntry.setEStructuralFeature(eFeature);
return fmEntry;
}
diff --git a/core/org.eclipse.emf.texo/src/org/eclipse/emf/texo/store/EMFResourceObjectStore.java b/core/org.eclipse.emf.texo/src/org/eclipse/emf/texo/store/EMFResourceObjectStore.java
index 9e139095..bdc37c2e 100644
--- a/core/org.eclipse.emf.texo/src/org/eclipse/emf/texo/store/EMFResourceObjectStore.java
+++ b/core/org.eclipse.emf.texo/src/org/eclipse/emf/texo/store/EMFResourceObjectStore.java
@@ -40,7 +40,6 @@ public class EMFResourceObjectStore extends MemoryObjectStore {
try {
final boolean loadFile = resource.getResourceSet().getURIConverter().exists(resource.getURI(),
Collections.emptyMap());
- System.err.println("Loading file " + loadFile);
if (loadFile) {
resource.load(getResourceLoadOptions());
final List<EObject> eObjects = new ArrayList<EObject>();
diff --git a/core/org.eclipse.emf.texo/src/org/eclipse/emf/texo/store/MemoryObjectStore.java b/core/org.eclipse.emf.texo/src/org/eclipse/emf/texo/store/MemoryObjectStore.java
index df289258..3a647956 100644
--- a/core/org.eclipse.emf.texo/src/org/eclipse/emf/texo/store/MemoryObjectStore.java
+++ b/core/org.eclipse.emf.texo/src/org/eclipse/emf/texo/store/MemoryObjectStore.java
@@ -40,7 +40,7 @@ public class MemoryObjectStore extends ObjectStore {
@SuppressWarnings("unchecked")
final ModelObject<Object> modelObject = (ModelObject<Object>) ModelResolver.getInstance().getModelObject(object);
final EClass eClass = modelObject.eClass();
- List<Object> dataList = data.get(eClass);
+ List<Object> dataList = data.get(resolveEClass(eClass));
if (dataList == null) {
dataList = new ArrayList<Object>();
data.put(eClass, dataList);
@@ -51,7 +51,7 @@ public class MemoryObjectStore extends ObjectStore {
@Override
public Object get(EClass eClass, Object id) {
- final List<Object> dataList = data.get(eClass);
+ final List<Object> dataList = data.get(resolveEClass(eClass));
if (dataList != null) {
for (Object o : dataList) {
final Object objectId = IdProvider.getInstance().getId(o);
@@ -98,7 +98,7 @@ public class MemoryObjectStore extends ObjectStore {
return;
}
final ModelObject<?> modelObject = ModelResolver.getInstance().getModelObject(object);
- final List<Object> dataList = data.get(modelObject.eClass());
+ final List<Object> dataList = data.get(resolveEClass(modelObject.eClass()));
boolean removed = false;
if (dataList != null) {
removed = dataList.remove(object);
@@ -123,6 +123,19 @@ public class MemoryObjectStore extends ObjectStore {
}
}
+ protected EClass resolveEClass(EClass eClass) {
+ if (data.containsKey(eClass)) {
+ return eClass;
+ }
+ for (EClass key : data.keySet()) {
+ if (key.getName().equals(eClass.getName())
+ && key.getEPackage().getNsURI().equals(eClass.getEPackage().getNsURI())) {
+ return key;
+ }
+ }
+ return eClass;
+ }
+
@Override
public <T extends Object> void refresh(T object) {
// don't do anything
@@ -131,7 +144,7 @@ public class MemoryObjectStore extends ObjectStore {
@Override
public <T extends Object> void insert(T object) {
final ModelObject<?> modelObject = ModelResolver.getInstance().getModelObject(object);
- List<Object> dataList = data.get(modelObject.eClass());
+ List<Object> dataList = data.get(resolveEClass(modelObject.eClass()));
if (dataList == null) {
dataList = new ArrayList<Object>();
data.put(modelObject.eClass(), dataList);
@@ -222,7 +235,7 @@ public class MemoryObjectStore extends ObjectStore {
*/
@Override
public List<?> query(EClass eClass, int firstResult, int maxResults) {
- List<?> result = data.get(eClass);
+ List<?> result = data.get(resolveEClass(eClass));
if (result == null) {
return Collections.emptyList();
}
diff --git a/core/org.eclipse.emf.texo/src/org/eclipse/emf/texo/store/TexoEMFResourceURIConverter.java b/core/org.eclipse.emf.texo/src/org/eclipse/emf/texo/store/TexoEMFResourceURIConverter.java
index 81b0d55f..1f64e499 100644
--- a/core/org.eclipse.emf.texo/src/org/eclipse/emf/texo/store/TexoEMFResourceURIConverter.java
+++ b/core/org.eclipse.emf.texo/src/org/eclipse/emf/texo/store/TexoEMFResourceURIConverter.java
@@ -41,9 +41,6 @@ public class TexoEMFResourceURIConverter extends ExtensibleURIConverterImpl impl
String[] segments = uri.segments();
String fileName = segments[0] + "_" + segments[1] + "." + getFileExtension(); //$NON-NLS-1$ //$NON-NLS-2$
String dir = getTemporaryDirectoryPath();
-
- System.err.println("Normalized " + URI.createFileURI(dir + File.separator + fileName));
-
return URI.createFileURI(dir + File.separator + fileName);
}
@@ -63,14 +60,9 @@ public class TexoEMFResourceURIConverter extends ExtensibleURIConverterImpl impl
*/
protected String getTemporaryDirectoryPath() {
try {
- if (System.getProperty("texo.temp.directory") != null) { //$NON-NLS-1$
- System.err.println("Texo temp " + System.getProperty("texo.temp.directory"));
- return System.getProperty("texo.temp.directory");//$NON-NLS-1$
- }
final File f = File.createTempFile("test" + System.currentTimeMillis(), null); //$NON-NLS-1$
String tempDirectory = f.getParentFile().getAbsolutePath();
f.delete();
- System.err.println("Texo temp " + tempDirectory);
return tempDirectory;
} catch (IOException e) {
throw new IllegalStateException(e);
diff --git a/infra/org.eclipse.emf.texo.releng.buckminster/build.xml b/infra/org.eclipse.emf.texo.releng.buckminster/build.xml
index 9c0a32c1..e643d5ff 100644
--- a/infra/org.eclipse.emf.texo.releng.buckminster/build.xml
+++ b/infra/org.eclipse.emf.texo.releng.buckminster/build.xml
@@ -58,7 +58,6 @@ http://dev.eclipse.org/viewsvn/index.cgi/trunk/org.eclipse.buckminster.releng/bu
</condition>
<property name="buildsPath" location="${hudsonWorkSpacePath}/build" />
- <property name="tempPath" location="${buildsPath}/temp-files" />
<property name="resultP2Site" location="/jobs/genie.texo/emft-texo-nightly/lastSuccessful/archive/build/result/p2site" />
<property name="gitPath" location="${hudsonWorkSpacePath}/git" />
@@ -145,7 +144,6 @@ http://dev.eclipse.org/viewsvn/index.cgi/trunk/org.eclipse.buckminster.releng/bu
<target name="init">
<echo message="Removing old build" />
<delete dir="${testPath}" quiet="true" />
- <delete dir="${tempPath}" quiet="true" />
<delete dir="${buildPath}" quiet="true" />
<delete dir="${generatePath}" quiet="true" />
<delete dir="${promotePath}" quiet="true" />
@@ -156,7 +154,6 @@ http://dev.eclipse.org/viewsvn/index.cgi/trunk/org.eclipse.buckminster.releng/bu
<echo message="Creating main directories" />
<echo message="rootPath: ${rootPath}" />
<echo message="buildPath: ${buildPath}" />
- <echo message="tempPath: ${tempPath}" />
<echo message="testPath: ${testPath}" />
<echo message="buildSitePath: ${buildSitePath}" />
<echo message="buildZipsPath: ${buildZipsPath}" />
@@ -164,7 +161,6 @@ http://dev.eclipse.org/viewsvn/index.cgi/trunk/org.eclipse.buckminster.releng/bu
<echo message="mavenPath: ${mavenPath}" />
<mkdir dir="${rootPath}" />
<mkdir dir="${buildPath}" />
- <mkdir dir="${tempPath}" />
<mkdir dir="${promotePath}" />
<mkdir dir="${mavenPath}" />
<mkdir dir="${testPath}" />
diff --git a/infra/org.eclipse.emf.texo.releng.buckminster/test/texo_test.xml b/infra/org.eclipse.emf.texo.releng.buckminster/test/texo_test.xml
index 390a150d..eed5164f 100644
--- a/infra/org.eclipse.emf.texo.releng.buckminster/test/texo_test.xml
+++ b/infra/org.eclipse.emf.texo.releng.buckminster/test/texo_test.xml
@@ -75,7 +75,6 @@ http://dev.eclipse.org/viewsvn/index.cgi/trunk/org.eclipse.buckminster.releng/bu
<arg value="--stderr" />
<arg value="${testResultsPath}/stderr.txt" />
<arg value="--flatXML"/>
- <jvmarg value="-Dtexo.temp.directory=${tempPath}"/>
</cmdargs>
</buckminster>
</target>
diff --git a/tests/org.eclipse.emf.texo.server.test/src/org/eclipse/emf/texo/server/test/XMLReadTest.java b/tests/org.eclipse.emf.texo.server.test/src/org/eclipse/emf/texo/server/test/XMLReadTest.java
index 576568c3..d35ac41b 100644
--- a/tests/org.eclipse.emf.texo.server.test/src/org/eclipse/emf/texo/server/test/XMLReadTest.java
+++ b/tests/org.eclipse.emf.texo.server.test/src/org/eclipse/emf/texo/server/test/XMLReadTest.java
@@ -22,9 +22,11 @@ import java.util.Collection;
import java.util.List;
import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.texo.json.JSONEObjectStore;
import org.eclipse.emf.texo.model.ModelObject;
import org.eclipse.emf.texo.model.ModelPackage;
import org.eclipse.emf.texo.model.ModelResolver;
+import org.eclipse.emf.texo.server.model.request.RequestModelPackage;
import org.eclipse.emf.texo.server.model.response.ResponseType;
import org.eclipse.emf.texo.server.service.RetrieveModelOperation;
import org.eclipse.emf.texo.server.service.ServiceContext;
@@ -54,6 +56,7 @@ public class XMLReadTest extends ModelPackageBaseTest {
// this is to prevent clashes in epackage loading
// of the library epackage
LibraryPackageImpl.init();
+ JSONEObjectStore.initEPackages();
return Arrays.asList(new Object[][] { { LibraryModelPackage.INSTANCE, new XMLServiceContext() },
{ RentalModelPackage.INSTANCE, new XMLServiceContext() } });
diff --git a/tests/org.eclipse.emf.texo.server.test/src/org/eclipse/emf/texo/server/test/issues/Bz391624EPersistenceResourceTest.java b/tests/org.eclipse.emf.texo.server.test/src/org/eclipse/emf/texo/server/test/issues/Bz391624EPersistenceResourceTest.java
index 508e6f5b..b7e6cd8f 100644
--- a/tests/org.eclipse.emf.texo.server.test/src/org/eclipse/emf/texo/server/test/issues/Bz391624EPersistenceResourceTest.java
+++ b/tests/org.eclipse.emf.texo.server.test/src/org/eclipse/emf/texo/server/test/issues/Bz391624EPersistenceResourceTest.java
@@ -34,16 +34,16 @@ public class Bz391624EPersistenceResourceTest extends Bz391624Test {
@Override
protected TexoResource createResource(String uriString) {
final ResourceSetImpl resourceSet = new ResourceSetImpl();
- resourceSet.getResourceFactoryRegistry().getProtocolToFactoryMap()
- .put("http", new EPersistenceTexoResourceFactory());
+ resourceSet.getResourceFactoryRegistry().getProtocolToFactoryMap().put("http",
+ new EPersistenceTexoResourceFactory());
return (TexoResource) resourceSet.createResource(URI.createURI(uriString));
}
private static class EPersistenceTexoResourceFactory implements Resource.Factory {
public Resource createResource(URI uri) {
- final EPersistenceTexoResource resource = ComponentProvider.getInstance().newInstance(
- EPersistenceTexoResource.class);
+ final EPersistenceTexoResource resource = ComponentProvider.getInstance()
+ .newInstance(EPersistenceTexoResource.class);
resource.setURI(uri);
return resource;
}
diff --git a/tests/org.eclipse.emf.texo.server.test/src/org/eclipse/emf/texo/server/test/issues/Bz391624Test.java b/tests/org.eclipse.emf.texo.server.test/src/org/eclipse/emf/texo/server/test/issues/Bz391624Test.java
index 186a00b0..5629672a 100644
--- a/tests/org.eclipse.emf.texo.server.test/src/org/eclipse/emf/texo/server/test/issues/Bz391624Test.java
+++ b/tests/org.eclipse.emf.texo.server.test/src/org/eclipse/emf/texo/server/test/issues/Bz391624Test.java
@@ -19,6 +19,7 @@ package org.eclipse.emf.texo.server.test.issues;
import java.io.IOException;
import java.util.Collections;
+import org.eclipse.emf.texo.model.ModelResolver;
import org.eclipse.emf.texo.server.test.store.TexoResourceTest;
import org.eclipse.emf.texo.store.TexoResource;
import org.eclipse.emf.texo.test.emfmodel.bz391624.Author;
@@ -26,7 +27,9 @@ import org.eclipse.emf.texo.test.emfmodel.bz391624.Book;
import org.eclipse.emf.texo.test.emfmodel.bz391624.Bz391624Factory;
import org.eclipse.emf.texo.test.emfmodel.bz391624.impl.Bz391624PackageImpl;
import org.eclipse.emf.texo.test.model.issues.bz391624.Bz391624ModelPackage;
+import org.junit.AfterClass;
import org.junit.Assert;
+import org.junit.BeforeClass;
import org.junit.Test;
/**
@@ -37,6 +40,19 @@ import org.junit.Test;
*/
public abstract class Bz391624Test extends TexoResourceTest {
+ @BeforeClass
+ public static void beforeClass() {
+ // deregister before register to prevent registration error
+ ModelResolver.getInstance().deregister(Bz391624ModelPackage.INSTANCE);
+ ModelResolver.getInstance().registerModelPackage(Bz391624ModelPackage.INSTANCE);
+ ModelResolver.getInstance().registerModelPackageContent(Bz391624ModelPackage.INSTANCE);
+ }
+
+ @AfterClass
+ public static void afterClass() {
+ ModelResolver.getInstance().deregister(Bz391624ModelPackage.INSTANCE);
+ }
+
public Bz391624Test() {
super("bz391624");
Bz391624PackageImpl.init();
diff --git a/tests/org.eclipse.emf.texo.server.test/src/org/eclipse/emf/texo/server/test/store/EMFResourceObjectStoreTest.java b/tests/org.eclipse.emf.texo.server.test/src/org/eclipse/emf/texo/server/test/store/EMFResourceObjectStoreTest.java
index 8625f2ee..74f6696b 100644
--- a/tests/org.eclipse.emf.texo.server.test/src/org/eclipse/emf/texo/server/test/store/EMFResourceObjectStoreTest.java
+++ b/tests/org.eclipse.emf.texo.server.test/src/org/eclipse/emf/texo/server/test/store/EMFResourceObjectStoreTest.java
@@ -16,21 +16,30 @@
*/
package org.eclipse.emf.texo.server.test.store;
+import java.io.File;
+import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
+import javax.servlet.http.HttpServletRequest;
+
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.texo.component.ComponentProvider;
import org.eclipse.emf.texo.server.store.EPersistenceService;
+import org.eclipse.emf.texo.server.web.ObjectStoreFactory;
import org.eclipse.emf.texo.store.EMFResourceObjectStore;
import org.eclipse.emf.texo.store.ObjectStore;
+import org.eclipse.emf.texo.store.TexoEMFResourceURIConverter;
import org.eclipse.emf.texo.test.model.samples.library.Book;
import org.eclipse.emf.texo.test.model.samples.library.Library;
import org.eclipse.emf.texo.test.model.samples.library.Writer;
import org.eclipse.emf.texo.test.model.samples.librarymodelclasses.model.LibraryModelFactory;
import org.eclipse.emf.texo.test.model.samples.librarymodelclasses.model.LibraryModelPackage;
+import org.junit.After;
+import org.junit.AfterClass;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@@ -51,6 +60,45 @@ public class EMFResourceObjectStoreTest {
return Arrays.asList(new String[] { "xml", "xmi" });
}
+ @AfterClass
+ public static void afterClass() {
+ ObjectStoreFactory.setInstance(new ObjectStoreFactory());
+ }
+
+ @Before
+ public void before() {
+ {
+ File xmiFile = new File(getTemporaryDirectoryPath(), "texo_data.xmi");
+ if (xmiFile.exists()) {
+ xmiFile.delete();
+ }
+ }
+ {
+ File xmlFile = new File(getTemporaryDirectoryPath(), "texo_data.xml");
+ if (xmlFile.exists()) {
+ xmlFile.delete();
+ }
+ }
+ ObjectStoreFactory.setInstance(new ObjectStoreFactory() {
+
+ @Override
+ protected ObjectStore createObjectStoreLocal(HttpServletRequest request, String objectStoreUri) {
+ ObjectStore os = super.createEMFResourceObjectStore();
+ if ("xml".equals(fileExtension)) {
+ final EMFResourceObjectStore eos = (EMFResourceObjectStore) os;
+ ((TexoEMFResourceURIConverter) eos.getURIConverter())
+ .setResourceType(TexoEMFResourceURIConverter.ResourceType.XML);
+ }
+ return os;
+ }
+ });
+ }
+
+ @After
+ public void after() {
+ ObjectStoreFactory.setInstance(new ObjectStoreFactory());
+ }
+
private String fileExtension;
private String uriStr;
@@ -158,7 +206,7 @@ public class EMFResourceObjectStoreTest {
final EMFResourceObjectStore objectStore = ComponentProvider.getInstance()
.newInstance(EMFResourceObjectStore.class);
if (uriStr == null) {
- uriStr = "http://localhost:8080/texo/data" + System.currentTimeMillis() + "." + fileExtension;
+ uriStr = "http://localhost:8080/texo/data";
}
objectStore.setUri(URI.createURI(uriStr));
objectStore.setChildLevels(1);
@@ -167,4 +215,16 @@ public class EMFResourceObjectStoreTest {
throw new RuntimeException(e);
}
}
+
+ protected String getTemporaryDirectoryPath() {
+ try {
+ final File f = File.createTempFile("test" + System.currentTimeMillis(), null); //$NON-NLS-1$
+ String tempDirectory = f.getParentFile().getAbsolutePath();
+ f.delete();
+ return tempDirectory;
+ } catch (IOException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
}
diff --git a/tests/org.eclipse.emf.texo.server.test/src/org/eclipse/emf/texo/server/test/ws/EMFResourceObjectStoreWSTest.java b/tests/org.eclipse.emf.texo.server.test/src/org/eclipse/emf/texo/server/test/ws/EMFResourceObjectStoreWSTest.java
index 05447281..043a9fbb 100644
--- a/tests/org.eclipse.emf.texo.server.test/src/org/eclipse/emf/texo/server/test/ws/EMFResourceObjectStoreWSTest.java
+++ b/tests/org.eclipse.emf.texo.server.test/src/org/eclipse/emf/texo/server/test/ws/EMFResourceObjectStoreWSTest.java
@@ -47,6 +47,7 @@ import org.eclipse.emf.texo.test.model.samples.librarymodelclasses.model.Library
import org.eclipse.emf.texo.utils.ModelUtils;
import org.eclipse.jetty.http.HttpMethod;
import org.junit.After;
+import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -72,6 +73,11 @@ public class EMFResourceObjectStoreWSTest extends BaseWSWebTest {
return params;
}
+ @AfterClass
+ public static void afterClass() {
+ ObjectStoreFactory.setInstance(new ObjectStoreFactory());
+ }
+
@Before
public void before() {
{
@@ -461,15 +467,9 @@ public class EMFResourceObjectStoreWSTest extends BaseWSWebTest {
protected String getTemporaryDirectoryPath() {
try {
- if (System.getProperty("texo.temp.directory") != null) { //$NON-NLS-1$
- System.err.println("Texo jvm arg temp " + System.getProperty("texo.temp.directory"));
- return System.getProperty("texo.temp.directory");//$NON-NLS-1$
- }
-
final File f = File.createTempFile("test" + System.currentTimeMillis(), null); //$NON-NLS-1$
String tempDirectory = f.getParentFile().getAbsolutePath();
f.delete();
- System.err.println("Texo temp " + tempDirectory);
return tempDirectory;
} catch (IOException e) {
throw new IllegalStateException(e);

Back to the top