diff options
5 files changed, 45 insertions, 25 deletions
diff --git a/tests/org.eclipse.emf.teneo.commontest/.classpath b/tests/org.eclipse.emf.teneo.commontest/.classpath index 751c8f2e5..2cbc07db2 100644 --- a/tests/org.eclipse.emf.teneo.commontest/.classpath +++ b/tests/org.eclipse.emf.teneo.commontest/.classpath @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src"/> + <classpathentry exported="true" kind="lib" path="lib/jtds-1.2.jar"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="output" path="bin"/> diff --git a/tests/org.eclipse.emf.teneo.commontest/META-INF/MANIFEST.MF b/tests/org.eclipse.emf.teneo.commontest/META-INF/MANIFEST.MF index ea3076be3..7766ec672 100644 --- a/tests/org.eclipse.emf.teneo.commontest/META-INF/MANIFEST.MF +++ b/tests/org.eclipse.emf.teneo.commontest/META-INF/MANIFEST.MF @@ -15,7 +15,9 @@ Require-Bundle: org.eclipse.emf.ecore.xmi, Eclipse-LazyStart: true Eclipse-BuddyPolicy: dependent Bundle-ClassPath: lib/mysql-connector-java-3.1.10-bin.jar, - lib/tools.jar + lib/tools.jar, + lib/jtds-1.2.jar, + . Export-Package: com.mysql.jdbc, com.mysql.jdbc.integration.c3p0, com.mysql.jdbc.integration.jboss, @@ -56,6 +58,12 @@ Export-Package: com.mysql.jdbc, com.sun.tools.jdi, com.sun.tools.jdi.resources, extlibrary, + net.sourceforge.jtds.jdbc, + net.sourceforge.jtds.jdbc.cache, + net.sourceforge.jtds.jdbcx, + net.sourceforge.jtds.jdbcx.proxy, + net.sourceforge.jtds.ssl, + net.sourceforge.jtds.util, org.eclipse.emf.teneo.test, org.eclipse.emf.teneo.test.conf, org.eclipse.emf.teneo.test.emf.annotations, diff --git a/tests/org.eclipse.emf.teneo.commontest/build.properties b/tests/org.eclipse.emf.teneo.commontest/build.properties index 09ae1673f..2c19826de 100644 --- a/tests/org.eclipse.emf.teneo.commontest/build.properties +++ b/tests/org.eclipse.emf.teneo.commontest/build.properties @@ -22,7 +22,8 @@ bin.includes = plugin.properties,\ lib/mysql-connector-java-3.1.10-bin.jar,\ readme.txt,\ lib/tools.jar,\ - src/org/eclipse/emf/teneo/test/emf/sample/Ecore.ecore + src/org/eclipse/emf/teneo/test/emf/sample/Ecore.ecore,\ + lib/jtds-1.2.jar src.includes = about.html,\ epl-v10.html,\ copyright.txt diff --git a/tests/org.eclipse.emf.teneo.commontest/readme.txt b/tests/org.eclipse.emf.teneo.commontest/readme.txt index be0995fa0..8ceaa0cc6 100644 --- a/tests/org.eclipse.emf.teneo.commontest/readme.txt +++ b/tests/org.eclipse.emf.teneo.commontest/readme.txt @@ -5,6 +5,7 @@ September 2006 This plugin uses two jar files: tools.jar part of the sun jdk 1.4 (or other java jdk provider), see http://java.sun.com mysql-connector-java-3.1.10-bin.jar, see http://www.mysql.com +jtds-1.2.jar, see http://jtds.sourceforge.net/ These files are not distributed together with Teneo and need to be downloaded separately from diff --git a/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/sample/EcoreAction.java b/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/sample/EcoreAction.java index a9babb6f7..fbfbb5d3d 100644 --- a/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/sample/EcoreAction.java +++ b/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/sample/EcoreAction.java @@ -11,13 +11,14 @@ * Martin Taal * </copyright> * - * $Id: EcoreAction.java,v 1.1 2006/09/29 12:30:28 mtaal Exp $ + * $Id: EcoreAction.java,v 1.2 2006/10/17 09:48:04 mtaal Exp $ */ package org.eclipse.emf.teneo.test.emf.sample; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.Collections; @@ -29,6 +30,7 @@ import org.eclipse.emf.ecore.EPackage; import org.eclipse.emf.ecore.EcorePackage; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl; +import org.eclipse.emf.teneo.annotations.pannotation.InheritanceType; import org.eclipse.emf.teneo.test.AbstractTestAction; import org.eclipse.emf.teneo.test.StoreTestException; import org.eclipse.emf.teneo.test.stores.TestStore; @@ -37,7 +39,7 @@ import org.eclipse.emf.teneo.test.stores.TestStore; * Tests persisting of ecore models in a relational store. * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ */ public class EcoreAction extends AbstractTestAction { @@ -46,41 +48,54 @@ public class EcoreAction extends AbstractTestAction { super(EcorePackage.eINSTANCE); } - /** Creates a supplier, a product, relates then, saves and retrieves them again. */ + /** Reads the library model and persists it. */ public void doAction(TestStore store) { + if (store.getInheritanceType().equals(InheritanceType.SINGLE_TABLE_LITERAL)) { + // ignore this as this fails any way + return; + } + // read ecore as a resource + final Resource resourceOne = new XMIResourceImpl(); try { // read from the resource { // a file handle to the current class // the play.xml is in the model directory - final Resource resource = new XMIResourceImpl(); - resource.load(this.getClass().getResourceAsStream("library.ecore"), Collections.EMPTY_MAP); - resource.load(Collections.EMPTY_MAP); + resourceOne.load(this.getClass().getResourceAsStream("library.ecore"), Collections.EMPTY_MAP); + resourceOne.load(Collections.EMPTY_MAP); //EPackage epack = (EPackage)resource.getContents().get(0); // resource.unload(); store.beginTransaction(); - store.store(EcorePackage.eINSTANCE); + final EPackage epack = (EPackage)resourceOne.getContents().get(0); + System.err.println(epack.getName()); + store.store(epack); store.commitTransaction(); } // read from the relational store // and save it in a xml byte array - byte[] bytes; + final Resource resourceTwo = new XMIResourceImpl(); { store.beginTransaction(); final List result = store.getObjects(EPackage.class); - final ByteArrayOutputStream bos = new ByteArrayOutputStream(); - final Resource resource = new XMIResourceImpl(); - resource.getContents().addAll(result); - resource.save(bos, Collections.EMPTY_MAP); - bytes = bos.toByteArray(); + // get the library ecore from the result + EPackage libEPack = null; + for (int i = 0; i < result.size(); i++) { + final EPackage epack = (EPackage)result.get(i); + // very simple test on name, ouch! + if (epack.getName().compareToIgnoreCase("library") == 0) { + libEPack = epack; + } + } + assertNotNull(libEPack); + resourceTwo.getContents().add(libEPack); store.commitTransaction(); } // now compare the two resources - compareResult("library.ecore", bytes); + compareResult(resourceOne, resourceTwo); } catch (Exception e) { throw new StoreTestException("Exception when testing persistence of ecore", e); @@ -88,16 +103,10 @@ public class EcoreAction extends AbstractTestAction { } /** Compare the original and the generated xml file */ - protected void compareResult(String fileNameOne, byte[] bytes) throws IOException { - final InputStream isOne = this.getClass().getResourceAsStream(fileNameOne); - - final Resource original_resource = new XMIResourceImpl(); - original_resource.load(isOne, Collections.EMPTY_MAP); - final Iterator original_iterator = original_resource.getAllContents(); + protected void compareResult(Resource resourceOne, Resource ResourceTwo) throws IOException { + final Iterator original_iterator = resourceOne.getAllContents(); - final Resource new_resource = new XMIResourceImpl(); - new_resource.load(new ByteArrayInputStream(bytes), Collections.EMPTY_MAP); - final Iterator new_iterator = new_resource.getAllContents(); + final Iterator new_iterator = ResourceTwo.getAllContents(); // rough structural test while (original_iterator.hasNext()) { |