diff options
author | mtaal | 2009-05-23 13:57:57 +0000 |
---|---|---|
committer | mtaal | 2009-05-23 13:57:57 +0000 |
commit | b79a3054d9dcb1ca1968a53e2b6d87f060ebfe07 (patch) | |
tree | b5e7c2c4c5ccd04b12b85b160c9d96eec85dae1f /tests | |
parent | b14c84ce7816d7da99cad1a44eedc72b13945549 (diff) | |
download | org.eclipse.emf.teneo-b79a3054d9dcb1ca1968a53e2b6d87f060ebfe07.tar.gz org.eclipse.emf.teneo-b79a3054d9dcb1ca1968a53e2b6d87f060ebfe07.tar.xz org.eclipse.emf.teneo-b79a3054d9dcb1ca1968a53e2b6d87f060ebfe07.zip |
Changes for 277570
Diffstat (limited to 'tests')
5 files changed, 184 insertions, 23 deletions
diff --git a/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.test.issues/BZ277570Action_mysql_a_o_hibernate.hbm.xml b/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.test.issues/BZ277570Action_mysql_a_o_hibernate.hbm.xml new file mode 100644 index 000000000..8fc58cfe5 --- /dev/null +++ b/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.test.issues/BZ277570Action_mysql_a_o_hibernate.hbm.xml @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> + +<hibernate-mapping auto-import="false"> + <class name="org.eclipse.emf.teneo.samples.issues.adept.impl.BazImpl" entity-name="Baz" abstract="true" lazy="false" discriminator-value="Baz" table="`baz`"> + <meta attribute="eclassName">Baz</meta> + <meta attribute="epackage">org.eclipse.emf.teneo.samples.issues.bz277570</meta> + <id name="id" type="long" unsaved-value="0"> + <column not-null="true" unique="true" name="`id`"/> + </id> + <discriminator column="`dtype`" type="string"/> + <property name="name" lazy="false" insert="true" update="true" not-null="false" unique="false" type="java.lang.String"> + <column not-null="false" unique="false" name="`name`"/> + </property> + </class> + <class name="org.eclipse.emf.teneo.samples.issues.adept.impl.FooImpl" entity-name="Foo" abstract="false" lazy="false" discriminator-value="Foo" table="`foo`"> + <meta attribute="eclassName">Foo</meta> + <meta attribute="epackage">org.eclipse.emf.teneo.samples.issues.bz277570</meta> + <id name="id" type="long" unsaved-value="0"> + <column not-null="true" unique="true" name="`id`"/> + </id> + <discriminator column="`dtype`" type="string"/> + <list name="bars" lazy="true" cascade="all,delete-orphan"> + <key update="true" foreign-key="foo_bars"> + <column name="`foo_bars_id`" not-null="false" unique="false"/> + </key> + <list-index column="`foo_bars_idx`"/> + <one-to-many entity-name="Bar"/> + </list> + <list name="biffs" lazy="true" cascade="all,delete-orphan"> + <key update="true" foreign-key="foo_biffs"> + <column name="`foo_biffs_id`" not-null="false" unique="false"/> + </key> + <list-index column="`foo_biffs_idx`"/> + <one-to-many entity-name="Biff"/> + </list> + </class> + <subclass name="org.eclipse.emf.teneo.samples.issues.adept.impl.BarImpl" entity-name="Bar" abstract="false" lazy="false" extends="Baz" discriminator-value="Bar"> + <meta attribute="eclassName">Bar</meta> + <meta attribute="epackage">org.eclipse.emf.teneo.samples.issues.bz277570</meta> + <many-to-one name="baz" entity-name="Baz" lazy="false" cascade="merge,persist,save-update,lock,refresh" foreign-key="bar_baz" insert="true" update="true" not-null="false"> + <column not-null="false" unique="false" name="`baz_baz_id`"/> + </many-to-one> + </subclass> + <subclass name="org.eclipse.emf.teneo.samples.issues.adept.impl.BiffImpl" entity-name="Biff" abstract="false" lazy="false" extends="Baz" discriminator-value="Biff"> + <meta attribute="eclassName">Biff</meta> + <meta attribute="epackage">org.eclipse.emf.teneo.samples.issues.bz277570</meta> + </subclass> +</hibernate-mapping>
\ No newline at end of file diff --git a/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.test.issues/BZ277570Action_mysql_e_o_hibernate.hbm.xml b/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.test.issues/BZ277570Action_mysql_e_o_hibernate.hbm.xml new file mode 100644 index 000000000..ca174d180 --- /dev/null +++ b/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.test.issues/BZ277570Action_mysql_e_o_hibernate.hbm.xml @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> + +<hibernate-mapping auto-import="false"> + <class name="org.eclipse.emf.teneo.samples.issues.adept.impl.BazImpl" entity-name="Baz" abstract="true" lazy="false" table="`baz`"> + <meta attribute="eclassName">Baz</meta> + <meta attribute="epackage">org.eclipse.emf.teneo.samples.issues.bz277570</meta> + <id name="id" type="long" unsaved-value="0"> + <column not-null="true" unique="true" name="`id`"/> + </id> + <property name="name" lazy="false" insert="true" update="true" not-null="false" unique="false" type="java.lang.String"> + <column not-null="false" unique="false" name="`name`"/> + </property> + </class> + <class name="org.eclipse.emf.teneo.samples.issues.adept.impl.FooImpl" entity-name="Foo" abstract="false" lazy="false" table="`foo`"> + <meta attribute="eclassName">Foo</meta> + <meta attribute="epackage">org.eclipse.emf.teneo.samples.issues.bz277570</meta> + <id name="id" type="long" unsaved-value="0"> + <column not-null="true" unique="true" name="`id`"/> + </id> + <list name="bars" lazy="true" cascade="all,delete-orphan"> + <key update="true" foreign-key="foo_bars"> + <column name="`foo_bars_id`" not-null="false" unique="false"/> + </key> + <list-index column="`foo_bars_idx`"/> + <one-to-many entity-name="Bar"/> + </list> + <list name="biffs" lazy="true" cascade="all,delete-orphan"> + <key update="true" foreign-key="foo_biffs"> + <column name="`foo_biffs_id`" not-null="false" unique="false"/> + </key> + <list-index column="`foo_biffs_idx`"/> + <one-to-many entity-name="Biff"/> + </list> + </class> + <joined-subclass name="org.eclipse.emf.teneo.samples.issues.adept.impl.BarImpl" entity-name="Bar" abstract="false" lazy="false" extends="Baz" table="`bar`"> + <meta attribute="eclassName">Bar</meta> + <meta attribute="epackage">org.eclipse.emf.teneo.samples.issues.bz277570</meta> + <key> + <column name="`baz_id`"/> + </key> + <many-to-one name="baz" entity-name="Baz" lazy="false" cascade="merge,persist,save-update,lock,refresh" foreign-key="bar_baz" insert="true" update="true" not-null="false"> + <column not-null="false" unique="false" name="`baz_baz_id`"/> + </many-to-one> + </joined-subclass> + <joined-subclass name="org.eclipse.emf.teneo.samples.issues.adept.impl.BiffImpl" entity-name="Biff" abstract="false" lazy="false" extends="Baz" table="`biff`"> + <meta attribute="eclassName">Biff</meta> + <meta attribute="epackage">org.eclipse.emf.teneo.samples.issues.bz277570</meta> + <key> + <column name="`baz_id`"/> + </key> + </joined-subclass> +</hibernate-mapping>
\ No newline at end of file diff --git a/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.test.issues/BZ277570Action_mysql_s_o_hibernate.hbm.xml b/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.test.issues/BZ277570Action_mysql_s_o_hibernate.hbm.xml new file mode 100644 index 000000000..ca174d180 --- /dev/null +++ b/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.test.issues/BZ277570Action_mysql_s_o_hibernate.hbm.xml @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> + +<hibernate-mapping auto-import="false"> + <class name="org.eclipse.emf.teneo.samples.issues.adept.impl.BazImpl" entity-name="Baz" abstract="true" lazy="false" table="`baz`"> + <meta attribute="eclassName">Baz</meta> + <meta attribute="epackage">org.eclipse.emf.teneo.samples.issues.bz277570</meta> + <id name="id" type="long" unsaved-value="0"> + <column not-null="true" unique="true" name="`id`"/> + </id> + <property name="name" lazy="false" insert="true" update="true" not-null="false" unique="false" type="java.lang.String"> + <column not-null="false" unique="false" name="`name`"/> + </property> + </class> + <class name="org.eclipse.emf.teneo.samples.issues.adept.impl.FooImpl" entity-name="Foo" abstract="false" lazy="false" table="`foo`"> + <meta attribute="eclassName">Foo</meta> + <meta attribute="epackage">org.eclipse.emf.teneo.samples.issues.bz277570</meta> + <id name="id" type="long" unsaved-value="0"> + <column not-null="true" unique="true" name="`id`"/> + </id> + <list name="bars" lazy="true" cascade="all,delete-orphan"> + <key update="true" foreign-key="foo_bars"> + <column name="`foo_bars_id`" not-null="false" unique="false"/> + </key> + <list-index column="`foo_bars_idx`"/> + <one-to-many entity-name="Bar"/> + </list> + <list name="biffs" lazy="true" cascade="all,delete-orphan"> + <key update="true" foreign-key="foo_biffs"> + <column name="`foo_biffs_id`" not-null="false" unique="false"/> + </key> + <list-index column="`foo_biffs_idx`"/> + <one-to-many entity-name="Biff"/> + </list> + </class> + <joined-subclass name="org.eclipse.emf.teneo.samples.issues.adept.impl.BarImpl" entity-name="Bar" abstract="false" lazy="false" extends="Baz" table="`bar`"> + <meta attribute="eclassName">Bar</meta> + <meta attribute="epackage">org.eclipse.emf.teneo.samples.issues.bz277570</meta> + <key> + <column name="`baz_id`"/> + </key> + <many-to-one name="baz" entity-name="Baz" lazy="false" cascade="merge,persist,save-update,lock,refresh" foreign-key="bar_baz" insert="true" update="true" not-null="false"> + <column not-null="false" unique="false" name="`baz_baz_id`"/> + </many-to-one> + </joined-subclass> + <joined-subclass name="org.eclipse.emf.teneo.samples.issues.adept.impl.BiffImpl" entity-name="Biff" abstract="false" lazy="false" extends="Baz" table="`biff`"> + <meta attribute="eclassName">Biff</meta> + <meta attribute="epackage">org.eclipse.emf.teneo.samples.issues.bz277570</meta> + <key> + <column name="`baz_id`"/> + </key> + </joined-subclass> +</hibernate-mapping>
\ No newline at end of file diff --git a/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/hibernate/test/issues/AllTests.java b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/hibernate/test/issues/AllTests.java index 291ff678c..c20d5b1b8 100644 --- a/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/hibernate/test/issues/AllTests.java +++ b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/hibernate/test/issues/AllTests.java @@ -27,6 +27,7 @@ import org.eclipse.emf.teneo.test.issues.BZ249246Action; import org.eclipse.emf.teneo.test.issues.BZ249440Action; import org.eclipse.emf.teneo.test.issues.BZ253799Action; import org.eclipse.emf.teneo.test.issues.BZ277546Action; +import org.eclipse.emf.teneo.test.issues.BZ277570Action; import org.eclipse.emf.teneo.test.issues.BagDuplicateAction; import org.eclipse.emf.teneo.test.issues.EnumTestAction; import org.eclipse.emf.teneo.test.issues.GeneralTestAction; @@ -45,13 +46,14 @@ import org.eclipse.emf.teneo.test.issues.TopClassesAction; * All tests * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> - * @version $Revision: 1.42 $ + * @version $Revision: 1.43 $ */ public class AllTests { public static Test suite() { TestSuite suite = new MultiCfgTestSuite("Test for org.eclipse.emf.teneo.hibernate.test.issues", HibernateTestbed.instance().getConfigurations()); + suite.addTestSuite(BZ277570Action.class); suite.addTestSuite(BZ277546Action.class); suite.addTestSuite(BZ258266Action.class); suite.addTestSuite(BZ253799Action.class); diff --git a/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/hibernate/test/stores/HibernateTestStore.java b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/hibernate/test/stores/HibernateTestStore.java index 926db9a0b..420dd39d5 100644 --- a/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/hibernate/test/stores/HibernateTestStore.java +++ b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/hibernate/test/stores/HibernateTestStore.java @@ -53,7 +53,7 @@ import org.hibernate.ejb.EntityManagerImpl; * The hibernate test store encapsulates the datastore actions to a hibernate store. * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> - * @version $Revision: 1.30 $ + * @version $Revision: 1.31 $ */ public class HibernateTestStore extends AbstractTestStore { /** The logger */ @@ -109,8 +109,8 @@ public class HibernateTestStore extends AbstractTestStore { props.setProperty(PersistenceOptions.INHERITANCE_MAPPING, inheritanceType.getName()); for (EPackage element : epackages) { - log.debug("Creating HibernateTeststore for " + element.getName() + " adapter " + - adapter.getClass().getName()); + log.debug("Creating HibernateTeststore for " + element.getName() + " adapter " + + adapter.getClass().getName()); } setDataStore(); @@ -166,8 +166,8 @@ public class HibernateTestStore extends AbstractTestStore { // do a special trick for hsqldb, because hsqldb expects all identifiers to be // escaped or otherwise uppercases them, so uppercase everything automatically - if (getDatabaseAdapter() instanceof HsqldbTestDatabaseAdapter && - !props.containsKey(PersistenceOptions.SQL_CASE_STRATEGY)) { + if (getDatabaseAdapter() instanceof HsqldbTestDatabaseAdapter + && !props.containsKey(PersistenceOptions.SQL_CASE_STRATEGY)) { props.setProperty(PersistenceOptions.SQL_CASE_STRATEGY, "uppercase"); } emfDataStore.setProperties(props); @@ -283,7 +283,7 @@ public class HibernateTestStore extends AbstractTestStore { // final Class interf = replaceClass(clazz); if (sessionWrapper.isEJB3EntityManager()) { return query("select o from " + getEntityName(clazz) + " o where o." + field + "=\'" + value + "\'", - checkCount); + checkCount); } else { return query("from " + getEntityName(clazz) + " where " + field + "=\'" + value + "\'", checkCount); } @@ -301,8 +301,8 @@ public class HibernateTestStore extends AbstractTestStore { final List<?> result = sessionWrapper.executeQuery(qryStr); 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; } @@ -316,11 +316,11 @@ public class HibernateTestStore extends AbstractTestStore { sessionWrapper.delete(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); + TestCase.assertTrue("The objects of class: " + clazz.getName() + + " was not deleted while this should be possible", !shouldSucceed); if (sessionWrapper.isTransactionActive()) { rollbackTransaction(); } @@ -333,8 +333,10 @@ public class HibernateTestStore extends AbstractTestStore { @SuppressWarnings("unchecked") public <T> T getObject(Class<T> 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 (T) l.get(0); } @@ -353,8 +355,8 @@ public class HibernateTestStore extends AbstractTestStore { @Override public void checkNumber(Class<?> clazz, int count) { final List<?> list = getObjects(clazz); - TestCase.assertTrue("Expected " + count + " object(s) but there are " + list.size() + - " object(s) of this class in the datastore: " + clazz.getName(), list.size() == count); + TestCase.assertTrue("Expected " + count + " object(s) but there are " + list.size() + + " object(s) of this class in the datastore: " + clazz.getName(), list.size() == count); } /** Flushes all updates to the underlying datastore */ @@ -369,8 +371,7 @@ public class HibernateTestStore extends AbstractTestStore { } /** - * Is called just after the test, the dropStore parameter can be used to prevent dropping the - * database when an error + * Is called just after the test, the dropStore parameter can be used to prevent dropping the database when an error */ @Override public void doTearDown() { @@ -415,10 +416,9 @@ public class HibernateTestStore 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; return - * HibernateHelper.INSTANCE.getInstanceClass(interfaze); } + * 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; + * return HibernateHelper.INSTANCE.getInstanceClass(interfaze); } */ /** Gets the referedto list */ @@ -447,6 +447,10 @@ public class HibernateTestStore extends AbstractTestStore { sessionWrapper.refresh(obj); } + public Object merge(Object object) { + return sessionWrapper.merge(object); + } + /** Check inheritance strategy */ public boolean isInheritanceStrategy(Class<?> cls, InheritanceType strategy) { return sessionWrapper.isInheritanceStrategy(cls, strategy); |