Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormtaal2007-07-04 19:29:34 +0000
committermtaal2007-07-04 19:29:34 +0000
commitf7948f38728b1b28bb4f019c75a3c3b90a0f2425 (patch)
tree1a859d0fbefb9d5166c3e46d0dd48ec00f67628d /tests/org.eclipse.emf.teneo.jpox.test/src
parent2c131091965d3c6ee41615d472799a8ca9465746 (diff)
downloadorg.eclipse.emf.teneo-f7948f38728b1b28bb4f019c75a3c3b90a0f2425.tar.gz
org.eclipse.emf.teneo-f7948f38728b1b28bb4f019c75a3c3b90a0f2425.tar.xz
org.eclipse.emf.teneo-f7948f38728b1b28bb4f019c75a3c3b90a0f2425.zip
[187984]
[193697] [193699] [195371] Note: regenerated all annotation emf models, the new java code uses java 5 enums instead of the old _LITERAL. It is therefore incompatible with the previous code. On the other hand, the annotation model itself is primarily for internal use.
Diffstat (limited to 'tests/org.eclipse.emf.teneo.jpox.test/src')
-rw-r--r--tests/org.eclipse.emf.teneo.jpox.test/src/org/eclipse/emf/teneo/jpox/test/issues/AllGenerateTests.java18
-rw-r--r--tests/org.eclipse.emf.teneo.jpox.test/src/org/eclipse/emf/teneo/jpox/test/issues/AllTests.java21
-rw-r--r--tests/org.eclipse.emf.teneo.jpox.test/src/org/eclipse/emf/teneo/jpox/test/stores/JPOXTestStore.java91
3 files changed, 61 insertions, 69 deletions
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 2dca079c2..c67dc6106 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.8 2007/03/30 19:05:16 mtaal Exp $
+ * $Id: AllGenerateTests.java,v 1.9 2007/07/04 19:29:35 mtaal Exp $
*/
package org.eclipse.emf.teneo.jpox.test.issues;
@@ -25,6 +25,7 @@ import org.eclipse.emf.teneo.test.conf.MultiCfgTestSuite;
import org.eclipse.emf.teneo.test.issues.AbstractReferenceAction;
import org.eclipse.emf.teneo.test.issues.BagDuplicateAction;
import org.eclipse.emf.teneo.test.issues.EnumTestAction;
+import org.eclipse.emf.teneo.test.issues.GeneralTestAction;
import org.eclipse.emf.teneo.test.issues.InheritanceAction;
import org.eclipse.emf.teneo.test.issues.InterfaceTrueAction;
import org.eclipse.emf.teneo.test.issues.MainAction;
@@ -35,7 +36,7 @@ import org.eclipse.emf.teneo.test.issues.SimplenmAction;
* All tests
*
* @author <a href="mailto:mtaal@elver.org">Martin Taal</a>
- * @version $Revision: 1.8 $
+ * @version $Revision: 1.9 $
*/
public class AllGenerateTests {
@@ -45,6 +46,7 @@ public class AllGenerateTests {
suite.addTest(new JPOXGenerateTest(MultipleInheritanceAction.class));
suite.addTest(new JPOXGenerateTest(MainAction.class));
+ suite.addTest(new JPOXGenerateTest(GeneralTestAction.class));
suite.addTest(new JPOXGenerateTest(InheritanceAction.class));
suite.addTest(new JPOXGenerateTest(BagDuplicateAction.class));
@@ -53,20 +55,10 @@ public class AllGenerateTests {
suite.addTest(new JPOXGenerateTest(InterfaceTrueAction.class));
suite.addTest(new JPOXGenerateTest(AbstractReferenceAction.class));
suite.addTest(new JPOXGenerateTest(SimplenmAction.class));
-
+
// seems not to work for jpox, is unimportant
// suite.addTest(new JPOXGenerateTest(TopClassesAction.class));
- // the following testcases are all non-epackage based
- // suite.addTest(new JPOXGenerateTest(DuplicateFieldAction.class));
- // suite.addTest(new JPOXGenerateTest(HierarchyQueryAction.class));
- // suite.addTest(new JPOXGenerateTest(ReferenceCycleAction.class));
- // suite.addTest(new JPOXGenerateTest(Relation1nAction.class));
- // suite.addTest(new JPOXGenerateTest(Relation2Action.class));
- // suite.addTest(new JPOXGenerateTest(Relation3Action.class));
- // suite.addTest(new JPOXGenerateTest(Relation4Action.class));
- // suite.addTest(new JPOXGenerateTest(Relation5Action.class));
- // suite.addTest(new JPOXGenerateTest(TestClassHierarchyAction.class));
return suite;
}
}
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 e863f0373..f7ce57f8d 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.13 2007/03/30 19:05:16 mtaal Exp $
+ * $Id: AllTests.java,v 1.14 2007/07/04 19:29:35 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.test.conf.MultiCfgTestSuite;
import org.eclipse.emf.teneo.test.issues.BagDuplicateAction;
import org.eclipse.emf.teneo.test.issues.EnumTestAction;
+import org.eclipse.emf.teneo.test.issues.GeneralTestAction;
import org.eclipse.emf.teneo.test.issues.InheritanceAction;
import org.eclipse.emf.teneo.test.issues.InterfaceTrueAction;
import org.eclipse.emf.teneo.test.issues.MultipleInheritanceAction;
@@ -32,16 +33,18 @@ import org.eclipse.emf.teneo.test.issues.SimplenmAction;
* All tests
*
* @author <a href="mailto:mtaal@elver.org">Martin Taal</a>
- * @version $Revision: 1.13 $
+ * @version $Revision: 1.14 $
*/
public class AllTests {
public static Test suite() {
- TestSuite suite = new MultiCfgTestSuite("Test for org.eclipse.emf.teneo.hibernate.test.issues", JPOXTestbed
- .instance().getConfigurations());
+ TestSuite suite =
+ new MultiCfgTestSuite("Test for org.eclipse.emf.teneo.hibernate.test.issues", JPOXTestbed.instance()
+ .getConfigurations());
suite.addTestSuite(MultipleInheritanceAction.class);
+ suite.addTestSuite(GeneralTestAction.class);
suite.addTestSuite(InterfaceTrueAction.class);
suite.addTestSuite(BagDuplicateAction.class);
suite.addTestSuite(InheritanceAction.class);
@@ -55,10 +58,12 @@ public class AllTests {
// the following test cases are all non-epackage
/*
- * suite.addTestSuite(DuplicateFieldAction.class); suite.addTestSuite(HierarchyQueryAction.class);
- * suite.addTestSuite(ReferenceCycleAction.class); suite.addTestSuite(Relation1nAction.class);
- * suite.addTestSuite(Relation2Action.class); suite.addTestSuite(Relation3Action.class);
- * suite.addTestSuite(Relation4Action.class); suite.addTestSuite(Relation5Action.class);
+ * suite.addTestSuite(DuplicateFieldAction.class);
+ * suite.addTestSuite(HierarchyQueryAction.class);
+ * suite.addTestSuite(ReferenceCycleAction.class);
+ * suite.addTestSuite(Relation1nAction.class); suite.addTestSuite(Relation2Action.class);
+ * suite.addTestSuite(Relation3Action.class); suite.addTestSuite(Relation4Action.class);
+ * suite.addTestSuite(Relation5Action.class);
* suite.addTestSuite(TestClassHierarchyAction.class);
*/
return suite;
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 e6a6059e7..0ec35b14d 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
@@ -43,6 +43,7 @@ import org.eclipse.emf.teneo.jpox.test.Utils;
import org.eclipse.emf.teneo.test.StoreTestException;
import org.eclipse.emf.teneo.test.stores.AbstractTestStore;
import org.eclipse.emf.teneo.test.stores.TestDatabaseAdapter;
+import org.eclipse.emf.teneo.util.EcoreDataTypes;
import org.eclipse.emf.teneo.util.StoreUtil;
import org.jpox.JDOClassLoaderResolver;
import org.jpox.PMFConfiguration;
@@ -54,7 +55,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.18 $
+ * @version $Revision: 1.19 $
*/
public class JPOXTestStore extends AbstractTestStore {
/** The logger */
@@ -93,8 +94,8 @@ public class JPOXTestStore extends AbstractTestStore {
/**
* Constructor for emf test cases
*/
- public JPOXTestStore(TestDatabaseAdapter adapter, EPackage[] epackages, String jdoLocation,
- Properties props, InheritanceType inheritanceType) {
+ public JPOXTestStore(TestDatabaseAdapter adapter, EPackage[] epackages, String jdoLocation, Properties props,
+ InheritanceType inheritanceType) {
super(adapter);
this.epackages = epackages;
this.props = props;
@@ -111,19 +112,16 @@ public class JPOXTestStore extends AbstractTestStore {
Properties properties = new Properties();
properties.putAll(props);
- properties.setProperty(PMFConfiguration.JDO_DATASTORE_DRIVERNAME_PROPERTY, adapter
- .getDbDriver());
+ properties.setProperty(PMFConfiguration.JDO_DATASTORE_DRIVERNAME_PROPERTY, adapter.getDbDriver());
properties.setProperty(PMFConfiguration.JDO_DATASTORE_URL_PROPERTY, adapter.getDbUrl());
- properties.setProperty(PMFConfiguration.JDO_DATASTORE_USERNAME_PROPERTY, adapter
- .getDbUser());
- properties
- .setProperty(PMFConfiguration.JDO_DATASTORE_PASSWORD_PROPERTY, adapter.getDbPwd());
+ properties.setProperty(PMFConfiguration.JDO_DATASTORE_USERNAME_PROPERTY, adapter.getDbUser());
+ properties.setProperty(PMFConfiguration.JDO_DATASTORE_PASSWORD_PROPERTY, adapter.getDbPwd());
properties.setProperty(PMFConfiguration.IDENTIFIER_CASE_PROPERTY, "LowerCase");
// properties.setProperty(PMFConfiguration.JDO_MAPPING_CATALOG_PROPERTY,
// adapter.getDbName());
- if (inheritanceType.getValue() == InheritanceType.JOINED) {
+ if (inheritanceType == InheritanceType.JOINED) {
properties.setProperty(PMFConfiguration.DEFAULT_INHERITANCE_STRATEGY_PROPERTY, "JPOX");
} else {
properties.setProperty(PMFConfiguration.DEFAULT_INHERITANCE_STRATEGY_PROPERTY, "JDO2");
@@ -133,26 +131,21 @@ 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();
+ 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";
+ "bin" + File.separator + epack.getClass().getName().replace('.', File.separatorChar) + ".class";
File packageFile = new File(pluginDir, packagePath);
File packageDirectory = packageFile.getParentFile();
if (!packageDirectory.exists()) {
- packagePath =
- epack.getClass().getName().replace('.', File.separatorChar) + ".class";
+ packagePath = epack.getClass().getName().replace('.', File.separatorChar) + ".class";
packageFile = new File(pluginDir, packagePath);
packageDirectory = packageFile.getParentFile();
}
final File dest;
- if (properties.getProperty(AbstractTestStore.STORE_MAPPING_FILE_ONE_DIRECTORY_HIGHER) != null
- && properties.getProperty(
- AbstractTestStore.STORE_MAPPING_FILE_ONE_DIRECTORY_HIGHER)
+ 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 {
@@ -164,8 +157,7 @@ public class JPOXTestStore extends AbstractTestStore {
}
final File destination = new File(dest.getAbsolutePath());
if (destination.exists()) {
- log.warn("Overwriting existing package.jdo file in location "
- + destination.getAbsolutePath());
+ log.warn("Overwriting existing package.jdo file in location " + destination.getAbsolutePath());
destination.delete();
}
destination.createNewFile();
@@ -235,7 +227,9 @@ public class JPOXTestStore extends AbstractTestStore {
/** Rollback transaction */
public void rollbackTransaction() {
- if (tx.isActive()) tx.rollback();
+ if (tx.isActive()) {
+ tx.rollback();
+ }
refresh();
}
@@ -262,8 +256,7 @@ public class JPOXTestStore extends AbstractTestStore {
/** Query for a class using a field and value pair */
public List query(Class clazz, String field, String value, int checkCount) {
final Class interf = replaceClass(clazz);
- return query("SELECT FROM " + interf.getName() + " WHERE " + field + "==\"" + value + "\"",
- checkCount);
+ return query("SELECT FROM " + interf.getName() + " WHERE " + field + "==\"" + value + "\"", checkCount);
}
/** Queries for an object */
@@ -279,9 +272,8 @@ public class JPOXTestStore extends AbstractTestStore {
final List result = (List) qry.execute();
if (checkCount > 0) {
- TestCase.assertTrue("Expected " + checkCount
- + " object(s) for this query but there are " + result.size()
- + " object(s) for the query " + qryStr, result.size() == checkCount);
+ TestCase.assertTrue("Expected " + checkCount + " object(s) for this query but there are " + result.size() +
+ " object(s) for the query " + qryStr, result.size() == checkCount);
}
return result;
}
@@ -295,12 +287,14 @@ public class JPOXTestStore extends AbstractTestStore {
pm.deletePersistent(l.get(i));
}
commitTransaction();
- TestCase.assertTrue("The objects of class: " + clazz.getName()
- + " was deleted while this should not be possible", shouldSucceed);
+ TestCase.assertTrue("The objects of class: " + clazz.getName() +
+ " was deleted while this should not be possible", shouldSucceed);
} catch (Exception e) {
- TestCase.assertTrue("The objects of class: " + clazz.getName()
- + " was not deleted while this should be possible", !shouldSucceed);
- if (tx.isActive()) rollbackTransaction();
+ TestCase.assertTrue("The objects of class: " + clazz.getName() +
+ " was not deleted while this should be possible", !shouldSucceed);
+ if (tx.isActive()) {
+ rollbackTransaction();
+ }
}
}
@@ -308,9 +302,8 @@ public class JPOXTestStore extends AbstractTestStore {
@Override
public Object getObject(Class clazz) {
List l = getObjects(clazz); // replace class is called in getObjects
- TestCase.assertTrue("There are " + l.size()
- + " object(s) of this class in the datastore, 1 was expected, class: "
- + clazz.getName(), l.size() == 1);
+ TestCase.assertTrue("There are " + l.size() +
+ " object(s) of this class in the datastore, 1 was expected, class: " + clazz.getName(), l.size() == 1);
return l.get(0);
}
@@ -332,9 +325,8 @@ public class JPOXTestStore extends AbstractTestStore {
Query q = pm.newQuery(e);
Collection c = (Collection) q.execute();
- TestCase.assertTrue("Expected " + count + " object(s) but there are " + c.size()
- + " object(s) of this class in the datastore: " + clazz.getName(),
- c.size() == count);
+ TestCase.assertTrue("Expected " + count + " object(s) but there are " + c.size() +
+ " object(s) of this class in the datastore: " + clazz.getName(), c.size() == count);
q.closeAll();
}
@@ -399,8 +391,7 @@ public class JPOXTestStore extends AbstractTestStore {
/** Base method to get a resource belonging to the pmf of this test case */
public Resource getResource(String extraParam) {
- String uriStr =
- "jpox://?" + JPOXResource.DS_NAME_PARAM + "=" + getDatabaseAdapter().getDbName();
+ String uriStr = "jpox://?" + JPOXResource.DS_NAME_PARAM + "=" + getDatabaseAdapter().getDbName();
if (extraParam != null) {
uriStr += "&" + extraParam;
@@ -414,8 +405,12 @@ public class JPOXTestStore extends AbstractTestStore {
/** Replaces a passed EMF Interface by its concrete class */
private Class replaceClass(Class interfaze) {
- if (!interfaze.isInterface()) return interfaze;
- if (!EObject.class.isAssignableFrom(interfaze)) return interfaze;
+ if (!interfaze.isInterface()) {
+ return interfaze;
+ }
+ if (!EObject.class.isAssignableFrom(interfaze)) {
+ return interfaze;
+ }
return JpoxHelper.INSTANCE.getInstanceClass(interfaze);
}
@@ -443,12 +438,12 @@ public class JPOXTestStore extends AbstractTestStore {
/** Check inheritance strategy */
public boolean isInheritanceStrategy(Class<?> clazz, InheritanceType strategy) {
final AbstractClassMetaData cmd =
- ((PersistenceManagerFactoryImpl) pmf).getPMFContext().getMetaDataManager()
- .getMetaDataForClass(clazz, clr);
- if (strategy.equals(InheritanceType.SINGLE_TABLE_LITERAL)) {
+ ((PersistenceManagerFactoryImpl) pmf).getPMFContext().getMetaDataManager().getMetaDataForClass(clazz,
+ clr);
+ if (strategy.equals(InheritanceType.SINGLE_TABLE)) {
return cmd.getInheritanceMetaData().getStrategyValue() == InheritanceStrategy.SUPERCLASS_TABLE;
}
- if (strategy.equals(InheritanceType.JOINED_LITERAL)) {
+ if (strategy.equals(InheritanceType.JOINED)) {
return cmd.getInheritanceMetaData().getStrategyValue() == InheritanceStrategy.NEW_TABLE;
}
throw new StoreTestException("Strategy: " + strategy.toString() + " not supported ");
@@ -481,6 +476,6 @@ public class JPOXTestStore extends AbstractTestStore {
/** Set the xmlcalendar date */
public Object getDate(Date date) {
- return date;
+ return EcoreDataTypes.INSTANCE.getXMLGregorianCalendar(date);
}
} \ No newline at end of file

Back to the top