summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbkolb2007-10-12 09:41:00 (EDT)
committerbkolb2007-10-12 09:41:00 (EDT)
commit895f45f64c21414e0da15392f6d9715fc8c6ce0f (patch)
treeaf89d52ee7b7bf496a85afb7d611bf5d0326abc0
parent286c9d28b63458b142cff95355a943c4d00d7dc8 (diff)
downloadorg.eclipse.mwe-895f45f64c21414e0da15392f6d9715fc8c6ce0f.zip
org.eclipse.mwe-895f45f64c21414e0da15392f6d9715fc8c6ce0f.tar.gz
org.eclipse.mwe-895f45f64c21414e0da15392f6d9715fc8c6ce0f.tar.bz2
added tests for Reader and Writer
-rw-r--r--plugins/org.eclipse.emf.mwe.utils/META-INF/MANIFEST.MF3
-rw-r--r--plugins/org.eclipse.emf.mwe.utils/src/org/eclipse/emf/mwe/utils/AbstractEMFWorkflowComponent.java1
-rw-r--r--plugins/org.eclipse.emf.mwe.utils/src/org/eclipse/emf/mwe/utils/SingleGlobalResourceSet.java (renamed from plugins/org.eclipse.emf.mwe.utils/src/org/eclipse/emf/mwe/internal/utils/SingleGlobalResourceSet.java)2
-rw-r--r--tests/org.eclipse.emf.mwe.tests/META-INF/MANIFEST.MF3
-rw-r--r--tests/org.eclipse.emf.mwe.tests/src/org/eclipse/emf/mwe/tests/util/AllTests.java2
-rw-r--r--tests/org.eclipse.emf.mwe.tests/src/org/eclipse/emf/mwe/tests/util/ReaderTest.java33
-rw-r--r--tests/org.eclipse.emf.mwe.tests/src/org/eclipse/emf/mwe/tests/util/WriterTest.java62
7 files changed, 101 insertions, 5 deletions
diff --git a/plugins/org.eclipse.emf.mwe.utils/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.mwe.utils/META-INF/MANIFEST.MF
index 49e34fa..7df89a6 100644
--- a/plugins/org.eclipse.emf.mwe.utils/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.mwe.utils/META-INF/MANIFEST.MF
@@ -6,7 +6,6 @@ Bundle-Version: 0.7.0.qualifier
Require-Bundle: org.eclipse.emf.mwe.core,
org.apache.commons.logging,
org.eclipse.emf.ecore.xmi
-Export-Package: org.eclipse.emf.mwe.internal.utils;x-internal:=true,
- org.eclipse.emf.mwe.utils
+Export-Package: org.eclipse.emf.mwe.utils
Bundle-Vendor: %providerName
Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/plugins/org.eclipse.emf.mwe.utils/src/org/eclipse/emf/mwe/utils/AbstractEMFWorkflowComponent.java b/plugins/org.eclipse.emf.mwe.utils/src/org/eclipse/emf/mwe/utils/AbstractEMFWorkflowComponent.java
index 0030029..7ce62d5 100644
--- a/plugins/org.eclipse.emf.mwe.utils/src/org/eclipse/emf/mwe/utils/AbstractEMFWorkflowComponent.java
+++ b/plugins/org.eclipse.emf.mwe.utils/src/org/eclipse/emf/mwe/utils/AbstractEMFWorkflowComponent.java
@@ -3,7 +3,6 @@ package org.eclipse.emf.mwe.utils;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.mwe.core.lib.WorkflowComponentWithModelSlot;
-import org.eclipse.emf.mwe.internal.utils.SingleGlobalResourceSet;
@SuppressWarnings("unchecked")
public abstract class AbstractEMFWorkflowComponent extends
diff --git a/plugins/org.eclipse.emf.mwe.utils/src/org/eclipse/emf/mwe/internal/utils/SingleGlobalResourceSet.java b/plugins/org.eclipse.emf.mwe.utils/src/org/eclipse/emf/mwe/utils/SingleGlobalResourceSet.java
index 4c187c9..dc4d505 100644
--- a/plugins/org.eclipse.emf.mwe.utils/src/org/eclipse/emf/mwe/internal/utils/SingleGlobalResourceSet.java
+++ b/plugins/org.eclipse.emf.mwe.utils/src/org/eclipse/emf/mwe/utils/SingleGlobalResourceSet.java
@@ -1,4 +1,4 @@
-package org.eclipse.emf.mwe.internal.utils;
+package org.eclipse.emf.mwe.utils;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
diff --git a/tests/org.eclipse.emf.mwe.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.emf.mwe.tests/META-INF/MANIFEST.MF
index 790ce27..6911dc5 100644
--- a/tests/org.eclipse.emf.mwe.tests/META-INF/MANIFEST.MF
+++ b/tests/org.eclipse.emf.mwe.tests/META-INF/MANIFEST.MF
@@ -9,5 +9,6 @@ Export-Package: org.eclipse.emf.mwe.tests
Require-Bundle: org.junit,
org.apache.ant,
org.eclipse.emf.mwe.core,
- org.eclipse.emf.ecore
+ org.eclipse.emf.ecore,
+ org.eclipse.emf.mwe.utils
Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/tests/org.eclipse.emf.mwe.tests/src/org/eclipse/emf/mwe/tests/util/AllTests.java b/tests/org.eclipse.emf.mwe.tests/src/org/eclipse/emf/mwe/tests/util/AllTests.java
index 0404c1f..613dc92 100644
--- a/tests/org.eclipse.emf.mwe.tests/src/org/eclipse/emf/mwe/tests/util/AllTests.java
+++ b/tests/org.eclipse.emf.mwe.tests/src/org/eclipse/emf/mwe/tests/util/AllTests.java
@@ -10,6 +10,8 @@ public class AllTests {
"Test for org.eclipse.emf.mwe.tests.util");
//$JUnit-BEGIN$
suite.addTestSuite(ResourceLoaderFactoryTest.class);
+ suite.addTestSuite(ReaderTest.class);
+ suite.addTestSuite(WriterTest.class);
//$JUnit-END$
return suite;
}
diff --git a/tests/org.eclipse.emf.mwe.tests/src/org/eclipse/emf/mwe/tests/util/ReaderTest.java b/tests/org.eclipse.emf.mwe.tests/src/org/eclipse/emf/mwe/tests/util/ReaderTest.java
new file mode 100644
index 0000000..3e24f68
--- /dev/null
+++ b/tests/org.eclipse.emf.mwe.tests/src/org/eclipse/emf/mwe/tests/util/ReaderTest.java
@@ -0,0 +1,33 @@
+package org.eclipse.emf.mwe.tests.util;
+
+import java.io.File;
+
+import junit.framework.TestCase;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.mwe.core.WorkflowContext;
+import org.eclipse.emf.mwe.core.issues.IssuesImpl;
+import org.eclipse.emf.mwe.core.monitor.NullProgressMonitor;
+import org.eclipse.emf.mwe.internal.core.WorkflowContextDefaultImpl;
+import org.eclipse.emf.mwe.utils.Reader;
+import org.eclipse.emf.mwe.utils.StandaloneSetup;
+
+public class ReaderTest extends TestCase {
+ public void testLoadSimpleModel() throws Exception {
+ Reader r = new Reader();
+ r.setFirstElementOnly(true);
+ r.setModelSlot("x");
+ r.setUri("platform:/resource/org.openarchitectureware.core.emftools.tests/testmodel.xmi");
+ new StandaloneSetup().setPlatformUri(new File("..").getAbsolutePath());
+
+ WorkflowContext ctx = new WorkflowContextDefaultImpl();
+ r.invoke(ctx, new NullProgressMonitor(), new IssuesImpl());
+ EObject model1 = (EObject) ctx.get("x");
+ assertNotNull(model1);
+
+ r.invoke(ctx, new NullProgressMonitor(), new IssuesImpl());
+ EObject model2 = (EObject) ctx.get("x");
+ assertNotNull(model2);
+ assertTrue(model1.eClass()==model2.eClass());
+ }
+}
diff --git a/tests/org.eclipse.emf.mwe.tests/src/org/eclipse/emf/mwe/tests/util/WriterTest.java b/tests/org.eclipse.emf.mwe.tests/src/org/eclipse/emf/mwe/tests/util/WriterTest.java
new file mode 100644
index 0000000..570987d
--- /dev/null
+++ b/tests/org.eclipse.emf.mwe.tests/src/org/eclipse/emf/mwe/tests/util/WriterTest.java
@@ -0,0 +1,62 @@
+package org.eclipse.emf.mwe.tests.util;
+
+import java.io.File;
+
+import junit.framework.TestCase;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.mwe.core.WorkflowContext;
+import org.eclipse.emf.mwe.core.issues.IssuesImpl;
+import org.eclipse.emf.mwe.core.monitor.NullProgressMonitor;
+import org.eclipse.emf.mwe.internal.core.WorkflowContextDefaultImpl;
+import org.eclipse.emf.mwe.utils.Reader;
+import org.eclipse.emf.mwe.utils.StandaloneSetup;
+import org.eclipse.emf.mwe.utils.Writer;
+
+public class WriterTest extends TestCase {
+ private String relative = "testmodel.ecore";
+ private String tempfile = "platform:/resource/org.openarchitectureware.core.emftools.tests/"+relative;
+
+
+
+ @SuppressWarnings("unchecked")
+ public void testLoadSimpleModel() throws Exception {
+ ResourceSet rs = new ResourceSetImpl();
+ Writer writer = new Writer();
+ writer.setModelSlot("x");
+ writer.setUri(tempfile);
+ writer.setResourceSet(rs);
+ new StandaloneSetup().setPlatformUri(new File("..").getAbsolutePath());
+
+ WorkflowContext ctx = new WorkflowContextDefaultImpl();
+ EPackage pack = EcoreFactory.eINSTANCE.createEPackage();
+ pack.setName("test");
+ pack.setNsURI("http://www.eclipse.org/oaw/writer/test");
+ EClass clazz = EcoreFactory.eINSTANCE.createEClass();
+ clazz.setName("TEST");
+ pack.getEClassifiers().add(clazz);
+ ctx.set("x", pack);
+ writer.invoke(ctx, new NullProgressMonitor(), new IssuesImpl());
+ EObject model1 = (EObject) ctx.get("x");
+ assertNotNull(model1);
+
+ // read in
+ Reader r = new Reader();
+ r.setFirstElementOnly(true);
+ r.setModelSlot("y");
+ r.setResourceSet(rs);
+ r.setUri(tempfile);
+
+ r.invoke(ctx, new NullProgressMonitor(), new IssuesImpl());
+ EPackage pack2 = (EPackage) ctx.get("y");
+
+ assertTrue(pack == pack2);
+ new File(relative).delete();
+
+ }
+}