diff options
author | mtaal | 2007-03-28 13:58:05 +0000 |
---|---|---|
committer | mtaal | 2007-03-28 13:58:05 +0000 |
commit | e9132d3e586cd7b61875e9a20bab6346432b35c9 (patch) | |
tree | 65e75d00ef13f051d20305baac8fba17267f29c4 /tests/org.eclipse.emf.teneo.jpox.test/src | |
parent | a138e52d80efbab3c6d75d15edd5e8b12accdbb9 (diff) | |
download | org.eclipse.emf.teneo-e9132d3e586cd7b61875e9a20bab6346432b35c9.tar.gz org.eclipse.emf.teneo-e9132d3e586cd7b61875e9a20bab6346432b35c9.tar.xz org.eclipse.emf.teneo-e9132d3e586cd7b61875e9a20bab6346432b35c9.zip |
[179446]
Diffstat (limited to 'tests/org.eclipse.emf.teneo.jpox.test/src')
6 files changed, 59 insertions, 28 deletions
diff --git a/tests/org.eclipse.emf.teneo.jpox.test/src/org/eclipse/emf/teneo/jpox/test/JPOXTestbed.java b/tests/org.eclipse.emf.teneo.jpox.test/src/org/eclipse/emf/teneo/jpox/test/JPOXTestbed.java index 68e336258..55ff55224 100644 --- a/tests/org.eclipse.emf.teneo.jpox.test/src/org/eclipse/emf/teneo/jpox/test/JPOXTestbed.java +++ b/tests/org.eclipse.emf.teneo.jpox.test/src/org/eclipse/emf/teneo/jpox/test/JPOXTestbed.java @@ -11,14 +11,14 @@ * Martin Taal * </copyright> * - * $Id: JPOXTestbed.java,v 1.36 2007/03/18 19:19:11 mtaal Exp $ + * $Id: JPOXTestbed.java,v 1.37 2007/03/28 13:58:16 mtaal Exp $ */ package org.eclipse.emf.teneo.jpox.test; import java.io.File; -import java.io.FileNotFoundException; import java.io.FileWriter; +import java.io.IOException; import java.util.Properties; import org.apache.commons.logging.Log; @@ -40,7 +40,7 @@ import org.jpox.enhancer.JPOXEnhancer; * The jpox test bed controls the creation of the store and the generation of the mapping file. * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> - * @version $Revision: 1.36 $ + * @version $Revision: 1.37 $ */ public class JPOXTestbed extends Testbed { @@ -67,7 +67,7 @@ public class JPOXTestbed extends Testbed { /** * The directory in which the mapping files are generated TODO make insesitive to user.dir */ - private static String RUN_BASE_DIR = System.getProperty("user.dir") + File.separatorChar + "run"; + private static String RUN_BASE_DIR = System.getProperty("user.dir") + File.separatorChar + "jdo"; /** Test the rundir */ static { @@ -111,9 +111,13 @@ public class JPOXTestbed extends Testbed { /** Generate the mapping file for the test case */ public void doMapping(AbstractTest testCase) { - File mappingFile = getMappingFile(testCase, getActiveConfiguration()); - generateMappingFile(testCase, mappingFile, getActiveConfiguration().isOptimistic(), getActiveConfiguration() - .getMappingStrategy()); + try { + final File mappingFile = getMappingFile(testCase, getActiveConfiguration()); + generateMappingFile(testCase, mappingFile, getActiveConfiguration().isOptimistic(), getActiveConfiguration() + .getMappingStrategy()); + } catch (Exception e) { + throw new StoreTestException("Exception while doing mapping", e); + } } /** @@ -138,21 +142,21 @@ public class JPOXTestbed extends Testbed { store.setUp(); return store; - } catch (FileNotFoundException e) { - throw new StoreTestException("Exception while getting hbm file", e); + } catch (Exception e) { + throw new StoreTestException("Exception while getting jdo file", e); } } /** * Creates a file with the extension based on the type of inheritance mapping strategy */ - protected File getMappingFile(AbstractTest testCase, TestConfiguration cfg) { - return new File(getRunTestDir(testCase, cfg), "package.jdo"); + protected File getMappingFile(AbstractTest testCase, TestConfiguration cfg) throws IOException { + return new File(getRunTestDir(testCase), cfg.getName() + "_package.jdo"); } /** Returns the directory in which to put the generated mapping files */ - protected File getRunTestDir(AbstractTest testCase, TestConfiguration cfg) { - File dir = new File(new File(RUN_BASE_DIR, testCase.getName()), cfg.getName()); + protected File getRunTestDir(AbstractTest testCase) throws IOException { + File dir = new File(RUN_BASE_DIR, testCase.getName()); dir.mkdirs(); return dir; } @@ -189,7 +193,9 @@ public class JPOXTestbed extends Testbed { final File projectDir = mappingFile.getParentFile().getParentFile().getParentFile().getParentFile().getParentFile(); final File samplesProject = new File (projectDir, "org.eclipse.emf.teneo.samples"); final File jdoFiles = new File(samplesProject, "jdofiles"); - + if (!jdoFiles.exists()) { + jdoFiles.mkdirs(); + } // just choose a name based on one of the classes in the package final String fileName = ((EClassifier)test.getEPackages()[0].getEClassifiers().get(0)).getInstanceClassName() + ".jdo"; final File jdoFile = new File(jdoFiles, fileName); diff --git a/tests/org.eclipse.emf.teneo.jpox.test/src/org/eclipse/emf/teneo/jpox/test/emf/sample/AllGenerateTests.java b/tests/org.eclipse.emf.teneo.jpox.test/src/org/eclipse/emf/teneo/jpox/test/emf/sample/AllGenerateTests.java index 7233ca917..93702beee 100644 --- a/tests/org.eclipse.emf.teneo.jpox.test/src/org/eclipse/emf/teneo/jpox/test/emf/sample/AllGenerateTests.java +++ b/tests/org.eclipse.emf.teneo.jpox.test/src/org/eclipse/emf/teneo/jpox/test/emf/sample/AllGenerateTests.java @@ -11,7 +11,7 @@ * Martin Taal * </copyright> * - * $Id: AllGenerateTests.java,v 1.13 2007/03/24 11:49:38 mtaal Exp $ + * $Id: AllGenerateTests.java,v 1.14 2007/03/28 13:58:06 mtaal Exp $ */ package org.eclipse.emf.teneo.jpox.test.emf.sample; @@ -28,6 +28,7 @@ import org.eclipse.emf.teneo.test.emf.sample.LibraryGlobalEagerAction; import org.eclipse.emf.teneo.test.emf.sample.LibraryNonResolvingAction; import org.eclipse.emf.teneo.test.emf.sample.LibraryResourceAction; import org.eclipse.emf.teneo.test.emf.sample.LibraryResourceCutPasteAction; +import org.eclipse.emf.teneo.test.emf.sample.LibraryResourceReferenceAction; import org.eclipse.emf.teneo.test.emf.sample.LibrarySerializationAction; import org.eclipse.emf.teneo.test.emf.sample.LibraryValidateResourceAction; import org.eclipse.emf.teneo.test.emf.sample.MindMapAction; @@ -43,13 +44,15 @@ import extlibrary.ExtLibraryAction; * All tests * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> - * @version $Revision: 1.13 $ + * @version $Revision: 1.14 $ */ public class AllGenerateTests { public static Test suite() { MultiCfgTestSuite suite = new MultiCfgTestSuite("Test for org.eclipse.emf.teneo.test.samples", JPOXTestbed .instance().getConfigurations()); + suite.addTest(new JPOXGenerateTest(LibraryResourceReferenceAction.class)); + suite.addTest(new JPOXGenerateTest(SchoolLibraryTest.testAction)); suite.addTest(new JPOXGenerateTest(ExtLibraryAction.class)); diff --git a/tests/org.eclipse.emf.teneo.jpox.test/src/org/eclipse/emf/teneo/jpox/test/emf/sample/AllTests.java b/tests/org.eclipse.emf.teneo.jpox.test/src/org/eclipse/emf/teneo/jpox/test/emf/sample/AllTests.java index 7b9f2c9b8..599e51617 100644 --- a/tests/org.eclipse.emf.teneo.jpox.test/src/org/eclipse/emf/teneo/jpox/test/emf/sample/AllTests.java +++ b/tests/org.eclipse.emf.teneo.jpox.test/src/org/eclipse/emf/teneo/jpox/test/emf/sample/AllTests.java @@ -11,7 +11,7 @@ * Martin Taal * </copyright> * - * $Id: AllTests.java,v 1.18 2007/03/24 11:49:38 mtaal Exp $ + * $Id: AllTests.java,v 1.19 2007/03/28 13:58:06 mtaal Exp $ */ package org.eclipse.emf.teneo.jpox.test.emf.sample; @@ -20,6 +20,7 @@ import junit.framework.Test; import junit.framework.TestSuite; import org.eclipse.emf.teneo.jpox.test.JPOXTestbed; +import org.eclipse.emf.teneo.jpox.test.generate.JPOXGenerateTest; import org.eclipse.emf.teneo.test.conf.MultiCfgTestSuite; import org.eclipse.emf.teneo.test.emf.sample.CatalogResourceAction; import org.eclipse.emf.teneo.test.emf.sample.ForumAction; @@ -28,6 +29,7 @@ import org.eclipse.emf.teneo.test.emf.sample.LibraryGlobalEagerAction; import org.eclipse.emf.teneo.test.emf.sample.LibraryNonResolvingAction; import org.eclipse.emf.teneo.test.emf.sample.LibraryResourceAction; import org.eclipse.emf.teneo.test.emf.sample.LibraryResourceCutPasteAction; +import org.eclipse.emf.teneo.test.emf.sample.LibraryResourceReferenceAction; import org.eclipse.emf.teneo.test.emf.sample.LibrarySerializationAction; import org.eclipse.emf.teneo.test.emf.sample.LibraryValidateResourceAction; import org.eclipse.emf.teneo.test.emf.sample.MindMapAction; @@ -42,13 +44,16 @@ import extlibrary.ExtLibraryAction; * All tests * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> - * @version $Revision: 1.18 $ + * @version $Revision: 1.19 $ */ public class AllTests { public static Test suite() { TestSuite suite = new MultiCfgTestSuite("Test for org.eclipse.emf.teneo.test.samples", JPOXTestbed.instance() .getConfigurations()); + suite.addTestSuite(LibraryResourceReferenceAction.class); +/* + suite.addTestSuite(SchoolLibraryTest.class); suite.addTestSuite(ProductAction.class); @@ -84,6 +89,6 @@ public class AllTests { suite.addTestSuite(PrimerPOAction.class); suite.addTestSuite(ForumAction.class); suite.addTestSuite(CatalogTest.class); - return suite; +*/ return suite; } } diff --git a/tests/org.eclipse.emf.teneo.jpox.test/src/org/eclipse/emf/teneo/jpox/test/issues/AllGenerateTests.java b/tests/org.eclipse.emf.teneo.jpox.test/src/org/eclipse/emf/teneo/jpox/test/issues/AllGenerateTests.java index 0a74e3c43..2c173c332 100644 --- a/tests/org.eclipse.emf.teneo.jpox.test/src/org/eclipse/emf/teneo/jpox/test/issues/AllGenerateTests.java +++ b/tests/org.eclipse.emf.teneo.jpox.test/src/org/eclipse/emf/teneo/jpox/test/issues/AllGenerateTests.java @@ -11,7 +11,7 @@ * Martin Taal * </copyright> * - * $Id: AllGenerateTests.java,v 1.6 2007/03/24 11:49:38 mtaal Exp $ + * $Id: AllGenerateTests.java,v 1.7 2007/03/28 13:58:06 mtaal Exp $ */ package org.eclipse.emf.teneo.jpox.test.issues; @@ -23,6 +23,7 @@ import org.eclipse.emf.teneo.jpox.test.JPOXTestbed; import org.eclipse.emf.teneo.jpox.test.generate.JPOXGenerateTest; import org.eclipse.emf.teneo.test.conf.MultiCfgTestSuite; import org.eclipse.emf.teneo.test.issues.AbstractReferenceAction; +import org.eclipse.emf.teneo.test.issues.AgilAction; import org.eclipse.emf.teneo.test.issues.BagDuplicateAction; import org.eclipse.emf.teneo.test.issues.EnumTestAction; import org.eclipse.emf.teneo.test.issues.InheritanceAction; @@ -35,13 +36,15 @@ import org.eclipse.emf.teneo.test.issues.SimplenmAction; * All tests * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> - * @version $Revision: 1.6 $ + * @version $Revision: 1.7 $ */ public class AllGenerateTests { public static Test suite() { TestSuite suite = new MultiCfgTestSuite("Test for issues", JPOXTestbed.instance().getConfigurations()); + suite.addTest(new JPOXGenerateTest(AgilAction.class)); + suite.addTest(new JPOXGenerateTest(MultipleInheritanceAction.class)); suite.addTest(new JPOXGenerateTest(MainAction.class)); diff --git a/tests/org.eclipse.emf.teneo.jpox.test/src/org/eclipse/emf/teneo/jpox/test/issues/AllTests.java b/tests/org.eclipse.emf.teneo.jpox.test/src/org/eclipse/emf/teneo/jpox/test/issues/AllTests.java index 5a6ee4488..2f795f27d 100644 --- a/tests/org.eclipse.emf.teneo.jpox.test/src/org/eclipse/emf/teneo/jpox/test/issues/AllTests.java +++ b/tests/org.eclipse.emf.teneo.jpox.test/src/org/eclipse/emf/teneo/jpox/test/issues/AllTests.java @@ -11,7 +11,7 @@ * Martin Taal * </copyright> * - * $Id: AllTests.java,v 1.11 2007/03/24 11:49:38 mtaal Exp $ + * $Id: AllTests.java,v 1.12 2007/03/28 13:58:06 mtaal Exp $ */ package org.eclipse.emf.teneo.jpox.test.issues; @@ -21,6 +21,7 @@ import junit.framework.TestSuite; import org.eclipse.emf.teneo.jpox.test.JPOXTestbed; import org.eclipse.emf.teneo.test.conf.MultiCfgTestSuite; +import org.eclipse.emf.teneo.test.issues.AgilAction; import org.eclipse.emf.teneo.test.issues.BagDuplicateAction; import org.eclipse.emf.teneo.test.issues.EnumTestAction; import org.eclipse.emf.teneo.test.issues.InheritanceAction; @@ -32,7 +33,7 @@ import org.eclipse.emf.teneo.test.issues.SimplenmAction; * All tests * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> - * @version $Revision: 1.11 $ + * @version $Revision: 1.12 $ */ public class AllTests { @@ -40,6 +41,8 @@ public class AllTests { TestSuite suite = new MultiCfgTestSuite("Test for org.eclipse.emf.teneo.hibernate.test.issues", JPOXTestbed .instance().getConfigurations()); + suite.addTestSuite(AgilAction.class); + suite.addTestSuite(MultipleInheritanceAction.class); suite.addTestSuite(InterfaceTrueAction.class); diff --git a/tests/org.eclipse.emf.teneo.jpox.test/src/org/eclipse/emf/teneo/jpox/test/stores/JPOXTestStore.java b/tests/org.eclipse.emf.teneo.jpox.test/src/org/eclipse/emf/teneo/jpox/test/stores/JPOXTestStore.java index 6ac407601..1cd571381 100644 --- a/tests/org.eclipse.emf.teneo.jpox.test/src/org/eclipse/emf/teneo/jpox/test/stores/JPOXTestStore.java +++ b/tests/org.eclipse.emf.teneo.jpox.test/src/org/eclipse/emf/teneo/jpox/test/stores/JPOXTestStore.java @@ -11,7 +11,7 @@ * Martin Taal * </copyright> * - * $Id: JPOXTestStore.java,v 1.15 2007/03/21 15:46:24 mtaal Exp $ + * $Id: JPOXTestStore.java,v 1.16 2007/03/28 13:58:07 mtaal Exp $ */ package org.eclipse.emf.teneo.jpox.test.stores; @@ -62,7 +62,7 @@ import org.jpox.metadata.InheritanceStrategy; * The jpox test store encapsulates the datastore actions to a jpox store. * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> - * @version $Revision: 1.15 $ + * @version $Revision: 1.16 $ */ public class JPOXTestStore extends AbstractTestStore { /** The logger */ @@ -137,8 +137,7 @@ public class JPOXTestStore extends AbstractTestStore { log.debug("Copying " + jdoLocation + " to classpath"); EPackage epack = epackages[0]; final File sourceFile = new File(jdoLocation); - final File pluginsDir = sourceFile.getParentFile().getParentFile().getParentFile().getParentFile() - .getParentFile(); + final File pluginsDir = sourceFile.getParentFile().getParentFile().getParentFile().getParentFile(); final File pluginDir = Utils.getPluginDir(pluginsDir, "org.eclipse.emf.teneo.samples"); String packagePath = "bin" + File.separator + epack.getClass().getName().replace('.', File.separatorChar) + ".class"; @@ -150,12 +149,24 @@ public class JPOXTestStore extends AbstractTestStore { packageDirectory = packageFile.getParentFile(); } - final File dest = new File(packageDirectory.getParentFile(), "package.jdo"); + + final File dest; + if (properties.getProperty(AbstractTestStore.STORE_MAPPING_FILE_ONE_DIRECTORY_HIGHER) != null && + properties.getProperty(AbstractTestStore.STORE_MAPPING_FILE_ONE_DIRECTORY_HIGHER).compareToIgnoreCase("true") == 0) { + dest = new File(packageDirectory.getParentFile().getParentFile(), "package.jdo"); + } else { + dest = new File(packageDirectory.getParentFile(), "package.jdo"); + } + + if (!dest.exists()) { + dest.mkdirs(); + } final File destination = new File(dest.getAbsolutePath()); if (destination.exists()) { log.warn("Overwriting existing package.jdo file in location " + destination.getAbsolutePath()); destination.delete(); } + destination.createNewFile(); StoreUtil.copyFile(new File(jdoLocation), destination); } catch (IOException e) { throw new StoreTestException("IOException while copying mapping file", e); |