Hibernate SVN: r10980 - in branches/Branch_3_2/Hibernate3/test/org/hibernate: junit/functional test test/bidi test/legacy
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-12-12 19:13:43 -0500 (Tue, 12 Dec 2006)
New Revision: 10980
Modified:
branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/functional/FunctionalTestCase.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/AllTests.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bidi/AuctionTest2.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/MasterDetailTest.java
Log:
cleanup
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/functional/FunctionalTestCase.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/functional/FunctionalTestCase.java 2006-12-13 00:13:19 UTC (rev 10979)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/functional/FunctionalTestCase.java 2006-12-13 00:13:43 UTC (rev 10980)
@@ -377,7 +377,7 @@
* @return true if sensitive
*/
protected boolean dialectIsCaseSensitive(String testDescription) {
- if ( getDialect().areStringComparisonsCaseInsensitive() ) {
+ if ( ! getDialect().areStringComparisonsCaseInsensitive() ) {
reportSkip( "Dialect is case sensitive. ", testDescription );
return true;
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/AllTests.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/AllTests.java 2006-12-13 00:13:19 UTC (rev 10979)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/AllTests.java 2006-12-13 00:13:43 UTC (rev 10980)
@@ -322,7 +322,6 @@
suite.addTest( OneToOneCacheTest.suite() );
suite.addTest( NonReflectiveBinderTest.suite() );
suite.addTest( ConfigurationPerformanceTest.suite() ); // Added to ensure we can utilize the recommended performance tips ;)
- suite.addTest( CustomSQLTest.suite() );
return filter( suite );
// return suite;
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bidi/AuctionTest2.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bidi/AuctionTest2.java 2006-12-13 00:13:19 UTC (rev 10979)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bidi/AuctionTest2.java 2006-12-13 00:13:43 UTC (rev 10980)
@@ -26,14 +26,18 @@
return new String[] { "bidi/Auction2.hbm.xml" };
}
+ public boolean createSchema() {
+ return getDialect().supportsExistsInSelect();
+ }
+
public static Test suite() {
return new FunctionalTestClassTestSuite( AuctionTest2.class );
}
public void testLazy() {
-
- if ( getDialect() instanceof Oracle9Dialect ) {
- return; //ora doesn't like exists() in the select clause
+ if ( ! getDialect().supportsExistsInSelect() ) {
+ reportSkip( "dialect does not support exist fragments in the select clause", "bidi support" );
+ return;
}
Session s = openSession();
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/MasterDetailTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/MasterDetailTest.java 2006-12-13 00:13:19 UTC (rev 10979)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/MasterDetailTest.java 2006-12-13 00:13:43 UTC (rev 10980)
@@ -877,7 +877,7 @@
ss.close();
s.refresh(c);
- assertTrue( c.getSubcategories().size()==2 );
+ assertEquals( 2, c.getSubcategories().size() );
s.flush();
s.connection().commit();
@@ -885,7 +885,7 @@
s = openSession();
c = (Category) s.load(Category.class, id);
- assertTrue( c.getSubcategories().size()==2 );
+ assertEquals( 2, c.getSubcategories().size() );
s.delete(c);
s.flush();
s.connection().commit();
17 years, 11 months
Hibernate SVN: r10979 - branches/Branch_3_2/Hibernate3/src/org/hibernate/dialect
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-12-12 19:13:19 -0500 (Tue, 12 Dec 2006)
New Revision: 10979
Modified:
branches/Branch_3_2/Hibernate3/src/org/hibernate/dialect/Dialect.java
branches/Branch_3_2/Hibernate3/src/org/hibernate/dialect/Oracle9Dialect.java
branches/Branch_3_2/Hibernate3/src/org/hibernate/dialect/SybaseDialect.java
Log:
added more dialect metadata
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/dialect/Dialect.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/dialect/Dialect.java 2006-12-13 00:12:56 UTC (rev 10978)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/dialect/Dialect.java 2006-12-13 00:13:19 UTC (rev 10979)
@@ -1628,4 +1628,13 @@
public boolean supportsSubqueryOnMutatingTable() {
return true;
}
+
+ /**
+ * Does the dialect support an exists statement in the select clause?
+ *
+ * @return
+ */
+ public boolean supportsExistsInSelect() {
+ return true;
+ }
}
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/dialect/Oracle9Dialect.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/dialect/Oracle9Dialect.java 2006-12-13 00:12:56 UTC (rev 10978)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/dialect/Oracle9Dialect.java 2006-12-13 00:13:19 UTC (rev 10979)
@@ -332,4 +332,8 @@
public boolean supportsEmptyInList() {
return false;
}
+
+ public boolean supportsExistsInSelect() {
+ return false;
+ }
}
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/dialect/SybaseDialect.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/dialect/SybaseDialect.java 2006-12-13 00:12:56 UTC (rev 10978)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/dialect/SybaseDialect.java 2006-12-13 00:13:19 UTC (rev 10979)
@@ -186,4 +186,8 @@
public boolean supportsEmptyInList() {
return false;
}
+
+ public boolean supportsExistsInSelect() {
+ return false;
+ }
}
17 years, 11 months
Hibernate SVN: r10978 - trunk/Hibernate3/src/org/hibernate/dialect
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-12-12 19:12:56 -0500 (Tue, 12 Dec 2006)
New Revision: 10978
Modified:
trunk/Hibernate3/src/org/hibernate/dialect/Dialect.java
trunk/Hibernate3/src/org/hibernate/dialect/Oracle9Dialect.java
trunk/Hibernate3/src/org/hibernate/dialect/SybaseDialect.java
Log:
added more dialect metadata
Modified: trunk/Hibernate3/src/org/hibernate/dialect/Dialect.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/dialect/Dialect.java 2006-12-12 23:28:04 UTC (rev 10977)
+++ trunk/Hibernate3/src/org/hibernate/dialect/Dialect.java 2006-12-13 00:12:56 UTC (rev 10978)
@@ -1627,4 +1627,13 @@
public boolean supportsSubqueryOnMutatingTable() {
return true;
}
+
+ /**
+ * Does the dialect support an exists statement in the select clause?
+ *
+ * @return
+ */
+ public boolean supportsExistsInSelect() {
+ return true;
+ }
}
Modified: trunk/Hibernate3/src/org/hibernate/dialect/Oracle9Dialect.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/dialect/Oracle9Dialect.java 2006-12-12 23:28:04 UTC (rev 10977)
+++ trunk/Hibernate3/src/org/hibernate/dialect/Oracle9Dialect.java 2006-12-13 00:12:56 UTC (rev 10978)
@@ -332,4 +332,8 @@
public boolean supportsEmptyInList() {
return false;
}
+
+ public boolean supportsExistsInSelect() {
+ return false;
+ }
}
Modified: trunk/Hibernate3/src/org/hibernate/dialect/SybaseDialect.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/dialect/SybaseDialect.java 2006-12-12 23:28:04 UTC (rev 10977)
+++ trunk/Hibernate3/src/org/hibernate/dialect/SybaseDialect.java 2006-12-13 00:12:56 UTC (rev 10978)
@@ -186,4 +186,8 @@
public boolean supportsEmptyInList() {
return false;
}
+
+ public boolean supportsExistsInSelect() {
+ return false;
+ }
}
17 years, 11 months
Hibernate SVN: r10977 - in trunk/Hibernate3/test/org/hibernate: . junit junit/functional test test/abstractembeddedcomponents/cid test/abstractembeddedcomponents/propertyref test/any test/array test/ast test/batch test/batchfetch test/bidi test/bytecode/cglib test/bytecode/javassist test/cache test/cache/ehcache test/cache/treecache/optimistic test/cache/treecache/pessimistic test/cascade test/cfg test/cid test/collection test/collection/bag test/collection/idbag test/collection/list tes
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-12-12 18:28:04 -0500 (Tue, 12 Dec 2006)
New Revision: 10977
Added:
trunk/Hibernate3/test/org/hibernate/junit/
trunk/Hibernate3/test/org/hibernate/junit/AbstractClassLoaderIsolatedTestCase.java
trunk/Hibernate3/test/org/hibernate/junit/SkipLog.java
trunk/Hibernate3/test/org/hibernate/junit/TestSuiteVisitor.java
trunk/Hibernate3/test/org/hibernate/junit/UnitTestCase.java
trunk/Hibernate3/test/org/hibernate/junit/functional/
trunk/Hibernate3/test/org/hibernate/junit/functional/DatabaseSpecificFunctionalTestCase.java
trunk/Hibernate3/test/org/hibernate/junit/functional/ExecutionEnvironment.java
trunk/Hibernate3/test/org/hibernate/junit/functional/FunctionalTestCase.java
trunk/Hibernate3/test/org/hibernate/junit/functional/FunctionalTestClassTestSuite.java
trunk/Hibernate3/test/org/hibernate/test/collection/original/
trunk/Hibernate3/test/org/hibernate/test/collection/original/CollectionTest.java
trunk/Hibernate3/test/org/hibernate/test/collection/original/Email.java
trunk/Hibernate3/test/org/hibernate/test/collection/original/Permission.java
trunk/Hibernate3/test/org/hibernate/test/collection/original/User.java
trunk/Hibernate3/test/org/hibernate/test/collection/original/UserPermissions.hbm.xml
trunk/Hibernate3/test/org/hibernate/test/dynamicentity/DynamicEntitySuite.java
trunk/Hibernate3/test/org/hibernate/test/entitymode/
trunk/Hibernate3/test/org/hibernate/test/entitymode/EntityModeSuite.java
trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/
trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/Dom4jSuite.java
trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/accessors/
trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/accessors/Dom4jAccessorTest.java
trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/basic/
trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/basic/AB.hbm.xml
trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/basic/Account.hbm.xml
trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/basic/Dom4jTest.java
trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/basic/Employer.hbm.xml
trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/many2one/
trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/many2one/Car.hbm.xml
trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/many2one/Car.java
trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/many2one/CarPart.java
trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/many2one/CarType.java
trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/many2one/Dom4jManyToOneTest.java
trunk/Hibernate3/test/org/hibernate/test/entitymode/map/
trunk/Hibernate3/test/org/hibernate/test/entitymode/map/MapSuite.java
trunk/Hibernate3/test/org/hibernate/test/entitymode/map/basic/
trunk/Hibernate3/test/org/hibernate/test/entitymode/map/basic/DynamicClassTest.java
trunk/Hibernate3/test/org/hibernate/test/entitymode/map/basic/ProductLine.hbm.xml
trunk/Hibernate3/test/org/hibernate/test/entitymode/multi/
trunk/Hibernate3/test/org/hibernate/test/entitymode/multi/MultiRepresentationTest.java
trunk/Hibernate3/test/org/hibernate/test/entitymode/multi/Stock.hbm.xml
trunk/Hibernate3/test/org/hibernate/test/entitymode/multi/Stock.java
trunk/Hibernate3/test/org/hibernate/test/entitymode/multi/Valuation.hbm.xml
trunk/Hibernate3/test/org/hibernate/test/entitymode/multi/Valuation.java
trunk/Hibernate3/test/org/hibernate/test/generated/GeneratedPropertySuite.java
trunk/Hibernate3/test/org/hibernate/test/generatedkeys/GeneratedKeysSuite.java
trunk/Hibernate3/test/org/hibernate/test/hql/CriteriaClassicAggregationReturnTest.java
trunk/Hibernate3/test/org/hibernate/test/jpa/lock/JPALockTest.java
trunk/Hibernate3/test/org/hibernate/test/onetoone/OneToOneSuite.java
trunk/Hibernate3/test/org/hibernate/test/onetoone/formula/
trunk/Hibernate3/test/org/hibernate/test/onetoone/formula/Address.java
trunk/Hibernate3/test/org/hibernate/test/onetoone/formula/OneToOneFormulaTest.java
trunk/Hibernate3/test/org/hibernate/test/onetoone/formula/Person.hbm.xml
trunk/Hibernate3/test/org/hibernate/test/onetoone/formula/Person.java
trunk/Hibernate3/test/org/hibernate/test/onetoone/joined/JoinedSubclassOneToOneTest.java
trunk/Hibernate3/test/org/hibernate/test/onetoone/link/
trunk/Hibernate3/test/org/hibernate/test/onetoone/link/Customer.java
trunk/Hibernate3/test/org/hibernate/test/onetoone/link/Employee.java
trunk/Hibernate3/test/org/hibernate/test/onetoone/link/OneToOneLinkTest.java
trunk/Hibernate3/test/org/hibernate/test/onetoone/link/Person.hbm.xml
trunk/Hibernate3/test/org/hibernate/test/onetoone/link/Person.java
trunk/Hibernate3/test/org/hibernate/test/onetoone/nopojo/DynamicMapOneToOneTest.java
trunk/Hibernate3/test/org/hibernate/test/onetoone/singletable/DiscrimSubclassOneToOneTest.java
trunk/Hibernate3/test/org/hibernate/test/orphan/OrphanSuite.java
Removed:
trunk/Hibernate3/test/org/hibernate/test/AbstractClassLoaderIsolatedTestCase.java
trunk/Hibernate3/test/org/hibernate/test/DatabaseSpecificTestCase.java
trunk/Hibernate3/test/org/hibernate/test/TestSuiteVisitor.java
trunk/Hibernate3/test/org/hibernate/test/collection/CollectionTest.java
trunk/Hibernate3/test/org/hibernate/test/collection/Email.java
trunk/Hibernate3/test/org/hibernate/test/collection/Permission.java
trunk/Hibernate3/test/org/hibernate/test/collection/User.java
trunk/Hibernate3/test/org/hibernate/test/collection/UserPermissions.hbm.xml
trunk/Hibernate3/test/org/hibernate/test/component/A.java
trunk/Hibernate3/test/org/hibernate/test/component/ABC.hbm.xml
trunk/Hibernate3/test/org/hibernate/test/component/B.java
trunk/Hibernate3/test/org/hibernate/test/component/C.java
trunk/Hibernate3/test/org/hibernate/test/component/DynamicComponentTest.java
trunk/Hibernate3/test/org/hibernate/test/dom4j/
trunk/Hibernate3/test/org/hibernate/test/dynamic/
trunk/Hibernate3/test/org/hibernate/test/entity/
trunk/Hibernate3/test/org/hibernate/test/jpa/lock/EJB3LockTest.java
trunk/Hibernate3/test/org/hibernate/test/onetoone/joined/OneToOneTest.java
trunk/Hibernate3/test/org/hibernate/test/onetoone/nopojo/OneToOneTest.java
trunk/Hibernate3/test/org/hibernate/test/onetoone/singletable/OneToOneTest.java
trunk/Hibernate3/test/org/hibernate/test/onetooneformula/
trunk/Hibernate3/test/org/hibernate/test/onetoonelink/
trunk/Hibernate3/test/org/hibernate/test/sqlinterceptor/
Modified:
trunk/Hibernate3/test/org/hibernate/test/AllTests.java
trunk/Hibernate3/test/org/hibernate/test/TestCase.java
trunk/Hibernate3/test/org/hibernate/test/TestSelector.java
trunk/Hibernate3/test/org/hibernate/test/abstractembeddedcomponents/cid/AbstractCompositeIdTest.java
trunk/Hibernate3/test/org/hibernate/test/abstractembeddedcomponents/propertyref/AbstractComponentPropertyRefTest.java
trunk/Hibernate3/test/org/hibernate/test/any/Address.java
trunk/Hibernate3/test/org/hibernate/test/any/AnyTypeTest.java
trunk/Hibernate3/test/org/hibernate/test/array/ArrayTest.java
trunk/Hibernate3/test/org/hibernate/test/ast/ASTIteratorTest.java
trunk/Hibernate3/test/org/hibernate/test/ast/ASTUtilTest.java
trunk/Hibernate3/test/org/hibernate/test/batch/BatchTest.java
trunk/Hibernate3/test/org/hibernate/test/batchfetch/BatchFetchTest.java
trunk/Hibernate3/test/org/hibernate/test/bidi/AuctionTest.java
trunk/Hibernate3/test/org/hibernate/test/bidi/AuctionTest2.java
trunk/Hibernate3/test/org/hibernate/test/bytecode/cglib/InvocationTargetExceptionTest.java
trunk/Hibernate3/test/org/hibernate/test/bytecode/cglib/ReflectionOptimizerTest.java
trunk/Hibernate3/test/org/hibernate/test/bytecode/javassist/InvocationTargetExceptionTest.java
trunk/Hibernate3/test/org/hibernate/test/bytecode/javassist/ReflectionOptimizerTest.java
trunk/Hibernate3/test/org/hibernate/test/cache/BaseCacheProviderTestCase.java
trunk/Hibernate3/test/org/hibernate/test/cache/ehcache/EhCacheTest.java
trunk/Hibernate3/test/org/hibernate/test/cache/treecache/optimistic/OptimisticTreeCacheTest.java
trunk/Hibernate3/test/org/hibernate/test/cache/treecache/pessimistic/TreeCacheTest.java
trunk/Hibernate3/test/org/hibernate/test/cascade/RefreshTest.java
trunk/Hibernate3/test/org/hibernate/test/cfg/CacheableFileTest.java
trunk/Hibernate3/test/org/hibernate/test/cid/CompositeIdTest.java
trunk/Hibernate3/test/org/hibernate/test/collection/CollectionSuite.java
trunk/Hibernate3/test/org/hibernate/test/collection/bag/PersistentBagTest.java
trunk/Hibernate3/test/org/hibernate/test/collection/idbag/PersistentIdBagTest.java
trunk/Hibernate3/test/org/hibernate/test/collection/list/PersistentListTest.java
trunk/Hibernate3/test/org/hibernate/test/collection/map/PersistentMapTest.java
trunk/Hibernate3/test/org/hibernate/test/collection/set/PersistentSetTest.java
trunk/Hibernate3/test/org/hibernate/test/component/ComponentTest.java
trunk/Hibernate3/test/org/hibernate/test/compositeelement/CompositeElementTest.java
trunk/Hibernate3/test/org/hibernate/test/connections/AggressiveReleaseTest.java
trunk/Hibernate3/test/org/hibernate/test/connections/BasicConnectionProviderTest.java
trunk/Hibernate3/test/org/hibernate/test/connections/ConnectionManagementTestCase.java
trunk/Hibernate3/test/org/hibernate/test/connections/ConnectionsSuite.java
trunk/Hibernate3/test/org/hibernate/test/connections/CurrentSessionConnectionTest.java
trunk/Hibernate3/test/org/hibernate/test/connections/SuppliedConnectionTest.java
trunk/Hibernate3/test/org/hibernate/test/connections/ThreadLocalCurrentSessionTest.java
trunk/Hibernate3/test/org/hibernate/test/criteria/CriteriaQueryTest.java
trunk/Hibernate3/test/org/hibernate/test/cuk/CompositePropertyRefTest.java
trunk/Hibernate3/test/org/hibernate/test/cuk/Person.hbm.xml
trunk/Hibernate3/test/org/hibernate/test/cut/CompositeUserTypeTest.java
trunk/Hibernate3/test/org/hibernate/test/deletetransient/DeleteTransientEntityTest.java
trunk/Hibernate3/test/org/hibernate/test/dialect/cache/SQLFunctionsInterSystemsTest.java
trunk/Hibernate3/test/org/hibernate/test/discriminator/DiscriminatorTest.java
trunk/Hibernate3/test/org/hibernate/test/dynamicentity/interceptor/InterceptorDynamicEntityTest.java
trunk/Hibernate3/test/org/hibernate/test/dynamicentity/tuplizer/TuplizerDynamicEntityTest.java
trunk/Hibernate3/test/org/hibernate/test/ecid/EmbeddedCompositeIdTest.java
trunk/Hibernate3/test/org/hibernate/test/exception/SQLExceptionConversionTest.java
trunk/Hibernate3/test/org/hibernate/test/extendshbm/ExtendsTest.java
trunk/Hibernate3/test/org/hibernate/test/extralazy/ExtraLazyTest.java
trunk/Hibernate3/test/org/hibernate/test/filter/DynamicFilterTest.java
trunk/Hibernate3/test/org/hibernate/test/formulajoin/FormulaJoinTest.java
trunk/Hibernate3/test/org/hibernate/test/generated/AbstractGeneratedPropertyTest.java
trunk/Hibernate3/test/org/hibernate/test/generated/TimestampGeneratedValuesWithCachingTest.java
trunk/Hibernate3/test/org/hibernate/test/generated/TriggerGeneratedValuesWithCachingTest.java
trunk/Hibernate3/test/org/hibernate/test/generated/TriggerGeneratedValuesWithoutCachingTest.java
trunk/Hibernate3/test/org/hibernate/test/generatedkeys/identity/IdentityGeneratedKeysTest.java
trunk/Hibernate3/test/org/hibernate/test/generatedkeys/select/SelectGeneratorTest.java
trunk/Hibernate3/test/org/hibernate/test/generatedkeys/seqidentity/SequenceIdentityTest.java
trunk/Hibernate3/test/org/hibernate/test/hql/ASTParserLoadingTest.java
trunk/Hibernate3/test/org/hibernate/test/hql/BulkManipulationTest.java
trunk/Hibernate3/test/org/hibernate/test/hql/ClassicTranslatorTest.java
trunk/Hibernate3/test/org/hibernate/test/hql/CriteriaHQLAlignmentTest.java
trunk/Hibernate3/test/org/hibernate/test/hql/EJBQLTest.java
trunk/Hibernate3/test/org/hibernate/test/hql/HQLSuite.java
trunk/Hibernate3/test/org/hibernate/test/hql/HQLTest.java
trunk/Hibernate3/test/org/hibernate/test/hql/HqlParserTest.java
trunk/Hibernate3/test/org/hibernate/test/hql/QueryTranslatorTestCase.java
trunk/Hibernate3/test/org/hibernate/test/hql/ScrollableCollectionFetchingTest.java
trunk/Hibernate3/test/org/hibernate/test/id/MultipleHiLoPerTableGeneratorTest.java
trunk/Hibernate3/test/org/hibernate/test/idbag/IdBagTest.java
trunk/Hibernate3/test/org/hibernate/test/idclass/IdClassTest.java
trunk/Hibernate3/test/org/hibernate/test/idprops/IdentifierPropertyReferencesTest.java
trunk/Hibernate3/test/org/hibernate/test/immutable/ImmutableTest.java
trunk/Hibernate3/test/org/hibernate/test/instrument/buildtime/InstrumentTest.java
trunk/Hibernate3/test/org/hibernate/test/instrument/cases/AbstractExecutable.java
trunk/Hibernate3/test/org/hibernate/test/instrument/domain/Documents.hbm.xml
trunk/Hibernate3/test/org/hibernate/test/instrument/runtime/AbstractTransformingClassLoaderInstrumentTestCase.java
trunk/Hibernate3/test/org/hibernate/test/instrument/runtime/CGLIBInstrumentationTest.java
trunk/Hibernate3/test/org/hibernate/test/instrument/runtime/JavassistInstrumentationTest.java
trunk/Hibernate3/test/org/hibernate/test/interceptor/InterceptorTest.java
trunk/Hibernate3/test/org/hibernate/test/interfaceproxy/InterfaceProxyTest.java
trunk/Hibernate3/test/org/hibernate/test/iterate/IterateTest.java
trunk/Hibernate3/test/org/hibernate/test/join/JoinTest.java
trunk/Hibernate3/test/org/hibernate/test/join/Person.hbm.xml
trunk/Hibernate3/test/org/hibernate/test/joinedsubclass/JoinedSubclassTest.java
trunk/Hibernate3/test/org/hibernate/test/joinfetch/JoinFetchTest.java
trunk/Hibernate3/test/org/hibernate/test/jpa/AbstractJPATest.java
trunk/Hibernate3/test/org/hibernate/test/jpa/JPAComplianceSuite.java
trunk/Hibernate3/test/org/hibernate/test/jpa/cascade/CascadeTest.java
trunk/Hibernate3/test/org/hibernate/test/jpa/fetch/FetchingTest.java
trunk/Hibernate3/test/org/hibernate/test/jpa/lock/RepeatableReadTest.java
trunk/Hibernate3/test/org/hibernate/test/jpa/proxy/JPAProxyTest.java
trunk/Hibernate3/test/org/hibernate/test/jpa/ql/JPAQLComplianceTest.java
trunk/Hibernate3/test/org/hibernate/test/jpa/ql/NativeQueryTest.java
trunk/Hibernate3/test/org/hibernate/test/jpa/removed/RemovedEntityTest.java
trunk/Hibernate3/test/org/hibernate/test/lazycache/InstrumentCacheTest.java
trunk/Hibernate3/test/org/hibernate/test/lazycache/InstrumentCacheTest2.java
trunk/Hibernate3/test/org/hibernate/test/lazyonetoone/LazyOneToOneTest.java
trunk/Hibernate3/test/org/hibernate/test/legacy/ABCProxyTest.java
trunk/Hibernate3/test/org/hibernate/test/legacy/ABCTest.java
trunk/Hibernate3/test/org/hibernate/test/legacy/CacheTest.java
trunk/Hibernate3/test/org/hibernate/test/legacy/ComponentNotNullTest.java
trunk/Hibernate3/test/org/hibernate/test/legacy/ConfigurationPerformanceTest.java
trunk/Hibernate3/test/org/hibernate/test/legacy/CustomSQLTest.java
trunk/Hibernate3/test/org/hibernate/test/legacy/FooBarTest.java
trunk/Hibernate3/test/org/hibernate/test/legacy/FumTest.java
trunk/Hibernate3/test/org/hibernate/test/legacy/IJ2Test.java
trunk/Hibernate3/test/org/hibernate/test/legacy/IJTest.java
trunk/Hibernate3/test/org/hibernate/test/legacy/LegacyTestCase.java
trunk/Hibernate3/test/org/hibernate/test/legacy/MapTest.java
trunk/Hibernate3/test/org/hibernate/test/legacy/MasterDetailTest.java
trunk/Hibernate3/test/org/hibernate/test/legacy/MultiTableTest.java
trunk/Hibernate3/test/org/hibernate/test/legacy/NonReflectiveBinderTest.java
trunk/Hibernate3/test/org/hibernate/test/legacy/OneToOneCacheTest.java
trunk/Hibernate3/test/org/hibernate/test/legacy/ParentChildTest.java
trunk/Hibernate3/test/org/hibernate/test/legacy/QueryByExampleTest.java
trunk/Hibernate3/test/org/hibernate/test/legacy/SQLFunctionsTest.java
trunk/Hibernate3/test/org/hibernate/test/legacy/SQLLoaderTest.java
trunk/Hibernate3/test/org/hibernate/test/legacy/StatisticsTest.java
trunk/Hibernate3/test/org/hibernate/test/lob/BlobTest.java
trunk/Hibernate3/test/org/hibernate/test/lob/ClobTest.java
trunk/Hibernate3/test/org/hibernate/test/lob/LobMappings.hbm.xml
trunk/Hibernate3/test/org/hibernate/test/lob/SerializableTypeTest.java
trunk/Hibernate3/test/org/hibernate/test/manytomany/ManyToManyTest.java
trunk/Hibernate3/test/org/hibernate/test/manytomany/ordered/OrderedManyToManyTest.java
trunk/Hibernate3/test/org/hibernate/test/map/MapIndexFormulaTest.java
trunk/Hibernate3/test/org/hibernate/test/mapcompelem/MapCompositeElementTest.java
trunk/Hibernate3/test/org/hibernate/test/mapelemformula/MapElementFormulaTest.java
trunk/Hibernate3/test/org/hibernate/test/mapping/PersistentClassVisitorTest.java
trunk/Hibernate3/test/org/hibernate/test/mapping/ValueVisitorTest.java
trunk/Hibernate3/test/org/hibernate/test/mappingexception/MappingExceptionTest.java
trunk/Hibernate3/test/org/hibernate/test/mixed/MixedTest.java
trunk/Hibernate3/test/org/hibernate/test/naturalid/NaturalIdTest.java
trunk/Hibernate3/test/org/hibernate/test/ondelete/OnDeleteTest.java
trunk/Hibernate3/test/org/hibernate/test/onetomany/OneToManyTest.java
trunk/Hibernate3/test/org/hibernate/test/ops/AbstractOperationTestCase.java
trunk/Hibernate3/test/org/hibernate/test/ops/CreateTest.java
trunk/Hibernate3/test/org/hibernate/test/ops/DeleteTest.java
trunk/Hibernate3/test/org/hibernate/test/ops/GetLoadTest.java
trunk/Hibernate3/test/org/hibernate/test/ops/MergeTest.java
trunk/Hibernate3/test/org/hibernate/test/ops/SaveOrUpdateTest.java
trunk/Hibernate3/test/org/hibernate/test/optlock/Document.hbm.xml
trunk/Hibernate3/test/org/hibernate/test/optlock/OptimisticLockTest.java
trunk/Hibernate3/test/org/hibernate/test/ordered/OrderByTest.java
trunk/Hibernate3/test/org/hibernate/test/orphan/OrphanIdRollbackTest.java
trunk/Hibernate3/test/org/hibernate/test/orphan/OrphanTest.java
trunk/Hibernate3/test/org/hibernate/test/orphan/PropertyRefTest.java
trunk/Hibernate3/test/org/hibernate/test/pagination/PaginationTest.java
trunk/Hibernate3/test/org/hibernate/test/pretty/SQLFormatterTest.java
trunk/Hibernate3/test/org/hibernate/test/propertyref/basic/PropertyRefTest.java
trunk/Hibernate3/test/org/hibernate/test/propertyref/component/complete/CompleteComponentPropertyRefTest.java
trunk/Hibernate3/test/org/hibernate/test/propertyref/component/partial/PartialComponentPropertyRefTest.java
trunk/Hibernate3/test/org/hibernate/test/propertyref/inheritence/discrim/SubclassPropertyRefTest.java
trunk/Hibernate3/test/org/hibernate/test/propertyref/inheritence/joined/JoinedSubclassPropertyRefTest.java
trunk/Hibernate3/test/org/hibernate/test/propertyref/inheritence/union/UnionSubclassPropertyRefTest.java
trunk/Hibernate3/test/org/hibernate/test/proxy/ProxyTest.java
trunk/Hibernate3/test/org/hibernate/test/querycache/QueryCacheTest.java
trunk/Hibernate3/test/org/hibernate/test/readonly/ReadOnlyTest.java
trunk/Hibernate3/test/org/hibernate/test/rowid/Point.hbm.xml
trunk/Hibernate3/test/org/hibernate/test/rowid/RowIdTest.java
trunk/Hibernate3/test/org/hibernate/test/schemaupdate/MigrationTest.java
trunk/Hibernate3/test/org/hibernate/test/sorted/SortTest.java
trunk/Hibernate3/test/org/hibernate/test/sql/DataDirectOracleSQLTest.java
trunk/Hibernate3/test/org/hibernate/test/sql/Db2SQLTest.java
trunk/Hibernate3/test/org/hibernate/test/sql/GeneralTest.java
trunk/Hibernate3/test/org/hibernate/test/sql/HandSQLTest.java
trunk/Hibernate3/test/org/hibernate/test/sql/MSSQLTest.java
trunk/Hibernate3/test/org/hibernate/test/sql/MySQLTest.java
trunk/Hibernate3/test/org/hibernate/test/sql/OracleSQLTest.java
trunk/Hibernate3/test/org/hibernate/test/sql/check/OracleCheckStyleTest.java
trunk/Hibernate3/test/org/hibernate/test/sql/check/ResultCheckStyleTest.java
trunk/Hibernate3/test/org/hibernate/test/stateless/StatelessSessionTest.java
trunk/Hibernate3/test/org/hibernate/test/stats/SessionStatsTest.java
trunk/Hibernate3/test/org/hibernate/test/stats/StatsTest.java
trunk/Hibernate3/test/org/hibernate/test/subclassfilter/DiscrimSubclassFilterTest.java
trunk/Hibernate3/test/org/hibernate/test/subclassfilter/JoinedSubclassFilterTest.java
trunk/Hibernate3/test/org/hibernate/test/subclassfilter/UnionSubclassFilterTest.java
trunk/Hibernate3/test/org/hibernate/test/subselect/SubselectTest.java
trunk/Hibernate3/test/org/hibernate/test/subselectfetch/SubselectFetchTest.java
trunk/Hibernate3/test/org/hibernate/test/ternary/TernaryTest.java
trunk/Hibernate3/test/org/hibernate/test/timestamp/TimestampTest.java
trunk/Hibernate3/test/org/hibernate/test/tm/CMTTest.java
trunk/Hibernate3/test/org/hibernate/test/tool/TestSchemaTools.java
trunk/Hibernate3/test/org/hibernate/test/typedmanytoone/TypedManyToOneTest.java
trunk/Hibernate3/test/org/hibernate/test/typedonetoone/TypedOneToOneTest.java
trunk/Hibernate3/test/org/hibernate/test/typeparameters/TypeParameterTest.java
trunk/Hibernate3/test/org/hibernate/test/unconstrained/UnconstrainedTest.java
trunk/Hibernate3/test/org/hibernate/test/unidir/BackrefTest.java
trunk/Hibernate3/test/org/hibernate/test/unionsubclass/UnionSubclassTest.java
trunk/Hibernate3/test/org/hibernate/test/unionsubclass2/UnionSubclassTest.java
trunk/Hibernate3/test/org/hibernate/test/usercollection/UserCollectionTypeTest.java
trunk/Hibernate3/test/org/hibernate/test/util/PropertiesHelperTest.java
trunk/Hibernate3/test/org/hibernate/test/util/StringHelperTest.java
trunk/Hibernate3/test/org/hibernate/test/util/dtd/EntityResolverTest.java
trunk/Hibernate3/test/org/hibernate/test/version/VersionTest.java
trunk/Hibernate3/test/org/hibernate/test/version/db/DbVersionTest.java
trunk/Hibernate3/test/org/hibernate/test/version/sybase/SybaseTimestampVersioningTest.java
trunk/Hibernate3/test/org/hibernate/test/where/WhereTest.java
Log:
test suite reorg
Added: trunk/Hibernate3/test/org/hibernate/junit/AbstractClassLoaderIsolatedTestCase.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/junit/AbstractClassLoaderIsolatedTestCase.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/junit/AbstractClassLoaderIsolatedTestCase.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,34 @@
+package org.hibernate.junit;
+
+/**
+ * A specialized TestCase for running tests in an isolated class-loader
+ *
+ * @author Steve Ebersole
+ */
+public abstract class AbstractClassLoaderIsolatedTestCase extends UnitTestCase {
+ private ClassLoader parentLoader;
+ private ClassLoader isolatedLoader;
+
+ public AbstractClassLoaderIsolatedTestCase(String string) {
+ super( string );
+ }
+
+ protected void setUp() throws Exception {
+ parentLoader = Thread.currentThread().getContextClassLoader();
+ isolatedLoader = buildIsolatedClassLoader( parentLoader );
+ Thread.currentThread().setContextClassLoader( isolatedLoader );
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ Thread.currentThread().setContextClassLoader( parentLoader );
+ releaseIsolatedClassLoader( isolatedLoader );
+ parentLoader = null;
+ isolatedLoader = null;
+ }
+
+ protected abstract ClassLoader buildIsolatedClassLoader(ClassLoader parent);
+
+ protected abstract void releaseIsolatedClassLoader(ClassLoader isolatedLoader);
+}
Added: trunk/Hibernate3/test/org/hibernate/junit/SkipLog.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/junit/SkipLog.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/junit/SkipLog.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,13 @@
+package org.hibernate.junit;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Well-known-location lookup for the test-skip log...
+ *
+ * @author Steve Ebersole
+ */
+public class SkipLog {
+ public static final Log LOG = LogFactory.getLog( "org.hibernate.test.SKIPPED" );
+}
Added: trunk/Hibernate3/test/org/hibernate/junit/TestSuiteVisitor.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/junit/TestSuiteVisitor.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/junit/TestSuiteVisitor.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,42 @@
+package org.hibernate.junit;
+
+import java.util.Enumeration;
+
+import junit.framework.TestSuite;
+import junit.framework.Test;
+
+/**
+ * Handles walking a TestSuite hierarchy for recognition of individual tests.
+ *
+ * @author Steve Ebersole
+ */
+public class TestSuiteVisitor {
+
+ private final TestSuiteVisitor.Handler handler;
+
+ public TestSuiteVisitor(TestSuiteVisitor.Handler handler) {
+ this.handler = handler;
+ }
+
+ public void visit(TestSuite testSuite) {
+ handler.startingTestSuite( testSuite );
+ Enumeration tests = testSuite.tests();
+ while ( tests.hasMoreElements() ) {
+ Test test = ( Test ) tests.nextElement();
+ if ( test instanceof TestSuite ) {
+ visit( ( TestSuite ) test );
+ }
+ else {
+ handler.handleTestCase( test );
+ }
+ }
+ handler.completedTestSuite( testSuite );
+ }
+
+ public static interface Handler {
+ public void handleTestCase(Test test);
+ public void startingTestSuite(TestSuite suite);
+ public void completedTestSuite(TestSuite suite);
+ }
+
+}
Added: trunk/Hibernate3/test/org/hibernate/junit/UnitTestCase.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/junit/UnitTestCase.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/junit/UnitTestCase.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,84 @@
+package org.hibernate.junit;
+
+import java.util.Iterator;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import junit.framework.AssertionFailedError;
+
+
+/**
+ * A basic JUnit {@link junit.framework.TestCase} subclass for
+ * adding some Hibernate specific behavior and functionality.
+ *
+ * @author Steve Ebersole
+ */
+public abstract class UnitTestCase extends junit.framework.TestCase {
+
+ private static final Log log = LogFactory.getLog( UnitTestCase.class );
+
+ public UnitTestCase(String string) {
+ super( string );
+ }
+
+ /**
+ * runBare overridden in order to apply FailureExpected validations
+ * as well as start/complete logging
+ *
+ * @throws Throwable
+ */
+ public void runBare() throws Throwable {
+ final boolean doValidate = getName().endsWith( "FailureExpected" ) && Boolean.getBoolean( "hibernate.test.validatefailureexpected" );
+ try {
+ log.info( "Starting test [" + fullTestName() + "]" );
+ super.runBare();
+ if ( doValidate ) {
+ fail( "Test marked as FailureExpected, but did not fail!" );
+ }
+ }
+ catch( Throwable t ) {
+ if ( doValidate ) {
+ skipExpectedFailure( t );
+ }
+ else {
+ throw t;
+ }
+ }
+ finally {
+ log.info( "Completed test [" + fullTestName() + "]" );
+ }
+ }
+
+ protected void skipExpectedFailure(Throwable error) {
+ reportSkip( "ignoring *FailuredExpected methods", "Failed with: " + error.toString() );
+ }
+
+ // additional assertions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ public static void assertElementTypeAssignability(java.util.Collection collection, Class clazz) throws AssertionFailedError {
+ Iterator itr = collection.iterator();
+ while ( itr.hasNext() ) {
+ assertClassAssignability( itr.next().getClass(), clazz );
+ }
+ }
+
+ public static void assertClassAssignability(Class source, Class target) throws AssertionFailedError {
+ if ( !target.isAssignableFrom( source ) ) {
+ throw new AssertionFailedError(
+ "Classes were not assignment-compatible : source<" + source.getName() +
+ "> target<" + target.getName() + ">"
+ );
+ }
+ }
+
+
+ // test skipping ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ public String fullTestName() {
+ return this.getClass().getName() + "#" + this.getName();
+ }
+
+ protected void reportSkip(String reason, String testDescription) {
+ SkipLog.LOG.warn( "*** skipping [" + fullTestName() + "] - " + testDescription + " : " + reason, new Exception() );
+ }
+}
Added: trunk/Hibernate3/test/org/hibernate/junit/functional/DatabaseSpecificFunctionalTestCase.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/junit/functional/DatabaseSpecificFunctionalTestCase.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/junit/functional/DatabaseSpecificFunctionalTestCase.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,27 @@
+package org.hibernate.junit.functional;
+
+import org.hibernate.junit.SkipLog;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public abstract class DatabaseSpecificFunctionalTestCase extends FunctionalTestCase {
+ public DatabaseSpecificFunctionalTestCase(String string) {
+ super( string );
+ }
+
+ protected void runTest() throws Throwable {
+ // Note: this protection comes into play when running
+ // tests individually. The suite as a whole is already
+ // "protected" by the fact that these tests are actually
+ // filtered out of the suite
+ if ( appliesTo( getDialect() ) ) {
+ super.runTest();
+ }
+ else {
+ SkipLog.LOG.warn( "skipping database-specific test [" + fullTestName() + "] for dialect [" + getDialect().getClass().getName() + "]" );
+ }
+ }
+}
Added: trunk/Hibernate3/test/org/hibernate/junit/functional/ExecutionEnvironment.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/junit/functional/ExecutionEnvironment.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/junit/functional/ExecutionEnvironment.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,165 @@
+package org.hibernate.junit.functional;
+
+import java.util.Iterator;
+import java.sql.Blob;
+import java.sql.Clob;
+
+import org.hibernate.dialect.Dialect;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
+import org.hibernate.cfg.Mappings;
+import org.hibernate.SessionFactory;
+import org.hibernate.mapping.PersistentClass;
+import org.hibernate.mapping.Property;
+import org.hibernate.mapping.SimpleValue;
+import org.hibernate.mapping.Collection;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class ExecutionEnvironment {
+
+ public static final Dialect DIALECT = Dialect.getDialect();
+
+ private final ExecutionEnvironment.Settings settings;
+
+ private Configuration configuration;
+ private SessionFactory sessionFactory;
+ private boolean allowRebuild;
+
+ public ExecutionEnvironment(ExecutionEnvironment.Settings settings) {
+ this.settings = settings;
+ }
+
+ public boolean isAllowRebuild() {
+ return allowRebuild;
+ }
+
+ public void setAllowRebuild(boolean allowRebuild) {
+ this.allowRebuild = allowRebuild;
+ }
+
+ public Dialect getDialect() {
+ return DIALECT;
+ }
+
+ public Configuration getConfiguration() {
+ return configuration;
+ }
+
+ public SessionFactory getSessionFactory() {
+ return sessionFactory;
+ }
+
+ public void initialize() {
+ if ( sessionFactory != null ) {
+ throw new IllegalStateException( "attempt to initialize already initialized ExecutionEnvironment" );
+ }
+ if ( ! settings.appliesTo( getDialect() ) ) {
+ return;
+ }
+
+ Configuration configuration = new Configuration();
+ configuration.setProperty( Environment.CACHE_PROVIDER, "org.hibernate.cache.HashtableCacheProvider" );
+
+ settings.configure( configuration );
+
+ applyMappings( configuration );
+ applyCacheSettings( configuration );
+
+
+ if ( settings.createSchema() ) {
+ configuration.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
+ }
+
+ // make sure we use the same dialect...
+ configuration.setProperty( Environment.DIALECT, getDialect().getClass().getName() );
+
+ configuration.buildMappings();
+ settings.afterConfigurationBuilt( configuration.createMappings(), getDialect() );
+
+ SessionFactory sessionFactory = configuration.buildSessionFactory();
+ this.configuration = configuration;
+ this.sessionFactory = sessionFactory;
+
+ settings.afterSessionFactoryBuilt();
+ }
+
+ private void applyMappings(Configuration configuration) {
+ String[] mappings = settings.getMappings();
+ for ( int i = 0; i < mappings.length; i++ ) {
+ configuration.addResource( settings.getBaseForMappings() + mappings[i], ExecutionEnvironment.class.getClassLoader() );
+ }
+ }
+
+ private void applyCacheSettings(Configuration configuration) {
+ if ( settings.getCacheConcurrencyStrategy() != null ) {
+ Iterator iter = configuration.getClassMappings();
+ while ( iter.hasNext() ) {
+ PersistentClass clazz = (PersistentClass) iter.next();
+ Iterator props = clazz.getPropertyClosureIterator();
+ boolean hasLob = false;
+ while ( props.hasNext() ) {
+ Property prop = (Property) props.next();
+ if ( prop.getValue().isSimpleValue() ) {
+ String type = ( ( SimpleValue ) prop.getValue() ).getTypeName();
+ if ( "blob".equals(type) || "clob".equals(type) ) {
+ hasLob = true;
+ }
+ if ( Blob.class.getName().equals(type) || Clob.class.getName().equals(type) ) {
+ hasLob = true;
+ }
+ }
+ }
+ if ( !hasLob && !clazz.isInherited() && settings.overrideCacheStrategy() ) {
+ configuration.setCacheConcurrencyStrategy( clazz.getEntityName(), settings.getCacheConcurrencyStrategy() );
+ }
+ }
+ iter = configuration.getCollectionMappings();
+ while ( iter.hasNext() ) {
+ Collection coll = (Collection) iter.next();
+ configuration.setCollectionCacheConcurrencyStrategy( coll.getRole(), settings.getCacheConcurrencyStrategy() );
+ }
+ }
+ }
+
+ protected void afterSessionFactoryBuilt() {
+ // for subclasses to override in order to perform extra "stuff" only
+ // when SF (re)built...
+ }
+
+ public void rebuild() {
+ if ( !allowRebuild ) {
+ return;
+ }
+ if ( sessionFactory != null ) {
+ sessionFactory.close();
+ sessionFactory = null;
+ }
+ sessionFactory = configuration.buildSessionFactory();
+ afterSessionFactoryBuilt();
+ }
+
+ public void complete() {
+ if ( sessionFactory != null ) {
+ sessionFactory.close();
+ sessionFactory = null;
+ }
+ configuration = null;
+ }
+
+ public static interface Settings {
+ public String[] getMappings();
+ public String getBaseForMappings();
+ public boolean createSchema();
+ public boolean recreateSchemaAfterFailure();
+ public void configure(Configuration cfg);
+ public boolean overrideCacheStrategy();
+ public String getCacheConcurrencyStrategy();
+ public void afterSessionFactoryBuilt();
+ public void afterConfigurationBuilt(Mappings mappings, Dialect dialect);
+ public boolean appliesTo(Dialect dialect);
+ }
+}
Added: trunk/Hibernate3/test/org/hibernate/junit/functional/FunctionalTestCase.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/junit/functional/FunctionalTestCase.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/junit/functional/FunctionalTestCase.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,504 @@
+package org.hibernate.junit.functional;
+
+import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Mappings;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.dialect.DB2Dialect;
+import org.hibernate.dialect.DerbyDialect;
+import org.hibernate.SessionFactory;
+import org.hibernate.HibernateException;
+import org.hibernate.Interceptor;
+import org.hibernate.Session;
+import org.hibernate.junit.UnitTestCase;
+import org.hibernate.engine.SessionFactoryImplementor;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Most of the Hibernate test suite in fact is a series of functional tests, not
+ * unit tests. Here is a base class for these functional tests.
+ *
+ * @author Steve Ebersole
+ */
+public abstract class FunctionalTestCase extends UnitTestCase implements ExecutionEnvironment.Settings {
+
+ private static final Log log = LogFactory.getLog( FunctionalTestCase.class );
+
+ private ExecutionEnvironment environment;
+ private boolean isEnvironmentLocallyManaged;
+
+ private org.hibernate.classic.Session session;
+
+ public FunctionalTestCase(String string) {
+ super( string );
+ }
+
+ public ExecutionEnvironment getEnvironment() {
+ return environment;
+ }
+
+ public void setEnvironment(ExecutionEnvironment environment) {
+ this.environment = environment;
+ }
+
+ protected void prepareTest() throws Exception {
+ }
+
+ protected void cleanupTest() throws Exception {
+ }
+
+ // JUnit hooks ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ /**
+ * Override {@link junit.framework.TestCase#setUp()} to check if we need
+ * to build a locally managed execution environment.
+ *
+ * @throws Exception
+ */
+ protected final void setUp() throws Exception {
+ if ( environment == null ) {
+ log.info( "Building locally managed execution env" );
+ isEnvironmentLocallyManaged = true;
+ environment = new ExecutionEnvironment( this );
+ environment.initialize();
+ }
+ prepareTest();
+ }
+
+ /**
+ * Override {@link junit.framework.TestCase#tearDown()} to tear down
+ * the execution environment if it is locally managed.
+ *
+ * @throws Exception
+ */
+ protected final void tearDown() throws Exception {
+ cleanupTest();
+ if ( isEnvironmentLocallyManaged ) {
+ log.info( "Destroying locally managed execution env" );
+ environment.complete();
+ environment = null;
+ }
+ }
+
+ /**
+ * runTest is overridden in order to apply session closure assertions.
+ *
+ * @throws Throwable
+ */
+ protected void runTest() throws Throwable {
+ final boolean stats = sfi().getStatistics().isStatisticsEnabled();
+ try {
+ if ( stats ) {
+ sfi().getStatistics().clear();
+ }
+
+ super.runTest();
+
+ if ( stats ) {
+ sfi().getStatistics().logSummary();
+ }
+
+ if ( session != null && session.isOpen() ) {
+ if ( session.isConnected() ) {
+ session.connection().rollback();
+ }
+ session.close();
+ session = null;
+ fail( "unclosed session" );
+ }
+ else {
+ session = null;
+ }
+ assertAllDataRemoved();
+ }
+ catch ( Throwable e ) {
+ try {
+ if ( session != null && session.isOpen() ) {
+ if ( session.isConnected() ) {
+ session.connection().rollback();
+ }
+ session.close();
+ }
+ }
+ catch ( Exception ignore ) {
+ }
+ try {
+ if ( recreateSchemaAfterFailure() && environment != null ) {
+ environment.rebuild();
+ }
+ }
+ catch ( Exception ignore ) {
+ }
+ throw e;
+ }
+ }
+
+ protected void assertAllDataRemoved() {
+ if ( !createSchema() ) {
+ return; // no tables were created...
+ }
+ if ( !Boolean.getBoolean( "hibernate.test.validateDataCleanup" ) ) {
+ return;
+ }
+
+ Session tmpSession = getSessions().openSession();
+ try {
+ List list = tmpSession.createQuery( "select o from java.lang.Object o" ).list();
+
+ Map items = new HashMap();
+ if ( !list.isEmpty() ) {
+ for ( Iterator iter = list.iterator(); iter.hasNext(); ) {
+ Object element = iter.next();
+ Integer l = ( Integer ) items.get( tmpSession.getEntityName( element ) );
+ if ( l == null ) {
+ l = new Integer( 0 );
+ }
+ l = new Integer( l.intValue() + 1 );
+ items.put( tmpSession.getEntityName( element ), l );
+ System.out.println( "Data left: " + element );
+ }
+ fail( "Data is left in the database: " + items.toString() );
+ }
+ }
+ finally {
+ try {
+ tmpSession.close();
+ }
+ catch( Throwable t ) {
+ // intentionally empty
+ }
+ }
+ }
+
+ protected void skipExpectedFailure(Throwable error) {
+ super.skipExpectedFailure( error );
+ try {
+ if ( recreateSchemaAfterFailure() && environment != null ) {
+ environment.rebuild();
+ }
+ }
+ catch ( Exception ignore ) {
+ }
+ }
+
+ // ExecutionEnvironment.Settings implementation ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ public String getBaseForMappings() {
+ return "org/hibernate/test/";
+ }
+
+ public boolean createSchema() {
+ return true;
+ }
+
+ public boolean recreateSchemaAfterFailure() {
+ return true;
+ }
+
+ public void configure(Configuration cfg) {
+ }
+
+ public boolean overrideCacheStrategy() {
+ return true;
+ }
+
+ public String getCacheConcurrencyStrategy() {
+ return "nonstrict-read-write";
+ }
+
+ public void afterSessionFactoryBuilt() {
+ }
+
+ public void afterConfigurationBuilt(Mappings mappings, Dialect dialect) {
+ }
+
+ /**
+ * Intended to indicate that this test class as a whole is intended for
+ * a dialect or series of dialects. Skips here (appliesTo = false) therefore
+ * simply indicate that the given tests target a particular feature of the
+ * checked database and none of the tests on this class should be run for the
+ * checked dialect.
+ *
+ * @param dialect The dialect to be checked.
+ * @return False if the test class as a whole is specifically targetting
+ * a dialect (or series of dialects) other than the indicated dialect
+ * and the test should therefore be skipped in its entirety;
+ * true otherwise.
+ */
+ public boolean appliesTo(Dialect dialect) {
+ return true;
+ }
+
+
+ // methods for subclasses to access environment ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ /**
+ * Get the factory for this test environment.
+ *
+ * @return The factory.
+ */
+ protected SessionFactory getSessions() {
+ return environment.getSessionFactory();
+ }
+
+ /**
+ * Get the factory for this test environment, casted to {@link org.hibernate.engine.SessionFactoryImplementor}.
+ * <p/>
+ * Shorthand for ( {@link org.hibernate.engine.SessionFactoryImplementor} ) {@link #getSessions()}...
+ *
+ * @return The factory
+ */
+ protected SessionFactoryImplementor sfi() {
+ return ( SessionFactoryImplementor ) getSessions();
+ }
+
+ protected Dialect getDialect() {
+ return ExecutionEnvironment.DIALECT;
+ }
+
+ protected Configuration getCfg() {
+ return environment.getConfiguration();
+ }
+
+ public org.hibernate.classic.Session openSession() throws HibernateException {
+ session = getSessions().openSession();
+ return session;
+ }
+
+ public org.hibernate.classic.Session openSession(Interceptor interceptor) throws HibernateException {
+ session = getSessions().openSession(interceptor);
+ return session;
+ }
+
+
+
+
+ /**
+ * Is connection at least read committed?
+ * <p/>
+ * Not, that this skip check relies on the JDBC driver reporting
+ * the true isolation level correctly. HSQLDB, for example, will
+ * report whatever you specify as the isolation
+ * (Connection.setTransationIsolation()), even though it only supports
+ * read-uncommitted.
+ *
+ * @param scenario text description of the scenario being tested.
+ * @return true if read-committed isolation is maintained.
+ */
+ protected boolean readCommittedIsolationMaintained(String scenario) {
+ int isolation = java.sql.Connection.TRANSACTION_READ_UNCOMMITTED;
+ Session testSession = null;
+ try {
+ testSession = openSession();
+ isolation = testSession.connection().getTransactionIsolation();
+ }
+ catch( Throwable ignore ) {
+ }
+ finally {
+ if ( testSession != null ) {
+ try {
+ testSession.close();
+ }
+ catch( Throwable ignore ) {
+ }
+ }
+ }
+ if ( isolation < java.sql.Connection.TRANSACTION_READ_COMMITTED ) {
+ reportSkip( "environment does not support at least read committed isolation", scenario );
+ return false;
+ }
+ else {
+ return true;
+ }
+ }
+
+ /**
+ * Does the db/dialect support using a column's physical name in the order-by clause
+ * even after it has been aliased in the select clause. This is not actually
+ * required by the SQL spec, although virtually ever DB in the world supports this
+ * (the most glaring omission here being IBM-variant DBs ala DB2 and Derby).
+ *
+ * @param testDescription description of the scenario being tested.
+ * @return true if is allowed
+ */
+ protected boolean allowsPhysicalColumnNameInOrderby(String testDescription) {
+ if ( DB2Dialect.class.isInstance( getDialect() ) ) {
+ // https://issues.apache.org/jira/browse/DERBY-1624
+ reportSkip( "Dialect does not support physical column name in order-by clause after it is aliased", testDescription );
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Does the db/dialect support using a column's physical name in the having clause
+ * even after it has been aliased in the select/group-by clause. This is not actually
+ * required by the SQL spec, although virtually ever DB in the world supports this.
+ *
+ * @param testDescription description of the scenario being tested.
+ * @return true if is allowed
+ */
+ protected boolean allowsPhysicalColumnNameInHaving(String testDescription) {
+ // I only *know* of this being a limitation on Derby, although I highly suspect
+ // it is a limitation on any IBM/DB2 variant
+ if ( DerbyDialect.class.isInstance( getDialect() ) ) {
+ // https://issues.apache.org/jira/browse/DERBY-1624
+ reportSkip( "Dialect does not support physical column name in having clause after it is aliased", testDescription );
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Does the db/dialect support empty lists in the IN operator?
+ * <p/>
+ * For example, is "... a.b IN () ..." supported?
+ *
+ * @param testDescription description of the scenario being tested.
+ * @return true if is allowed
+ */
+ protected boolean dialectSupportsEmptyInList(String testDescription) {
+ if ( ! getDialect().supportsEmptyInList() ) {
+ reportSkip( "Dialect does not support SQL empty in list : x in ()", testDescription );
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Is the db/dialect sensitive in terms of string comparisons?
+ * @param testDescription description of the scenario being tested.
+ * @return true if sensitive
+ */
+ protected boolean dialectIsCaseSensitive(String testDescription) {
+ if ( getDialect().areStringComparisonsCaseInsensitive() ) {
+ reportSkip( "Dialect is case sensitive. ", testDescription );
+ return true;
+ }
+ return false;
+ }
+
+ protected boolean supportsRowValueConstructorSyntaxInInList() {
+ if ( ! getDialect().supportsRowValueConstructorSyntaxInInList() ) {
+ reportSkip( "Dialect does not support 'tuple' syntax as part of an IN value list", "query support" );
+ return false;
+ }
+ return true;
+ }
+
+ protected boolean supportsResultSetPositionQueryMethodsOnForwardOnlyCursor() {
+ if ( ! getDialect().supportsResultSetPositionQueryMethodsOnForwardOnlyCursor() ) {
+ reportSkip( "Driver does not support 'position query' methods on forward-only cursors", "query support" );
+ return false;
+ }
+ return true;
+ }
+
+ protected boolean supportsCircularCascadeDelete() {
+ if ( ! getDialect().supportsCircularCascadeDeleteConstraints() ) {
+ reportSkip( "db/dialect does not support 'circular' cascade delete constraints", "cascade delete constraint support" );
+ return false;
+ }
+ return true;
+ }
+
+ protected boolean supportsSubselectOnLeftSideIn() {
+ if ( ! getDialect().supportsSubselectAsInPredicateLHS() ) {
+ reportSkip( "Database does not support (<subselect>) in ( ... ) ", "query support" );
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Expected LOB usage pattern is such that I can perform an insert
+ * via prepared statement with a parameter binding for a LOB value
+ * without crazy casting to JDBC driver implementation-specific classes...
+ * <p/>
+ * Part of the trickiness here is the fact that this is largely
+ * driver dependent. For Oracle, which is notoriously bad with
+ * LOB support in their drivers actually does a pretty good job with
+ * LOB support as of the 10.2.x versions of their drivers...
+ *
+ * @return True if expected usage pattern is support; false otherwise.
+ */
+ protected boolean supportsExpectedLobUsagePattern() {
+ if ( ! getDialect().supportsExpectedLobUsagePattern() ) {
+ reportSkip( "database/driver does not support expected LOB usage pattern", "LOB support" );
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Does the current dialect support propogating changes to LOB
+ * values back to the database? Talking about mutating the
+ * underlying value as opposed to supplying a new
+ * LOB instance...
+ *
+ * @return True if the changes are propogated back to the
+ * database; false otherwise.
+ */
+ protected boolean supportsLobValueChangePropogation() {
+ if ( ! getDialect().supportsLobValueChangePropogation() ) {
+ reportSkip( "database/driver does not support propogating LOB value change back to database", "LOB support" );
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Is it supported to materialize a LOB locator outside the transaction in
+ * which it was created?
+ * <p/>
+ * Again, part of the trickiness here is the fact that this is largely
+ * driver dependent.
+ * <p/>
+ * NOTE: all database I have tested which {@link #supportsExpectedLobUsagePattern()}
+ * also support the ability to materialize a LOB outside the owning transaction...
+ *
+ * @return True if unbounded materialization is supported; false otherwise.
+ */
+ protected boolean supportsUnboundedLobLocatorMaterialization() {
+ if ( !getDialect().supportsUnboundedLobLocatorMaterialization() ) {
+ reportSkip( "database/driver does not support materializing a LOB locator outside the 'owning' transaction", "LOB support" );
+ return false;
+ }
+ return true;
+ }
+
+ protected boolean supportsSubqueryOnMutatingTable() {
+ if ( !getDialect().supportsSubqueryOnMutatingTable() ) {
+ reportSkip( "database/driver does not support referencing mutating table in subquery", "bulk DML support" );
+ return false;
+ }
+ return true;
+ }
+
+ protected boolean dialectIs(Class dialectClass) {
+ return dialectClass.isInstance( getDialect() );
+ }
+
+ protected boolean dialectIsOneOf(Class[] dialectClasses) {
+ for ( int i = 0; i < dialectClasses.length; i++ ) {
+ if ( dialectClasses[i].isInstance( getDialect() ) ) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ protected boolean dialectIsNot(Class dialectClass) {
+ return ! dialectIs( dialectClass );
+ }
+
+ protected boolean dialectIsNot(Class[] dialectClasses) {
+ return ! dialectIsOneOf( dialectClasses );
+ }
+}
Added: trunk/Hibernate3/test/org/hibernate/junit/functional/FunctionalTestClassTestSuite.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/junit/functional/FunctionalTestClassTestSuite.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/junit/functional/FunctionalTestClassTestSuite.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,117 @@
+package org.hibernate.junit.functional;
+
+import junit.framework.TestSuite;
+import junit.framework.Test;
+import junit.framework.TestResult;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * A specialized {@link junit.framework.TestSuite} implementation intended
+ * for use as an aggregate for a single test class specifically for the purpose
+ * of maintaing a single {@link org.hibernate.SessionFactory} for executings all
+ * tests defined as part of the given functional test class.
+ *
+ * @author Steve Ebersole
+ */
+public class FunctionalTestClassTestSuite extends TestSuite {
+
+ private static final Log log = LogFactory.getLog( FunctionalTestClassTestSuite.class );
+
+ private ExecutionEnvironment.Settings settings;
+ private ExecutionEnvironment environment;
+ private Throwable environmentSetupError;
+ private int testCount;
+ private int testPosition;
+
+ public FunctionalTestClassTestSuite(Class testClass, String name) {
+ super( testClass, name );
+ }
+
+ public FunctionalTestClassTestSuite(Class testClass) {
+ this( testClass, testClass.getName() );
+ }
+
+ /**
+ * Constructor form used during {@link org.hibernate.test.AllTests} filtering...
+ *
+ * @param name The name.
+ */
+ private FunctionalTestClassTestSuite(String name) {
+ super( name );
+ }
+
+ public void addTest(Test test) {
+ if ( settings == null ) {
+ settings = ( ExecutionEnvironment.Settings ) test;
+ }
+ // todo : we could also centralize the skipping of "database specific" tests here
+ // instead of duplicating this notion in AllTests and DatabaseSpecificFunctionalTestCase.
+ testCount++;
+ super.addTest( test );
+ }
+
+ public void run(TestResult testResult) {
+ if ( testCount == 0 ) {
+ // might be zero if database-specific...
+ return;
+ }
+ try {
+ log.info( "Starting test-suite [" + getName() + "]" );
+ try {
+ setUp();
+ }
+ catch( Throwable t ) {
+ environmentSetupError = t;
+ }
+ testPosition = 0;
+ super.run( testResult );
+ }
+ finally {
+ try {
+ tearDown();
+ }
+ catch( Throwable ignore ) {
+ }
+ log.info( "Completed test-suite [" + getName() + "]" );
+ }
+ }
+
+ public void runTest(Test test, TestResult testResult) {
+ if ( environmentSetupError != null ) {
+ testResult.startTest( test );
+ testResult.addError( test, environmentSetupError );
+ testResult.endTest( test );
+ return;
+ }
+ FunctionalTestCase functionalTest = ( ( FunctionalTestCase ) test );
+ try {
+ if ( ++testPosition < testCount ) {
+ // disallow rebuilding the schema because this is the last test
+ // in this suite, thus it is about to get dropped immediately
+ // afterwards anyway...
+ environment.setAllowRebuild( true );
+ }
+ functionalTest.setEnvironment( environment );
+ super.runTest( functionalTest, testResult );
+ }
+ finally {
+ functionalTest.setEnvironment( null );
+ }
+ }
+
+ protected void setUp() {
+ log.info( "Building aggregated execution environment" );
+ environment = new ExecutionEnvironment( settings );
+ environment.initialize();
+ }
+
+ protected void tearDown() {
+ if ( environment != null ) {
+ log.info( "Destroying aggregated execution environment" );
+ environment.complete();
+ this.environment = null;
+ }
+ }
+}
Deleted: trunk/Hibernate3/test/org/hibernate/test/AbstractClassLoaderIsolatedTestCase.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/AbstractClassLoaderIsolatedTestCase.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/AbstractClassLoaderIsolatedTestCase.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,32 +0,0 @@
-package org.hibernate.test;
-
-import junit.framework.TestCase;
-
-/**
- * A specialized TestCase for running tests in an isolated class-loader
- *
- * @author Steve Ebersole
- */
-public abstract class AbstractClassLoaderIsolatedTestCase extends TestCase {
- private ClassLoader parentLoader;
- private ClassLoader isolatedLoader;
-
- protected void setUp() throws Exception {
- parentLoader = Thread.currentThread().getContextClassLoader();
- isolatedLoader = buildIsolatedClassLoader( parentLoader );
- Thread.currentThread().setContextClassLoader( isolatedLoader );
- super.setUp();
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- Thread.currentThread().setContextClassLoader( parentLoader );
- releaseIsolatedClassLoader( isolatedLoader );
- parentLoader = null;
- isolatedLoader = null;
- }
-
- protected abstract ClassLoader buildIsolatedClassLoader(ClassLoader parent);
-
- protected abstract void releaseIsolatedClassLoader(ClassLoader isolatedLoader);
-}
Modified: trunk/Hibernate3/test/org/hibernate/test/AllTests.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/AllTests.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/AllTests.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,11 +1,14 @@
//$Id$
package org.hibernate.test;
+import java.lang.reflect.Constructor;
+
import junit.framework.Test;
import junit.framework.TestSuite;
import junit.textui.TestRunner;
import org.hibernate.dialect.Dialect;
+import org.hibernate.junit.TestSuiteVisitor;
import org.hibernate.test.abstractembeddedcomponents.cid.AbstractCompositeIdTest;
import org.hibernate.test.abstractembeddedcomponents.propertyref.AbstractComponentPropertyRefTest;
import org.hibernate.test.any.AnyTypeTest;
@@ -26,25 +29,19 @@
import org.hibernate.test.criteria.CriteriaQueryTest;
import org.hibernate.test.cuk.CompositePropertyRefTest;
import org.hibernate.test.cut.CompositeUserTypeTest;
+import org.hibernate.test.deletetransient.DeleteTransientEntityTest;
import org.hibernate.test.dialect.cache.SQLFunctionsInterSystemsTest;
import org.hibernate.test.discriminator.DiscriminatorTest;
-import org.hibernate.test.dom4j.Dom4jAccessorTest;
-import org.hibernate.test.dom4j.Dom4jManyToOneTest;
-import org.hibernate.test.dom4j.Dom4jTest;
-import org.hibernate.test.dynamic.DynamicClassTest;
import org.hibernate.test.dynamicentity.interceptor.InterceptorDynamicEntityTest;
import org.hibernate.test.dynamicentity.tuplizer.TuplizerDynamicEntityTest;
import org.hibernate.test.ecid.EmbeddedCompositeIdTest;
-import org.hibernate.test.entity.MultiRepresentationTest;
+import org.hibernate.test.entitymode.EntityModeSuite;
import org.hibernate.test.exception.SQLExceptionConversionTest;
import org.hibernate.test.extralazy.ExtraLazyTest;
import org.hibernate.test.filter.DynamicFilterTest;
import org.hibernate.test.formulajoin.FormulaJoinTest;
-import org.hibernate.test.generated.TimestampGeneratedValuesWithCachingTest;
-import org.hibernate.test.generated.TriggerGeneratedValuesWithCachingTest;
-import org.hibernate.test.generated.TriggerGeneratedValuesWithoutCachingTest;
-import org.hibernate.test.generatedkeys.select.SelectGeneratorTest;
-import org.hibernate.test.generatedkeys.seqidentity.SequenceIdentityTest;
+import org.hibernate.test.generated.GeneratedPropertySuite;
+import org.hibernate.test.generatedkeys.GeneratedKeysSuite;
import org.hibernate.test.hql.HQLSuite;
import org.hibernate.test.id.MultipleHiLoPerTableGeneratorTest;
import org.hibernate.test.idbag.IdBagTest;
@@ -69,6 +66,7 @@
import org.hibernate.test.legacy.CacheTest;
import org.hibernate.test.legacy.ComponentNotNullTest;
import org.hibernate.test.legacy.ConfigurationPerformanceTest;
+import org.hibernate.test.legacy.CustomSQLTest;
import org.hibernate.test.legacy.FooBarTest;
import org.hibernate.test.legacy.FumTest;
import org.hibernate.test.legacy.IJ2Test;
@@ -95,13 +93,11 @@
import org.hibernate.test.naturalid.NaturalIdTest;
import org.hibernate.test.ondelete.OnDeleteTest;
import org.hibernate.test.onetomany.OneToManyTest;
-import org.hibernate.test.onetoone.joined.OneToOneTest;
-import org.hibernate.test.onetooneformula.OneToOneFormulaTest;
+import org.hibernate.test.onetoone.OneToOneSuite;
import org.hibernate.test.ops.OpsSuite;
import org.hibernate.test.optlock.OptimisticLockTest;
import org.hibernate.test.ordered.OrderByTest;
-import org.hibernate.test.orphan.OrphanIdRollbackTest;
-import org.hibernate.test.orphan.OrphanTest;
+import org.hibernate.test.orphan.OrphanSuite;
import org.hibernate.test.pagination.PaginationTest;
import org.hibernate.test.propertyref.PropertyRefSuite;
import org.hibernate.test.proxy.ProxyTest;
@@ -131,6 +127,7 @@
import org.hibernate.test.version.db.DbVersionTest;
import org.hibernate.test.version.sybase.SybaseTimestampVersioningTest;
import org.hibernate.test.where.WhereTest;
+import org.hibernate.test.usercollection.UserCollectionTypeTest;
/**
* @author Gavin King
@@ -196,24 +193,19 @@
suite.addTest( CompositePropertyRefTest.suite() );
suite.addTest( FormulaJoinTest.suite() );
suite.addTest( DiscriminatorTest.suite() );
- suite.addTest( DynamicClassTest.suite() );
+ suite.addTest( EntityModeSuite.suite() );
suite.addTest( DynamicFilterTest.suite() );
suite.addTest( InterfaceProxyTest.suite() );
- suite.addTest( OrphanTest.suite() );
- suite.addTest( OrphanIdRollbackTest.suite() );
+ suite.addTest( OrphanSuite.suite() );
suite.addTest( JoinTest.suite() );
suite.addTest( JoinedSubclassTest.suite() );
suite.addTest( org.hibernate.test.unionsubclass2.UnionSubclassTest.suite() );
suite.addTest( MixedTest.suite() );
suite.addTest( OneToManyTest.suite() );
suite.addTest( ManyToManyTest.suite() );
- suite.addTest( OneToOneFormulaTest.suite() );
- suite.addTest( OneToOneTest.suite() );
- suite.addTest( org.hibernate.test.onetoone.singletable.OneToOneTest.suite() );
- suite.addTest( org.hibernate.test.onetoonelink.OneToOneTest.suite() );
+ suite.addTest( OneToOneSuite.suite() );
suite.addTest( OptimisticLockTest.suite() );
suite.addTest( PropertyRefSuite.suite() );
- suite.addTest( org.hibernate.test.orphan.PropertyRefTest.suite() );
suite.addTest( NativeSqlSupportSuite.suite() );
suite.addTest( CriteriaQueryTest.suite() );
suite.addTest( SubselectTest.suite() );
@@ -231,10 +223,6 @@
suite.addTest( TypedManyToOneTest.suite() );
suite.addTest( CMTTest.suite() );
suite.addTest( MultipleHiLoPerTableGeneratorTest.suite() );
- suite.addTest( MultiRepresentationTest.suite() );
- suite.addTest( Dom4jAccessorTest.suite() );
- suite.addTest( Dom4jTest.suite() );
- suite.addTest( Dom4jManyToOneTest.suite() );
suite.addTest( UnionSubclassFilterTest.suite() );
suite.addTest( JoinedSubclassFilterTest.suite() );
suite.addTest( DiscrimSubclassFilterTest.suite() );
@@ -273,11 +261,8 @@
suite.addTest( JavassistInstrumentationTest.suite() );
suite.addTest( SybaseTimestampVersioningTest.suite() );
suite.addTest( DbVersionTest.suite() );
- suite.addTest( TimestampGeneratedValuesWithCachingTest.suite() );
- suite.addTest( TriggerGeneratedValuesWithCachingTest.suite() );
- suite.addTest( TriggerGeneratedValuesWithoutCachingTest.suite() );
- suite.addTest( SelectGeneratorTest.suite() );
- suite.addTest( SequenceIdentityTest.suite() );
+ suite.addTest( GeneratedPropertySuite.suite() );
+ suite.addTest( GeneratedKeysSuite.suite() );
suite.addTest( InterceptorDynamicEntityTest.suite() );
suite.addTest( TuplizerDynamicEntityTest.suite() );
suite.addTest( BytecodeSuite.suite() );
@@ -289,6 +274,8 @@
suite.addTest( SQLFunctionsInterSystemsTest.suite() );
suite.addTest( LobSuite.suite() );
suite.addTest( IdentifierPropertyReferencesTest.suite() );
+ suite.addTest( DeleteTransientEntityTest.suite() );
+ suite.addTest( UserCollectionTypeTest.suite() );
return filter( suite );
//return suite;
@@ -335,6 +322,7 @@
suite.addTest( OneToOneCacheTest.suite() );
suite.addTest( NonReflectiveBinderTest.suite() );
suite.addTest( ConfigurationPerformanceTest.suite() ); // Added to ensure we can utilize the recommended performance tips ;)
+ suite.addTest( CustomSQLTest.suite() );
return filter( suite );
// return suite;
}
@@ -390,10 +378,7 @@
}
public void startingTestSuite(TestSuite suite) {
- currentStackElement = new TestSuiteStackEntry(
- new TestSuite( suite.getName() ),
- currentStackElement
- );
+ currentStackElement = new TestSuiteStackEntry( instantiateCopy( suite ), currentStackElement );
if ( topStackElement == null ) {
topStackElement = currentStackElement;
}
@@ -408,5 +393,19 @@
public TestSuite getFilteredTestSuite() {
return topStackElement.testSuite;
}
+
+ private static final Class[] EXPECTED_CTOR_SIG = new Class[] { String.class };
+
+ private TestSuite instantiateCopy(TestSuite suite) {
+ try {
+ Class testSuiteClass = suite.getClass();
+ Constructor ctor = testSuiteClass.getDeclaredConstructor( EXPECTED_CTOR_SIG );
+ ctor.setAccessible( true );
+ return ( TestSuite ) ctor.newInstance( new Object[] { suite.getName() } );
+ }
+ catch ( Throwable t ) {
+ throw new RuntimeException( "Unable to build test suite copy [" + suite + "]", t );
+ }
+ }
}
}
\ No newline at end of file
Deleted: trunk/Hibernate3/test/org/hibernate/test/DatabaseSpecificTestCase.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/DatabaseSpecificTestCase.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/DatabaseSpecificTestCase.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,23 +0,0 @@
-package org.hibernate.test;
-
-/**
- * @author Steve Ebersole
- */
-public abstract class DatabaseSpecificTestCase extends TestCase {
- public DatabaseSpecificTestCase(String name) {
- super( name );
- }
-
- protected void runTest() throws Throwable {
- // Note: this protection comes into play when running
- // tests individually. The suite as a whole is already
- // "protected" by the fact that these tests are actually
- // filtered out of the suite
- if ( appliesTo( getDialect() ) ) {
- super.runTest();
- }
- else {
- SKIP_LOG.warn( "skipping database-specific test [" + fullTestName() + "] for dialect [" + getDialect().getClass().getName() + "]" );
- }
- }
-}
Modified: trunk/Hibernate3/test/org/hibernate/test/TestCase.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/TestCase.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/TestCase.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -114,6 +114,9 @@
}
protected Dialect getDialect() {
+ if ( dialect == null ) {
+ dialect = Dialect.getDialect();
+ }
return dialect;
}
Modified: trunk/Hibernate3/test/org/hibernate/test/TestSelector.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/TestSelector.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/TestSelector.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,26 +1,28 @@
package org.hibernate.test;
+import java.util.Set;
+import java.util.HashSet;
+import java.io.File;
+
import org.apache.tools.ant.types.selectors.FileSelector;
import org.apache.tools.ant.BuildException;
-import java.io.File;
-import java.util.Set;
-import java.util.HashSet;
+import org.hibernate.junit.TestSuiteVisitor;
-import junit.framework.TestSuite;
import junit.framework.Test;
+import junit.framework.TestSuite;
/**
* A custom Ant FileSelector used to limit the tests run from the Ant
- * build script to only those defined in the {@link AllTests} suite.
+ * build script to only those defined in the {@link org.hibernate.test.AllTests} suite.
* <p/>
- * {@link AllTests} is used/maintained by the developers to easily
+ * {@link org.hibernate.test.AllTests} is used/maintained by the developers to easily
* run the test suite in all IDEs. It represents all the tests
* which should actually be run and included in test results.
- *
+ *
* @author Steve Ebersole
*/
-public class TestSelector extends junit.framework.TestCase implements FileSelector {
+public class TestSelector implements FileSelector {
private final Set allTestClassNames = new HashSet();
@@ -59,12 +61,4 @@
return file;
}
-
- // unit tests ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- public void testFileSelection() {
- File file = new File( "" );
- assertTrue( "valid test not selected", isSelected( file, "org/hibernate/test/hql/HQLTest.class", file ) );
- assertFalse( "invalid test selected", isSelected( file, "hithere.class", file ) );
- }
}
Deleted: trunk/Hibernate3/test/org/hibernate/test/TestSuiteVisitor.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/TestSuiteVisitor.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/TestSuiteVisitor.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,42 +0,0 @@
-package org.hibernate.test;
-
-import junit.framework.TestSuite;
-import junit.framework.Test;
-
-import java.util.Enumeration;
-
-/**
- * Handles walking a TestSuite hierarchy for recognition of individual tests.
- *
- * @author Steve Ebersole
- */
-public class TestSuiteVisitor {
-
- private final Handler handler;
-
- public TestSuiteVisitor(Handler handler) {
- this.handler = handler;
- }
-
- public void visit(TestSuite testSuite) {
- handler.startingTestSuite( testSuite );
- Enumeration tests = testSuite.tests();
- while ( tests.hasMoreElements() ) {
- Test test = ( Test ) tests.nextElement();
- if ( test instanceof TestSuite ) {
- visit( ( TestSuite ) test );
- }
- else {
- handler.handleTestCase( test );
- }
- }
- handler.completedTestSuite( testSuite );
- }
-
- public static interface Handler {
- public void handleTestCase(Test test);
- public void startingTestSuite(TestSuite suite);
- public void completedTestSuite(TestSuite suite);
- }
-
-}
Modified: trunk/Hibernate3/test/org/hibernate/test/abstractembeddedcomponents/cid/AbstractCompositeIdTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/abstractembeddedcomponents/cid/AbstractCompositeIdTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/abstractembeddedcomponents/cid/AbstractCompositeIdTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,24 +1,25 @@
package org.hibernate.test.abstractembeddedcomponents.cid;
-import org.hibernate.test.TestCase;
import org.hibernate.Session;
import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+
import junit.framework.Test;
-import junit.framework.TestSuite;
/**
* @author Steve Ebersole
*/
-public class AbstractCompositeIdTest extends TestCase {
+public class AbstractCompositeIdTest extends FunctionalTestCase {
public AbstractCompositeIdTest(String x) {
super( x );
}
public static Test suite() {
- return new TestSuite( AbstractCompositeIdTest.class );
+ return new FunctionalTestClassTestSuite( AbstractCompositeIdTest.class );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "abstractembeddedcomponents/cid/Mappings.hbm.xml" };
}
Modified: trunk/Hibernate3/test/org/hibernate/test/abstractembeddedcomponents/propertyref/AbstractComponentPropertyRefTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/abstractembeddedcomponents/propertyref/AbstractComponentPropertyRefTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/abstractembeddedcomponents/propertyref/AbstractComponentPropertyRefTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,24 +1,25 @@
package org.hibernate.test.abstractembeddedcomponents.propertyref;
-import org.hibernate.test.TestCase;
import org.hibernate.Session;
import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+
import junit.framework.Test;
-import junit.framework.TestSuite;
/**
* @author Steve Ebersole
*/
-public class AbstractComponentPropertyRefTest extends TestCase {
+public class AbstractComponentPropertyRefTest extends FunctionalTestCase {
public AbstractComponentPropertyRefTest(String name) {
super( name );
}
public static Test suite() {
- return new TestSuite( AbstractComponentPropertyRefTest.class );
+ return new FunctionalTestClassTestSuite( AbstractComponentPropertyRefTest.class );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "abstractembeddedcomponents/propertyref/Mappings.hbm.xml" };
}
Modified: trunk/Hibernate3/test/org/hibernate/test/any/Address.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/any/Address.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/any/Address.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -12,7 +12,6 @@
private Long id;
private Set lines = new HashSet();
-
public Long getId() {
return id;
}
Modified: trunk/Hibernate3/test/org/hibernate/test/any/AnyTypeTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/any/AnyTypeTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/any/AnyTypeTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,31 +1,32 @@
package org.hibernate.test.any;
-import org.hibernate.test.TestCase;
import org.hibernate.Session;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.junit.functional.FunctionalTestCase;
+
import junit.framework.Test;
-import junit.framework.TestSuite;
/**
* todo: describe AnyTypeTest
*
* @author Steve Ebersole
*/
-public class AnyTypeTest extends TestCase {
+public class AnyTypeTest extends FunctionalTestCase {
public AnyTypeTest(String name) {
super( name );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "any/Person.hbm.xml" };
}
- protected String getCacheConcurrencyStrategy() {
+ public String getCacheConcurrencyStrategy() {
// having second level cache causes a condition whereby the original test case would not fail...
return null;
}
public static Test suite() {
- return new TestSuite( AnyTypeTest.class );
+ return new FunctionalTestClassTestSuite( AnyTypeTest.class );
}
/**
Modified: trunk/Hibernate3/test/org/hibernate/test/array/ArrayTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/array/ArrayTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/array/ArrayTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -2,17 +2,29 @@
package org.hibernate.test.array;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Emmanuel Bernard
*/
-public class ArrayTest extends TestCase {
-
+public class ArrayTest extends FunctionalTestCase {
+
+ public ArrayTest(String x) {
+ super( x );
+ }
+
+ public String[] getMappings() {
+ return new String[] { "array/A.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( ArrayTest.class );
+ }
+
public void testArrayJoinFetch() throws Exception {
Session s;
Transaction tx;
@@ -38,18 +50,4 @@
tx.commit();
s.close();
}
-
- public ArrayTest(String x) {
- super( x );
- }
-
- public static Test suite() {
- return new TestSuite( ArrayTest.class );
- }
-
- protected String[] getMappings() {
- return new String[] {
- "array/A.hbm.xml"
- };
- }
}
Modified: trunk/Hibernate3/test/org/hibernate/test/ast/ASTIteratorTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/ast/ASTIteratorTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/ast/ASTIteratorTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -3,8 +3,9 @@
import java.io.PrintWriter;
+import antlr.ASTFactory;
+import antlr.collections.AST;
import junit.framework.Test;
-import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.hibernate.hql.antlr.HqlTokenTypes;
@@ -13,14 +14,12 @@
import org.hibernate.hql.ast.util.ASTParentsFirstIterator;
import org.hibernate.hql.ast.util.ASTPrinter;
import org.hibernate.hql.ast.util.ASTUtil;
+import org.hibernate.junit.UnitTestCase;
-import antlr.ASTFactory;
-import antlr.collections.AST;
-
/**
* Test ASTIterator.
*/
-public class ASTIteratorTest extends TestCase {
+public class ASTIteratorTest extends UnitTestCase {
private ASTFactory factory;
/**
Modified: trunk/Hibernate3/test/org/hibernate/test/ast/ASTUtilTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/ast/ASTUtilTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/ast/ASTUtilTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,19 +1,18 @@
// $Id$
package org.hibernate.test.ast;
+import antlr.ASTFactory;
+import antlr.collections.AST;
import junit.framework.Test;
-import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.hibernate.hql.ast.util.ASTUtil;
+import org.hibernate.junit.UnitTestCase;
-import antlr.ASTFactory;
-import antlr.collections.AST;
-
/**
* Unit test for ASTUtil.
*/
-public class ASTUtilTest extends TestCase {
+public class ASTUtilTest extends UnitTestCase {
private ASTFactory factory;
/**
Modified: trunk/Hibernate3/test/org/hibernate/test/batch/BatchTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/batch/BatchTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/batch/BatchTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -4,67 +4,78 @@
import java.math.BigDecimal;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.CacheMode;
import org.hibernate.ScrollMode;
import org.hibernate.ScrollableResults;
import org.hibernate.Session;
import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
-import org.hibernate.test.TestCase;
/**
* This is how to do batch processing in Hibernate.
- * Remember to enable JDBC batch updates, or this
+ * Remember to enable JDBC batch updates, or this
* test will take a Very Long Time!
- *
+ *
* @author Gavin King
*/
-public class BatchTest extends TestCase {
-
+public class BatchTest extends FunctionalTestCase {
+
public BatchTest(String str) {
- super(str);
+ super( str );
}
-
+
+ public String[] getMappings() {
+ return new String[] { "batch/DataPoint.hbm.xml" };
+ }
+
+ public String getCacheConcurrencyStrategy() {
+ return null;
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty( Environment.STATEMENT_BATCH_SIZE, "20" );
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( BatchTest.class );
+ }
+
public void testBatchInsertUpdate() {
-
- //remember to set hibernate.jdbc.batch_size=20
-
long start = System.currentTimeMillis();
-
- final boolean flushInBatches = true;
final int N = 5000; //26 secs with batch flush, 26 without
//final int N = 100000; //53 secs with batch flush, OOME without
//final int N = 250000; //137 secs with batch flush, OOME without
-
+
Session s = openSession();
- s.setCacheMode(CacheMode.IGNORE);
- Transaction t = s.beginTransaction();
- for ( int i=0; i<N; i++ ) {
+ s.setCacheMode( CacheMode.IGNORE );
+ Transaction t = s.beginTransaction();
+ for ( int i = 0; i < N; i++ ) {
DataPoint dp = new DataPoint();
- dp.setX( new BigDecimal(i * 0.1d).setScale(19, BigDecimal.ROUND_DOWN) );
- dp.setY( new BigDecimal( Math.cos( dp.getX().doubleValue() ) ).setScale(19, BigDecimal.ROUND_DOWN) );
- s.save(dp);
- if ( flushInBatches && i % 20 == 0 ) {
+ dp.setX( new BigDecimal( i * 0.1d ).setScale( 19, BigDecimal.ROUND_DOWN ) );
+ dp.setY( new BigDecimal( Math.cos( dp.getX().doubleValue() ) ).setScale( 19, BigDecimal.ROUND_DOWN ) );
+ s.save( dp );
+ if ( i % 20 == 0 ) {
s.flush();
s.clear();
}
}
t.commit();
s.close();
-
+
s = openSession();
- s.setCacheMode(CacheMode.IGNORE);
+ s.setCacheMode( CacheMode.IGNORE );
t = s.beginTransaction();
int i = 0;
- ScrollableResults sr = s.createQuery("from DataPoint dp order by dp.x asc")
- .scroll(ScrollMode.FORWARD_ONLY);
+ ScrollableResults sr = s.createQuery( "from DataPoint dp order by dp.x asc" )
+ .scroll( ScrollMode.FORWARD_ONLY );
while ( sr.next() ) {
- DataPoint dp = (DataPoint) sr.get(0);
- dp.setDescription("done!");
- if ( flushInBatches && ++i % 20 == 0 ) {
+ DataPoint dp = ( DataPoint ) sr.get( 0 );
+ dp.setDescription( "done!" );
+ if ( ++i % 20 == 0 ) {
s.flush();
s.clear();
}
@@ -73,22 +84,6 @@
s.close();
System.out.println( System.currentTimeMillis() - start );
}
-
- protected void configure(Configuration cfg) {
- cfg.setProperty(Environment.STATEMENT_BATCH_SIZE, "20");
- }
- protected String[] getMappings() {
- return new String[] { "batch/DataPoint.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(BatchTest.class);
- }
-
- public String getCacheConcurrencyStrategy() {
- return null;
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/batchfetch/BatchFetchTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/batchfetch/BatchFetchTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/batchfetch/BatchFetchTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -6,118 +6,117 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class BatchFetchTest extends TestCase {
-
+public class BatchFetchTest extends FunctionalTestCase {
+
public BatchFetchTest(String str) {
- super(str);
+ super( str );
}
-
+
+ public String[] getMappings() {
+ return new String[] { "batchfetch/ProductLine.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( BatchFetchTest.class );
+ }
+
public void testBatchFetch() {
Session s = openSession();
Transaction t = s.beginTransaction();
ProductLine cars = new ProductLine();
- cars.setDescription("Cars");
- Model monaro = new Model(cars);
- monaro.setName("monaro");
- monaro.setDescription("Holden Monaro");
- Model hsv = new Model(cars);
- hsv.setName("hsv");
- hsv.setDescription("Holden Commodore HSV");
- s.save(cars);
-
+ cars.setDescription( "Cars" );
+ Model monaro = new Model( cars );
+ monaro.setName( "monaro" );
+ monaro.setDescription( "Holden Monaro" );
+ Model hsv = new Model( cars );
+ hsv.setName( "hsv" );
+ hsv.setDescription( "Holden Commodore HSV" );
+ s.save( cars );
+
ProductLine oss = new ProductLine();
- oss.setDescription("OSS");
- Model jboss = new Model(oss);
- jboss.setName("JBoss");
- jboss.setDescription("JBoss Application Server");
- Model hibernate = new Model(oss);
- hibernate.setName("Hibernate");
- hibernate.setDescription("Hibernate");
- Model cache = new Model(oss);
- cache.setName("JBossCache");
- cache.setDescription("JBoss TreeCache");
- s.save(oss);
-
+ oss.setDescription( "OSS" );
+ Model jboss = new Model( oss );
+ jboss.setName( "JBoss" );
+ jboss.setDescription( "JBoss Application Server" );
+ Model hibernate = new Model( oss );
+ hibernate.setName( "Hibernate" );
+ hibernate.setDescription( "Hibernate" );
+ Model cache = new Model( oss );
+ cache.setName( "JBossCache" );
+ cache.setDescription( "JBoss TreeCache" );
+ s.save( oss );
+
t.commit();
s.close();
-
- s.getSessionFactory().evict(Model.class);
- s.getSessionFactory().evict(ProductLine.class);
-
+
+ s.getSessionFactory().evict( Model.class );
+ s.getSessionFactory().evict( ProductLine.class );
+
s = openSession();
t = s.beginTransaction();
-
- List list = s.createQuery("from ProductLine pl order by pl.description").list();
- cars = (ProductLine) list.get(0);
- oss = (ProductLine) list.get(1);
+
+ List list = s.createQuery( "from ProductLine pl order by pl.description" ).list();
+ cars = ( ProductLine ) list.get( 0 );
+ oss = ( ProductLine ) list.get( 1 );
assertFalse( Hibernate.isInitialized( cars.getModels() ) );
assertFalse( Hibernate.isInitialized( oss.getModels() ) );
assertEquals( cars.getModels().size(), 2 ); //fetch both collections
assertTrue( Hibernate.isInitialized( cars.getModels() ) );
assertTrue( Hibernate.isInitialized( oss.getModels() ) );
-
+
s.clear();
-
- list = s.createQuery("from Model m").list();
- hibernate = (Model) s.get(Model.class, hibernate.getId());
+
+ list = s.createQuery( "from Model m" ).list();
+ hibernate = ( Model ) s.get( Model.class, hibernate.getId() );
hibernate.getProductLine().getId();
- for ( Iterator i=list.iterator(); i.hasNext(); ) {
- assertFalse( Hibernate.isInitialized( ( (Model) i.next() ).getProductLine() ) );
+ for ( Iterator i = list.iterator(); i.hasNext(); ) {
+ assertFalse( Hibernate.isInitialized( ( ( Model ) i.next() ).getProductLine() ) );
}
assertEquals( hibernate.getProductLine().getDescription(), "OSS" ); //fetch both productlines
-
+
s.clear();
-
- Iterator iter = s.createQuery("from Model").iterate();
+
+ Iterator iter = s.createQuery( "from Model" ).iterate();
list = new ArrayList();
while ( iter.hasNext() ) {
list.add( iter.next() );
}
- Model m = (Model) list.get(0);
+ Model m = ( Model ) list.get( 0 );
m.getDescription(); //fetch a batch of 4
-
+
s.clear();
-
- list = s.createQuery("from ProductLine").list();
- ProductLine pl = (ProductLine) list.get(0);
- ProductLine pl2 = (ProductLine) list.get(1);
- s.evict(pl2);
+
+ list = s.createQuery( "from ProductLine" ).list();
+ ProductLine pl = ( ProductLine ) list.get( 0 );
+ ProductLine pl2 = ( ProductLine ) list.get( 1 );
+ s.evict( pl2 );
pl.getModels().size(); //fetch just one collection! (how can we write an assertion for that??)
-
+
t.commit();
s.close();
s = openSession();
t = s.beginTransaction();
- list = s.createQuery("from ProductLine pl order by pl.description").list();
- cars = (ProductLine) list.get(0);
- oss = (ProductLine) list.get(1);
+ list = s.createQuery( "from ProductLine pl order by pl.description" ).list();
+ cars = ( ProductLine ) list.get( 0 );
+ oss = ( ProductLine ) list.get( 1 );
assertEquals( cars.getModels().size(), 2 );
assertEquals( oss.getModels().size(), 3 );
- s.delete(cars);
- s.delete(oss);
+ s.delete( cars );
+ s.delete( oss );
t.commit();
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "batchfetch/ProductLine.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(BatchFetchTest.class);
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/bidi/AuctionTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/bidi/AuctionTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/bidi/AuctionTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -5,65 +5,75 @@
import java.util.Date;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.dialect.PostgreSQLDialect;
-import org.hibernate.test.TestCase;
/**
* @author Gavin King
*/
-public class AuctionTest extends TestCase {
-
+public class AuctionTest extends FunctionalTestCase {
+
public AuctionTest(String str) {
- super(str);
+ super( str );
}
-
+
+ public String[] getMappings() {
+ return new String[] { "bidi/Auction.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( AuctionTest.class );
+ }
+
public void testLazy() {
- if ( getDialect() instanceof PostgreSQLDialect ) return; //doesn't like boolean=1
-
+ if ( getDialect() instanceof PostgreSQLDialect ) {
+ return; //doesn't like boolean=1
+ }
+
Session s = openSession();
Transaction t = s.beginTransaction();
Auction a = new Auction();
- a.setDescription("an auction for something");
+ a.setDescription( "an auction for something" );
a.setEnd( new Date() );
Bid b = new Bid();
- b.setAmount( new BigDecimal(123.34).setScale(19, BigDecimal.ROUND_DOWN) );
- b.setSuccessful(true);
+ b.setAmount( new BigDecimal( 123.34 ).setScale( 19, BigDecimal.ROUND_DOWN ) );
+ b.setSuccessful( true );
b.setDatetime( new Date() );
- b.setItem(a);
- a.getBids().add(b);
- a.setSuccessfulBid(b);
- s.persist(b);
+ b.setItem( a );
+ a.getBids().add( b );
+ a.setSuccessfulBid( b );
+ s.persist( b );
t.commit();
s.close();
-
+
Long aid = a.getId();
Long bid = b.getId();
-
+
s = openSession();
t = s.beginTransaction();
- b = (Bid) s.load( Bid.class, bid );
- assertFalse( Hibernate.isInitialized(b) );
- a = (Auction) s.get( Auction.class, aid );
+ b = ( Bid ) s.load( Bid.class, bid );
+ assertFalse( Hibernate.isInitialized( b ) );
+ a = ( Auction ) s.get( Auction.class, aid );
assertFalse( Hibernate.isInitialized( a.getBids() ) );
assertTrue( Hibernate.isInitialized( a.getSuccessfulBid() ) );
assertSame( a.getBids().iterator().next(), b );
assertSame( b, a.getSuccessfulBid() );
- assertTrue( Hibernate.isInitialized(b) );
+ assertTrue( Hibernate.isInitialized( b ) );
assertTrue( b.isSuccessful() );
t.commit();
s.close();
s = openSession();
t = s.beginTransaction();
- b = (Bid) s.load( Bid.class, bid );
- assertFalse( Hibernate.isInitialized(b) );
- a = (Auction) s.createQuery("from Auction a left join fetch a.bids").uniqueResult();
- assertTrue( Hibernate.isInitialized(b) );
+ b = ( Bid ) s.load( Bid.class, bid );
+ assertFalse( Hibernate.isInitialized( b ) );
+ a = ( Auction ) s.createQuery( "from Auction a left join fetch a.bids" ).uniqueResult();
+ assertTrue( Hibernate.isInitialized( b ) );
assertTrue( Hibernate.isInitialized( a.getBids() ) );
assertSame( b, a.getSuccessfulBid() );
assertSame( a.getBids().iterator().next(), b );
@@ -73,13 +83,13 @@
s = openSession();
t = s.beginTransaction();
- b = (Bid) s.load( Bid.class, bid );
- a = (Auction) s.load( Auction.class, aid );
- assertFalse( Hibernate.isInitialized(b) );
- assertFalse( Hibernate.isInitialized(a) );
- s.createQuery("from Auction a left join fetch a.successfulBid").list();
- assertTrue( Hibernate.isInitialized(b) );
- assertTrue( Hibernate.isInitialized(a) );
+ b = ( Bid ) s.load( Bid.class, bid );
+ a = ( Auction ) s.load( Auction.class, aid );
+ assertFalse( Hibernate.isInitialized( b ) );
+ assertFalse( Hibernate.isInitialized( a ) );
+ s.createQuery( "from Auction a left join fetch a.successfulBid" ).list();
+ assertTrue( Hibernate.isInitialized( b ) );
+ assertTrue( Hibernate.isInitialized( a ) );
assertSame( b, a.getSuccessfulBid() );
assertFalse( Hibernate.isInitialized( a.getBids() ) );
assertSame( a.getBids().iterator().next(), b );
@@ -89,14 +99,14 @@
s = openSession();
t = s.beginTransaction();
- b = (Bid) s.load( Bid.class, bid );
- a = (Auction) s.load( Auction.class, aid );
- assertFalse( Hibernate.isInitialized(b) );
- assertFalse( Hibernate.isInitialized(a) );
+ b = ( Bid ) s.load( Bid.class, bid );
+ a = ( Auction ) s.load( Auction.class, aid );
+ assertFalse( Hibernate.isInitialized( b ) );
+ assertFalse( Hibernate.isInitialized( a ) );
assertSame( s.get( Bid.class, bid ), b );
- assertTrue( Hibernate.isInitialized(b) );
- assertSame( s.get(Auction.class, aid ), a );
- assertTrue( Hibernate.isInitialized(a) );
+ assertTrue( Hibernate.isInitialized( b ) );
+ assertSame( s.get( Auction.class, aid ), a );
+ assertTrue( Hibernate.isInitialized( a ) );
assertSame( b, a.getSuccessfulBid() );
assertFalse( Hibernate.isInitialized( a.getBids() ) );
assertSame( a.getBids().iterator().next(), b );
@@ -104,14 +114,6 @@
t.commit();
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "bidi/Auction.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(AuctionTest.class);
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/bidi/AuctionTest2.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/bidi/AuctionTest2.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/bidi/AuctionTest2.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -7,64 +7,74 @@
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.dialect.Oracle9Dialect;
-import org.hibernate.test.TestCase;
import junit.framework.Test;
-import junit.framework.TestSuite;
/**
* @author Gavin King
*/
-public class AuctionTest2 extends TestCase {
-
+public class AuctionTest2 extends FunctionalTestCase {
+
public AuctionTest2(String str) {
- super(str);
+ super( str );
}
+ public String[] getMappings() {
+ return new String[] { "bidi/Auction2.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( AuctionTest2.class );
+ }
+
public void testLazy() {
-
- if ( getDialect() instanceof Oracle9Dialect ) return; //ora doesn't like exists() in the select clause
-
+
+ if ( getDialect() instanceof Oracle9Dialect ) {
+ return; //ora doesn't like exists() in the select clause
+ }
+
Session s = openSession();
Transaction t = s.beginTransaction();
Auction a = new Auction();
- a.setDescription("an auction for something");
+ a.setDescription( "an auction for something" );
a.setEnd( new Date() );
Bid b = new Bid();
- b.setAmount( new BigDecimal(123.34).setScale(19, BigDecimal.ROUND_DOWN) );
- b.setSuccessful(true);
+ b.setAmount( new BigDecimal( 123.34 ).setScale( 19, BigDecimal.ROUND_DOWN ) );
+ b.setSuccessful( true );
b.setDatetime( new Date() );
- b.setItem(a);
- a.getBids().add(b);
- a.setSuccessfulBid(b);
- s.persist(b);
+ b.setItem( a );
+ a.getBids().add( b );
+ a.setSuccessfulBid( b );
+ s.persist( b );
t.commit();
s.close();
-
+
Long aid = a.getId();
Long bid = b.getId();
-
+
s = openSession();
t = s.beginTransaction();
- b = (Bid) s.load( Bid.class, bid );
- assertFalse( Hibernate.isInitialized(b) );
- a = (Auction) s.get( Auction.class, aid );
+ b = ( Bid ) s.load( Bid.class, bid );
+ assertFalse( Hibernate.isInitialized( b ) );
+ a = ( Auction ) s.get( Auction.class, aid );
assertFalse( Hibernate.isInitialized( a.getBids() ) );
assertFalse( Hibernate.isInitialized( a.getSuccessfulBid() ) );
assertSame( a.getBids().iterator().next(), b );
assertSame( b, a.getSuccessfulBid() );
- assertTrue( Hibernate.isInitialized(b) );
+ assertTrue( Hibernate.isInitialized( b ) );
assertTrue( b.isSuccessful() );
t.commit();
s.close();
s = openSession();
t = s.beginTransaction();
- b = (Bid) s.load( Bid.class, bid );
- assertFalse( Hibernate.isInitialized(b) );
- a = (Auction) s.createQuery("from Auction a left join fetch a.bids").uniqueResult();
- assertTrue( Hibernate.isInitialized(b) );
+ b = ( Bid ) s.load( Bid.class, bid );
+ assertFalse( Hibernate.isInitialized( b ) );
+ a = ( Auction ) s.createQuery( "from Auction a left join fetch a.bids" ).uniqueResult();
+ assertTrue( Hibernate.isInitialized( b ) );
assertTrue( Hibernate.isInitialized( a.getBids() ) );
assertSame( b, a.getSuccessfulBid() );
assertSame( a.getBids().iterator().next(), b );
@@ -74,13 +84,13 @@
s = openSession();
t = s.beginTransaction();
- b = (Bid) s.load( Bid.class, bid );
- a = (Auction) s.load( Auction.class, aid );
- assertFalse( Hibernate.isInitialized(b) );
- assertFalse( Hibernate.isInitialized(a) );
- s.createQuery("from Auction a left join fetch a.successfulBid").list();
- assertTrue( Hibernate.isInitialized(b) );
- assertTrue( Hibernate.isInitialized(a) );
+ b = ( Bid ) s.load( Bid.class, bid );
+ a = ( Auction ) s.load( Auction.class, aid );
+ assertFalse( Hibernate.isInitialized( b ) );
+ assertFalse( Hibernate.isInitialized( a ) );
+ s.createQuery( "from Auction a left join fetch a.successfulBid" ).list();
+ assertTrue( Hibernate.isInitialized( b ) );
+ assertTrue( Hibernate.isInitialized( a ) );
assertSame( b, a.getSuccessfulBid() );
assertFalse( Hibernate.isInitialized( a.getBids() ) );
assertSame( a.getBids().iterator().next(), b );
@@ -90,14 +100,14 @@
s = openSession();
t = s.beginTransaction();
- b = (Bid) s.load( Bid.class, bid );
- a = (Auction) s.load( Auction.class, aid );
- assertFalse( Hibernate.isInitialized(b) );
- assertFalse( Hibernate.isInitialized(a) );
+ b = ( Bid ) s.load( Bid.class, bid );
+ a = ( Auction ) s.load( Auction.class, aid );
+ assertFalse( Hibernate.isInitialized( b ) );
+ assertFalse( Hibernate.isInitialized( a ) );
assertSame( s.get( Bid.class, bid ), b );
- assertTrue( Hibernate.isInitialized(b) );
- assertSame( s.get(Auction.class, aid ), a );
- assertTrue( Hibernate.isInitialized(a) );
+ assertTrue( Hibernate.isInitialized( b ) );
+ assertSame( s.get( Auction.class, aid ), a );
+ assertTrue( Hibernate.isInitialized( a ) );
assertSame( b, a.getSuccessfulBid() );
assertFalse( Hibernate.isInitialized( a.getBids() ) );
assertSame( a.getBids().iterator().next(), b );
@@ -105,13 +115,5 @@
t.commit();
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "bidi/Auction2.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(AuctionTest2.class);
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/bytecode/cglib/InvocationTargetExceptionTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/bytecode/cglib/InvocationTargetExceptionTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/bytecode/cglib/InvocationTargetExceptionTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -4,6 +4,9 @@
import org.hibernate.test.bytecode.Bean;
import org.hibernate.Session;
import org.hibernate.Hibernate;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.cfg.Environment;
import junit.framework.TestSuite;
@@ -15,17 +18,17 @@
*
* @author Steve Ebersole
*/
-public class InvocationTargetExceptionTest extends TestCase {
+public class InvocationTargetExceptionTest extends FunctionalTestCase {
public InvocationTargetExceptionTest(String name) {
super( name );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "bytecode/Bean.hbm.xml" };
}
public static TestSuite suite() {
- return new TestSuite( InvocationTargetExceptionTest.class );
+ return new FunctionalTestClassTestSuite( InvocationTargetExceptionTest.class );
}
public void testProxiedInvocationException() {
Modified: trunk/Hibernate3/test/org/hibernate/test/bytecode/cglib/ReflectionOptimizerTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/bytecode/cglib/ReflectionOptimizerTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/bytecode/cglib/ReflectionOptimizerTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,16 +1,22 @@
package org.hibernate.test.bytecode.cglib;
-import junit.framework.TestCase;
import junit.framework.TestSuite;
+
+import org.hibernate.bytecode.ReflectionOptimizer;
import org.hibernate.bytecode.cglib.BytecodeProviderImpl;
-import org.hibernate.bytecode.ReflectionOptimizer;
+import org.hibernate.junit.UnitTestCase;
import org.hibernate.test.bytecode.Bean;
import org.hibernate.test.bytecode.BeanReflectionHelper;
/**
* @author Steve Ebersole
*/
-public class ReflectionOptimizerTest extends TestCase {
+public class ReflectionOptimizerTest extends UnitTestCase {
+
+ public ReflectionOptimizerTest(String string) {
+ super( string );
+ }
+
public void testReflectionOptimization() {
BytecodeProviderImpl provider = new BytecodeProviderImpl();
ReflectionOptimizer optimizer = provider.getReflectionOptimizer(
Modified: trunk/Hibernate3/test/org/hibernate/test/bytecode/javassist/InvocationTargetExceptionTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/bytecode/javassist/InvocationTargetExceptionTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/bytecode/javassist/InvocationTargetExceptionTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,38 +1,41 @@
package org.hibernate.test.bytecode.javassist;
-import org.hibernate.test.TestCase;
-import org.hibernate.test.bytecode.Bean;
-import org.hibernate.Session;
-import org.hibernate.Hibernate;
-import org.hibernate.cfg.Environment;
-
import java.text.ParseException;
import junit.framework.TestSuite;
+import org.hibernate.Hibernate;
+import org.hibernate.Session;
+import org.hibernate.cfg.Environment;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.test.bytecode.Bean;
+
/**
* Test that the Javassist-based lazy initializer properly handles
* InvocationTargetExceptions
*
* @author Steve Ebersole
*/
-public class InvocationTargetExceptionTest extends TestCase {
+public class InvocationTargetExceptionTest extends FunctionalTestCase {
public InvocationTargetExceptionTest(String name) {
super( name );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "bytecode/Bean.hbm.xml" };
}
public static TestSuite suite() {
- return new TestSuite( InvocationTargetExceptionTest.class );
+ return new FunctionalTestClassTestSuite( InvocationTargetExceptionTest.class );
}
public void testProxiedInvocationException() {
- if ( ! ( Environment.getBytecodeProvider() instanceof org.hibernate.bytecode.javassist.BytecodeProviderImpl ) ) {
+ if ( !( Environment.getBytecodeProvider() instanceof org.hibernate.bytecode.javassist.BytecodeProviderImpl ) ) {
// because of the scoping :(
- reportSkip( "env not configured for javassist provider", "bytecode-provider InvocationTargetException handling" );
+ reportSkip(
+ "env not configured for javassist provider", "bytecode-provider InvocationTargetException handling"
+ );
return;
}
Session s = openSession();
@@ -54,7 +57,7 @@
catch ( ParseException e ) {
// expected behavior
}
- catch( Throwable t ) {
+ catch ( Throwable t ) {
fail( "unexpected exception type : " + t );
}
Modified: trunk/Hibernate3/test/org/hibernate/test/bytecode/javassist/ReflectionOptimizerTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/bytecode/javassist/ReflectionOptimizerTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/bytecode/javassist/ReflectionOptimizerTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,16 +1,22 @@
package org.hibernate.test.bytecode.javassist;
-import junit.framework.TestCase;
import junit.framework.TestSuite;
+
+import org.hibernate.bytecode.ReflectionOptimizer;
import org.hibernate.bytecode.javassist.BytecodeProviderImpl;
-import org.hibernate.bytecode.ReflectionOptimizer;
+import org.hibernate.junit.UnitTestCase;
import org.hibernate.test.bytecode.Bean;
import org.hibernate.test.bytecode.BeanReflectionHelper;
/**
* @author Steve Ebersole
*/
-public class ReflectionOptimizerTest extends TestCase {
+public class ReflectionOptimizerTest extends UnitTestCase {
+
+ public ReflectionOptimizerTest(String string) {
+ super( string );
+ }
+
public void testReflectionOptimization() {
BytecodeProviderImpl provider = new BytecodeProviderImpl();
ReflectionOptimizer optimizer = provider.getReflectionOptimizer(
Modified: trunk/Hibernate3/test/org/hibernate/test/cache/BaseCacheProviderTestCase.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/cache/BaseCacheProviderTestCase.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/cache/BaseCacheProviderTestCase.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,16 +1,16 @@
package org.hibernate.test.cache;
+import java.util.HashMap;
import java.util.Map;
-import java.util.HashMap;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cache.ReadWriteCache;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
+import org.hibernate.junit.functional.FunctionalTestCase;
import org.hibernate.stat.SecondLevelCacheStatistics;
import org.hibernate.stat.Statistics;
-import org.hibernate.test.TestCase;
import org.hibernate.test.tm.DummyConnectionProvider;
import org.hibernate.test.tm.DummyTransactionManagerLookup;
import org.hibernate.transaction.JDBCTransactionFactory;
@@ -20,7 +20,7 @@
*
* @author Steve Ebersole
*/
-public abstract class BaseCacheProviderTestCase extends TestCase {
+public abstract class BaseCacheProviderTestCase extends FunctionalTestCase {
// note that a lot of the fucntionality here is intended to be used
// in creating specific tests for each CacheProvider that would extend
@@ -30,11 +30,11 @@
super( x );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "cache/Item.hbm.xml" };
}
- protected void configure(Configuration cfg) {
+ public void configure(Configuration cfg) {
super.configure( cfg );
cfg.setProperty( Environment.CACHE_REGION_PREFIX, "" );
cfg.setProperty( Environment.USE_SECOND_LEVEL_CACHE, "true" );
Modified: trunk/Hibernate3/test/org/hibernate/test/cache/ehcache/EhCacheTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/cache/ehcache/EhCacheTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/cache/ehcache/EhCacheTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -2,9 +2,10 @@
package org.hibernate.test.cache.ehcache;
import junit.framework.Test;
-import junit.framework.TestSuite;
+
import org.hibernate.cache.EhCacheProvider;
import org.hibernate.cfg.Environment;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.test.cache.BaseCacheProviderTestCase;
/**
@@ -21,7 +22,7 @@
}
public static Test suite() {
- return new TestSuite( EhCacheTest.class );
+ return new FunctionalTestClassTestSuite( EhCacheTest.class );
}
public String getCacheConcurrencyStrategy() {
Modified: trunk/Hibernate3/test/org/hibernate/test/cache/treecache/optimistic/OptimisticTreeCacheTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/cache/treecache/optimistic/OptimisticTreeCacheTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/cache/treecache/optimistic/OptimisticTreeCacheTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,16 +1,17 @@
package org.hibernate.test.cache.treecache.optimistic;
import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.hibernate.cache.OptimisticTreeCacheProvider;
-import org.hibernate.cfg.Environment;
-import org.hibernate.test.cache.BaseCacheProviderTestCase;
-import org.hibernate.test.tm.DummyTransactionManager;
import org.jboss.cache.Fqn;
import org.jboss.cache.TreeCache;
import org.jboss.cache.config.Option;
import org.jboss.cache.optimistic.DataVersion;
+import org.hibernate.cache.OptimisticTreeCacheProvider;
+import org.hibernate.cfg.Environment;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.test.cache.BaseCacheProviderTestCase;
+import org.hibernate.test.tm.DummyTransactionManager;
+
/**
* @author Steve Ebersole
*/
@@ -25,7 +26,7 @@
}
public static Test suite() {
- return new TestSuite( OptimisticTreeCacheTest.class );
+ return new FunctionalTestClassTestSuite( OptimisticTreeCacheTest.class );
}
public String getCacheConcurrencyStrategy() {
Modified: trunk/Hibernate3/test/org/hibernate/test/cache/treecache/pessimistic/TreeCacheTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/cache/treecache/pessimistic/TreeCacheTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/cache/treecache/pessimistic/TreeCacheTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,10 +1,11 @@
package org.hibernate.test.cache.treecache.pessimistic;
-import org.hibernate.test.cache.BaseCacheProviderTestCase;
+import junit.framework.Test;
+
import org.hibernate.cache.TreeCacheProvider;
import org.hibernate.cfg.Environment;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.test.cache.BaseCacheProviderTestCase;
/**
* @author Steve Ebersole
@@ -20,7 +21,7 @@
}
public static Test suite() {
- return new TestSuite( TreeCacheTest.class );
+ return new FunctionalTestClassTestSuite( TreeCacheTest.class );
}
public String getCacheConcurrencyStrategy() {
Modified: trunk/Hibernate3/test/org/hibernate/test/cascade/RefreshTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/cascade/RefreshTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/cascade/RefreshTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,38 +1,35 @@
// $Id$
package org.hibernate.test.cascade;
-import org.hibernate.test.TestCase;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-
-import java.util.Date;
-import java.util.Iterator;
import java.sql.Connection;
import java.sql.PreparedStatement;
+import java.util.Date;
+import java.util.Iterator;
import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+
/**
* Implementation of RefreshTest.
*
* @author Steve Ebersole
*/
-public class RefreshTest extends TestCase {
+public class RefreshTest extends FunctionalTestCase {
public RefreshTest(String name) {
super( name );
}
- protected String[] getMappings() {
- return new String[] {
- "cascade/Job.hbm.xml",
- "cascade/JobBatch.hbm.xml"
- };
+ public String[] getMappings() {
+ return new String[] { "cascade/Job.hbm.xml", "cascade/JobBatch.hbm.xml" };
}
public static Test suite() {
- return new TestSuite( RefreshTest.class );
+ return new FunctionalTestClassTestSuite( RefreshTest.class );
}
public void testRefreshCascade() throws Throwable {
@@ -64,7 +61,6 @@
}
private void updateStatuses(Connection connection) throws Throwable {
-
PreparedStatement stmnt = null;
try {
stmnt = connection.prepareStatement( "UPDATE T_JOB SET JOB_STATUS = 1" );
Modified: trunk/Hibernate3/test/org/hibernate/test/cfg/CacheableFileTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/cfg/CacheableFileTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/cfg/CacheableFileTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -2,21 +2,24 @@
import java.io.File;
-import junit.framework.TestCase;
-
import org.hibernate.cfg.Configuration;
+import org.hibernate.junit.UnitTestCase;
/**
* {@inheritDoc}
*
* @author Steve Ebersole
*/
-public class CacheableFileTest extends TestCase {
+public class CacheableFileTest extends UnitTestCase {
public static final String MAPPING = "org/hibernate/test/cfg/Cacheable.hbm.xml";
private File mappingFile;
+ public CacheableFileTest(String string) {
+ super( string );
+ }
+
protected void setUp() throws Exception {
super.setUp();
mappingFile = new File( getClass().getClassLoader().getResource( MAPPING ).getFile() );
Modified: trunk/Hibernate3/test/org/hibernate/test/cid/CompositeIdTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/cid/CompositeIdTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/cid/CompositeIdTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -7,21 +7,29 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class CompositeIdTest extends TestCase {
+public class CompositeIdTest extends FunctionalTestCase {
public CompositeIdTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "cid/Customer.hbm.xml", "cid/Order.hbm.xml", "cid/LineItem.hbm.xml", "cid/Product.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite(CompositeIdTest.class);
+ }
public void testQuery() {
Session s = openSession();
@@ -257,18 +265,5 @@
s.close();
}
- protected String[] getMappings() {
- return new String[] {
- "cid/Customer.hbm.xml",
- "cid/Order.hbm.xml",
- "cid/LineItem.hbm.xml",
- "cid/Product.hbm.xml"
- };
- }
-
- public static Test suite() {
- return new TestSuite(CompositeIdTest.class);
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/collection/CollectionSuite.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/collection/CollectionSuite.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/collection/CollectionSuite.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -7,6 +7,7 @@
import org.hibernate.test.collection.idbag.PersistentIdBagTest;
import org.hibernate.test.collection.list.PersistentListTest;
import org.hibernate.test.collection.map.PersistentMapTest;
+import org.hibernate.test.collection.original.CollectionTest;
import org.hibernate.test.collection.set.PersistentSetTest;
/**
@@ -18,11 +19,11 @@
public static Test suite() {
TestSuite suite = new TestSuite( "Collection-related tests" );
- suite.addTest( CollectionTest.suite() );
suite.addTest( PersistentBagTest.suite() );
suite.addTest( PersistentIdBagTest.suite() );
suite.addTest( PersistentListTest.suite() );
suite.addTest( PersistentMapTest.suite() );
+ suite.addTest( CollectionTest.suite() );
suite.addTest( PersistentSetTest.suite() );
return suite;
}
Deleted: trunk/Hibernate3/test/org/hibernate/test/collection/CollectionTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/collection/CollectionTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/collection/CollectionTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,252 +0,0 @@
-//$Id$
-package org.hibernate.test.collection;
-
-import java.sql.SQLException;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.hibernate.Hibernate;
-import org.hibernate.HibernateException;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
-
-/**
- * @author Gavin King
- */
-public class CollectionTest extends TestCase {
-
- public CollectionTest(String str) {
- super(str);
- }
-
- public void testExtraLazy() throws HibernateException, SQLException {
- Session s = openSession();
- Transaction t = s.beginTransaction();
- User u = new User("gavin");
- u.getPermissions().add( new Permission("obnoxiousness") );
- u.getPermissions().add( new Permission("pigheadedness") );
- u.getSessionData().put("foo", "foo value");
- s.persist(u);
- t.commit();
- s.close();
- s = openSession();
- t = s.beginTransaction();
- u = (User) s.get(User.class, "gavin");
-
- assertFalse( Hibernate.isInitialized( u.getPermissions() ) );
- assertEquals( u.getPermissions().size(), 2 );
- assertTrue( u.getPermissions().contains( new Permission("obnoxiousness") ) );
- assertFalse( u.getPermissions().contains( new Permission("silliness") ) );
- assertNotNull( u.getPermissions().get(1) );
- assertNull( u.getPermissions().get(3) );
- assertFalse( Hibernate.isInitialized( u.getPermissions() ) );
-
- assertFalse( Hibernate.isInitialized( u.getSessionData() ) );
- assertEquals( u.getSessionData().size(), 1 );
- assertTrue( u.getSessionData().containsKey("foo") );
- assertFalse( u.getSessionData().containsKey("bar") );
- assertTrue( u.getSessionData().containsValue("foo value") );
- assertFalse( u.getSessionData().containsValue("bar") );
- assertEquals( "foo value", u.getSessionData().get("foo") );
- assertNull( u.getSessionData().get("bar") );
- assertFalse( Hibernate.isInitialized( u.getSessionData() ) );
-
- assertFalse( Hibernate.isInitialized( u.getSessionData() ) );
- u.getSessionData().put("bar", "bar value");
- u.getSessionAttributeNames().add("bar");
- assertFalse( Hibernate.isInitialized( u.getSessionAttributeNames() ) );
- assertTrue( Hibernate.isInitialized( u.getSessionData() ) );
-
- s.delete(u);
- t.commit();
- s.close();
- }
-
- /*public void testFilter() throws HibernateException, SQLException {
- Session s = openSession();
- Transaction t = s.beginTransaction();
- User u = new User("gavin");
- u.getPermissions().add( new Permission("obnoxiousness") );
- u.getPermissions().add( new Permission("pigheadedness") );
- s.persist(u);
- t.commit();
- s.close();
- s = openSession();
- t = s.beginTransaction();
- u = (User) s.get(User.class, "gavin");
- assertFalse( Hibernate.isInitialized( u.getPermissions() ) );
- assertEquals( s.createFilter( u.getPermissions(), "select count(*)" ).uniqueResult(), new Integer(2) );
- assertFalse( Hibernate.isInitialized( u.getPermissions() ) );
- assertFalse( Hibernate.isInitialized( u.getSessionData() ) );
- assertEquals( s.createFilter( u.getSessionData(), "select count(*)" ).uniqueResult(), new Integer(0) );
- assertFalse( Hibernate.isInitialized( u.getSessionData() ) );
- s.delete(u);
- t.commit();
- s.close();
- }*/
-
- public void testMerge() throws HibernateException, SQLException {
- Session s = openSession();
- Transaction t = s.beginTransaction();
- User u = new User("gavin");
- u.getPermissions().add( new Permission("obnoxiousness") );
- u.getPermissions().add( new Permission("pigheadedness") );
- s.persist(u);
- t.commit();
- s.close();
-
- s = openSession();
- t = s.beginTransaction();
- User u2 = (User) s.createCriteria(User.class).uniqueResult();
- u2.setPermissions(null); //forces one shot delete
- s.merge(u);
- t.commit();
- s.close();
-
- u.getPermissions().add( new Permission("silliness") );
-
- s = openSession();
- t = s.beginTransaction();
- s.merge(u);
- t.commit();
- s.close();
-
- s = openSession();
- t = s.beginTransaction();
- u2 = (User) s.createCriteria(User.class).uniqueResult();
- assertEquals( u2.getPermissions().size(), 3 );
- assertEquals( ( (Permission) u2.getPermissions().get(0) ).getType(), "obnoxiousness" );
- assertEquals( ( (Permission) u2.getPermissions().get(2) ).getType(), "silliness" );
- t.commit();
- s.close();
-
- s = openSession();
- t = s.beginTransaction();
- s.delete(u2);
- s.flush();
- t.commit();
- s.close();
-
- }
-
- public void testFetch() {
- Session s = openSession();
- Transaction t = s.beginTransaction();
- User u = new User("gavin");
- u.getPermissions().add( new Permission("obnoxiousness") );
- u.getPermissions().add( new Permission("pigheadedness") );
- u.getEmailAddresses().add( new Email("gavin(a)hibernate.org") );
- u.getEmailAddresses().add( new Email("gavin.king(a)jboss.com") );
- s.persist(u);
- t.commit();
- s.close();
-
- s = openSession();
- t = s.beginTransaction();
- User u2 = (User) s.createCriteria(User.class).uniqueResult();
- assertTrue( Hibernate.isInitialized( u2.getEmailAddresses() ) );
- assertFalse( Hibernate.isInitialized( u2.getPermissions() ) );
- assertEquals( u2.getEmailAddresses().size(), 2 );
- s.delete(u2);
- t.commit();
- s.close();
- }
-
- public void testUpdateOrder() {
- Session s = openSession();
- Transaction t = s.beginTransaction();
- User u = new User("gavin");
- u.getSessionData().put("foo", "foo value");
- u.getSessionData().put("bar", "bar value");
- u.getEmailAddresses().add( new Email("gavin.king(a)jboss.com") );
- u.getEmailAddresses().add( new Email("gavin(a)hibernate.org") );
- u.getEmailAddresses().add( new Email("gavin(a)illflow.com") );
- u.getEmailAddresses().add( new Email("gavin(a)nospam.com") );
- s.persist(u);
- t.commit();
- s.close();
-
- u.getSessionData().clear();
- u.getSessionData().put("baz", "baz value");
- u.getSessionData().put("bar", "bar value");
- u.getEmailAddresses().remove(0);
- u.getEmailAddresses().remove(2);
-
- s = openSession();
- t = s.beginTransaction();
- s.update(u);
- t.commit();
- s.close();
-
- u.getSessionData().clear();
- u.getEmailAddresses().add(0, new Email("gavin(a)nospam.com") );
- u.getEmailAddresses().add( new Email("gavin.king(a)jboss.com") );
-
- s = openSession();
- t = s.beginTransaction();
- s.update(u);
- t.commit();
- s.close();
-
- s = openSession();
- t = s.beginTransaction();
- s.delete(u);
- t.commit();
- s.close();
-
- }
-
- public void testValueMap() {
- Session s = openSession();
- Transaction t = s.beginTransaction();
- User u = new User("gavin");
- u.getSessionData().put("foo", "foo value");
- u.getSessionData().put("bar", null);
- u.getEmailAddresses().add(null);
- u.getEmailAddresses().add( new Email("gavin.king(a)jboss.com") );
- u.getEmailAddresses().add(null);
- u.getEmailAddresses().add(null);
- s.persist(u);
- t.commit();
- s.close();
-
- s = openSession();
- t = s.beginTransaction();
- User u2 = (User) s.createCriteria(User.class).uniqueResult();
- assertFalse( Hibernate.isInitialized( u2.getSessionData() ) );
- assertEquals( u2.getSessionData().size(), 1 );
- assertEquals( u2.getEmailAddresses().size(), 2 );
- u2.getSessionData().put("foo", "new foo value");
- u2.getEmailAddresses().set( 1, new Email("gavin(a)hibernate.org") );
- //u2.getEmailAddresses().remove(3);
- //u2.getEmailAddresses().remove(2);
- t.commit();
- s.close();
-
- s = openSession();
- t = s.beginTransaction();
- u2 = (User) s.createCriteria(User.class).uniqueResult();
- assertFalse( Hibernate.isInitialized( u2.getSessionData() ) );
- assertEquals( u2.getSessionData().size(), 1 );
- assertEquals( u2.getEmailAddresses().size(), 2 );
- assertEquals( u2.getSessionData().get("foo"), "new foo value" );
- assertEquals( ( (Email) u2.getEmailAddresses().get(1) ).getAddress(), "gavin(a)hibernate.org" );
- s.delete(u2);
- t.commit();
- s.close();
- }
-
-
-
- protected String[] getMappings() {
- return new String[] { "collection/UserPermissions.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(CollectionTest.class);
- }
-
-}
-
Deleted: trunk/Hibernate3/test/org/hibernate/test/collection/Email.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/collection/Email.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/collection/Email.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,27 +0,0 @@
-//$Id$
-package org.hibernate.test.collection;
-
-/**
- * @author Gavin King
- */
-public class Email {
- private String address;
- Email() {}
- public String getAddress() {
- return address;
- }
- public void setAddress(String type) {
- this.address = type;
- }
- public Email(String type) {
- this.address = type;
- }
- public boolean equals(Object that) {
- if ( !(that instanceof Email) ) return false;
- Email p = (Email) that;
- return this.address.equals(p.address);
- }
- public int hashCode() {
- return address.hashCode();
- }
-}
Deleted: trunk/Hibernate3/test/org/hibernate/test/collection/Permission.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/collection/Permission.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/collection/Permission.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,27 +0,0 @@
-//$Id$
-package org.hibernate.test.collection;
-
-/**
- * @author Gavin King
- */
-public class Permission {
- private String type;
- Permission() {}
- public String getType() {
- return type;
- }
- public void setType(String type) {
- this.type = type;
- }
- public Permission(String type) {
- this.type = type;
- }
- public boolean equals(Object that) {
- if ( !(that instanceof Permission) ) return false;
- Permission p = (Permission) that;
- return this.type.equals(p.type);
- }
- public int hashCode() {
- return type.hashCode();
- }
-}
Deleted: trunk/Hibernate3/test/org/hibernate/test/collection/User.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/collection/User.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/collection/User.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,55 +0,0 @@
-//$Id$
-package org.hibernate.test.collection;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author Gavin King
- */
-public class User {
- private String userName;
- private List permissions = new ArrayList();
- private List emailAddresses = new ArrayList();
- private Map sessionData = new HashMap();
- private Set sessionAttributeNames = new HashSet();
-
- User() {}
- public User(String name) {
- userName = name;
- }
- public List getPermissions() {
- return permissions;
- }
- public void setPermissions(List permissions) {
- this.permissions = permissions;
- }
- public String getUserName() {
- return userName;
- }
- public void setUserName(String userName) {
- this.userName = userName;
- }
- public List getEmailAddresses() {
- return emailAddresses;
- }
- public void setEmailAddresses(List emailAddresses) {
- this.emailAddresses = emailAddresses;
- }
- public Map getSessionData() {
- return sessionData;
- }
- public void setSessionData(Map sessionData) {
- this.sessionData = sessionData;
- }
- public Set getSessionAttributeNames() {
- return sessionAttributeNames;
- }
- public void setSessionAttributeNames(Set sessionAttributeNames) {
- this.sessionAttributeNames = sessionAttributeNames;
- }
-}
Deleted: trunk/Hibernate3/test/org/hibernate/test/collection/UserPermissions.hbm.xml
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/collection/UserPermissions.hbm.xml 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/collection/UserPermissions.hbm.xml 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,54 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-
-<!--
-
- This mapping demonstrates how to use a composite
- element mapping to model a parent/child association.
-
--->
-
-<hibernate-mapping
- package="org.hibernate.test.collection">
-
- <import class="Permission"/>
-
- <class name="User" table="`Users`">
- <id name="userName"/>
- <list name="permissions" lazy="extra">
- <key column="userName"/>
- <list-index column="displayOrder" base="1"/>
- <composite-element class="Permission">
- <property name="type" column="permissionType"/>
- </composite-element>
- </list>
- <list name="emailAddresses" fetch="join">
- <key column="userName"/>
- <list-index column="displayOrder" base="1"/>
- <composite-element class="Email">
- <property name="address"/>
- </composite-element>
- </list>
- <map name="sessionData"
- order-by="lower(`attributeName`) asc"
- lazy="extra">
- <key column="userName"/>
- <map-key column="`attributeName`"
- type="string"/>
- <element column="`attributeValue`"
- type="serializable"
- not-null="true"/>
- </map>
- <set name="sessionAttributeNames"
- lazy="extra"
- inverse="true">
- <key column="userName"/>
- <element column="`attributeName`"
- type="string"/>
- </set>
- </class>
-
-
-</hibernate-mapping>
Modified: trunk/Hibernate3/test/org/hibernate/test/collection/bag/PersistentBagTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/collection/bag/PersistentBagTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/collection/bag/PersistentBagTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,31 +1,30 @@
package org.hibernate.test.collection.bag;
-import java.util.HashSet;
import java.util.ArrayList;
import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.hibernate.test.TestCase;
import org.hibernate.Session;
import org.hibernate.collection.PersistentBag;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* Tests related to operations on a PersistentBag.
*
* @author Steve Ebersole
*/
-public class PersistentBagTest extends TestCase {
+public class PersistentBagTest extends FunctionalTestCase {
public PersistentBagTest(String name) {
super( name );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "collection/bag/Mappings.hbm.xml" };
}
public static Test suite() {
- return new TestSuite( PersistentBagTest.class );
+ return new FunctionalTestClassTestSuite( PersistentBagTest.class );
}
public void testWriteMethodDirtying() {
Modified: trunk/Hibernate3/test/org/hibernate/test/collection/idbag/PersistentIdBagTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/collection/idbag/PersistentIdBagTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/collection/idbag/PersistentIdBagTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -3,28 +3,28 @@
import java.util.ArrayList;
import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.hibernate.test.TestCase;
import org.hibernate.Session;
import org.hibernate.collection.PersistentIdentifierBag;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* Tests related to operations on a PersistentIdentifierBag
*
* @author Steve Ebersole
*/
-public class PersistentIdBagTest extends TestCase {
+public class PersistentIdBagTest extends FunctionalTestCase {
public PersistentIdBagTest(String name) {
super( name );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "collection/idbag/Mappings.hbm.xml" };
}
public static Test suite() {
- return new TestSuite( PersistentIdBagTest.class );
+ return new FunctionalTestClassTestSuite( PersistentIdBagTest.class );
}
public void testWriteMethodDirtying() {
Modified: trunk/Hibernate3/test/org/hibernate/test/collection/list/PersistentListTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/collection/list/PersistentListTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/collection/list/PersistentListTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -3,28 +3,28 @@
import java.util.ArrayList;
import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.hibernate.test.TestCase;
import org.hibernate.Session;
import org.hibernate.collection.PersistentList;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* Tests related to operations on a PersistentList
*
* @author Steve Ebersole
*/
-public class PersistentListTest extends TestCase {
+public class PersistentListTest extends FunctionalTestCase {
public PersistentListTest(String name) {
super( name );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "collection/list/Mappings.hbm.xml" };
}
public static Test suite() {
- return new TestSuite( PersistentListTest.class );
+ return new FunctionalTestClassTestSuite( PersistentListTest.class );
}
public void testWriteMethodDirtying() {
Modified: trunk/Hibernate3/test/org/hibernate/test/collection/map/PersistentMapTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/collection/map/PersistentMapTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/collection/map/PersistentMapTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,30 +1,30 @@
package org.hibernate.test.collection.map;
-import org.hibernate.test.TestCase;
-import org.hibernate.Session;
-import org.hibernate.collection.PersistentMap;
-
import java.util.HashMap;
import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.Session;
+import org.hibernate.collection.PersistentMap;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+
/**
* todo: describe PersistentMapTest
*
* @author Steve Ebersole
*/
-public class PersistentMapTest extends TestCase {
+public class PersistentMapTest extends FunctionalTestCase {
public PersistentMapTest(String name) {
super( name );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "collection/map/Mappings.hbm.xml" };
}
public static Test suite() {
- return new TestSuite( PersistentMapTest.class );
+ return new FunctionalTestClassTestSuite( PersistentMapTest.class );
}
public void testWriteMethodDirtying() {
Copied: trunk/Hibernate3/test/org/hibernate/test/collection/original/CollectionTest.java (from rev 10964, trunk/Hibernate3/test/org/hibernate/test/collection/CollectionTest.java)
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/collection/CollectionTest.java 2006-12-08 16:06:49 UTC (rev 10964)
+++ trunk/Hibernate3/test/org/hibernate/test/collection/original/CollectionTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,228 @@
+//$Id$
+package org.hibernate.test.collection.original;
+
+import java.sql.SQLException;
+
+import junit.framework.Test;
+
+import org.hibernate.Hibernate;
+import org.hibernate.HibernateException;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+
+/**
+ * @author Gavin King
+ */
+public class CollectionTest extends FunctionalTestCase {
+
+ public CollectionTest(String str) {
+ super( str );
+ }
+
+ public String[] getMappings() {
+ return new String[] { "collection/original/UserPermissions.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( CollectionTest.class );
+ }
+
+ public void testExtraLazy() throws HibernateException, SQLException {
+ Session s = openSession();
+ Transaction t = s.beginTransaction();
+ User u = new User( "gavin" );
+ u.getPermissions().add( new Permission( "obnoxiousness" ) );
+ u.getPermissions().add( new Permission( "pigheadedness" ) );
+ u.getSessionData().put( "foo", "foo value" );
+ s.persist( u );
+ t.commit();
+ s.close();
+ s = openSession();
+ t = s.beginTransaction();
+ u = ( User ) s.get( User.class, "gavin" );
+
+ assertFalse( Hibernate.isInitialized( u.getPermissions() ) );
+ assertEquals( u.getPermissions().size(), 2 );
+ assertTrue( u.getPermissions().contains( new Permission( "obnoxiousness" ) ) );
+ assertFalse( u.getPermissions().contains( new Permission( "silliness" ) ) );
+ assertNotNull( u.getPermissions().get( 1 ) );
+ assertNull( u.getPermissions().get( 3 ) );
+ assertFalse( Hibernate.isInitialized( u.getPermissions() ) );
+
+ assertFalse( Hibernate.isInitialized( u.getSessionData() ) );
+ assertEquals( u.getSessionData().size(), 1 );
+ assertTrue( u.getSessionData().containsKey( "foo" ) );
+ assertFalse( u.getSessionData().containsKey( "bar" ) );
+ assertTrue( u.getSessionData().containsValue( "foo value" ) );
+ assertFalse( u.getSessionData().containsValue( "bar" ) );
+ assertEquals( "foo value", u.getSessionData().get( "foo" ) );
+ assertNull( u.getSessionData().get( "bar" ) );
+ assertFalse( Hibernate.isInitialized( u.getSessionData() ) );
+
+ assertFalse( Hibernate.isInitialized( u.getSessionData() ) );
+ u.getSessionData().put( "bar", "bar value" );
+ u.getSessionAttributeNames().add( "bar" );
+ assertFalse( Hibernate.isInitialized( u.getSessionAttributeNames() ) );
+ assertTrue( Hibernate.isInitialized( u.getSessionData() ) );
+
+ s.delete( u );
+ t.commit();
+ s.close();
+ }
+
+ public void testMerge() throws HibernateException, SQLException {
+ Session s = openSession();
+ Transaction t = s.beginTransaction();
+ User u = new User( "gavin" );
+ u.getPermissions().add( new Permission( "obnoxiousness" ) );
+ u.getPermissions().add( new Permission( "pigheadedness" ) );
+ s.persist( u );
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ User u2 = ( User ) s.createCriteria( User.class ).uniqueResult();
+ u2.setPermissions( null ); //forces one shot delete
+ s.merge( u );
+ t.commit();
+ s.close();
+
+ u.getPermissions().add( new Permission( "silliness" ) );
+
+ s = openSession();
+ t = s.beginTransaction();
+ s.merge( u );
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ u2 = ( User ) s.createCriteria( User.class ).uniqueResult();
+ assertEquals( u2.getPermissions().size(), 3 );
+ assertEquals( ( ( Permission ) u2.getPermissions().get( 0 ) ).getType(), "obnoxiousness" );
+ assertEquals( ( ( Permission ) u2.getPermissions().get( 2 ) ).getType(), "silliness" );
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ s.delete( u2 );
+ s.flush();
+ t.commit();
+ s.close();
+
+ }
+
+ public void testFetch() {
+ Session s = openSession();
+ Transaction t = s.beginTransaction();
+ User u = new User( "gavin" );
+ u.getPermissions().add( new Permission( "obnoxiousness" ) );
+ u.getPermissions().add( new Permission( "pigheadedness" ) );
+ u.getEmailAddresses().add( new Email( "gavin(a)hibernate.org" ) );
+ u.getEmailAddresses().add( new Email( "gavin.king(a)jboss.com" ) );
+ s.persist( u );
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ User u2 = ( User ) s.createCriteria( User.class ).uniqueResult();
+ assertTrue( Hibernate.isInitialized( u2.getEmailAddresses() ) );
+ assertFalse( Hibernate.isInitialized( u2.getPermissions() ) );
+ assertEquals( u2.getEmailAddresses().size(), 2 );
+ s.delete( u2 );
+ t.commit();
+ s.close();
+ }
+
+ public void testUpdateOrder() {
+ Session s = openSession();
+ Transaction t = s.beginTransaction();
+ User u = new User( "gavin" );
+ u.getSessionData().put( "foo", "foo value" );
+ u.getSessionData().put( "bar", "bar value" );
+ u.getEmailAddresses().add( new Email( "gavin.king(a)jboss.com" ) );
+ u.getEmailAddresses().add( new Email( "gavin(a)hibernate.org" ) );
+ u.getEmailAddresses().add( new Email( "gavin(a)illflow.com" ) );
+ u.getEmailAddresses().add( new Email( "gavin(a)nospam.com" ) );
+ s.persist( u );
+ t.commit();
+ s.close();
+
+ u.getSessionData().clear();
+ u.getSessionData().put( "baz", "baz value" );
+ u.getSessionData().put( "bar", "bar value" );
+ u.getEmailAddresses().remove( 0 );
+ u.getEmailAddresses().remove( 2 );
+
+ s = openSession();
+ t = s.beginTransaction();
+ s.update( u );
+ t.commit();
+ s.close();
+
+ u.getSessionData().clear();
+ u.getEmailAddresses().add( 0, new Email( "gavin(a)nospam.com" ) );
+ u.getEmailAddresses().add( new Email( "gavin.king(a)jboss.com" ) );
+
+ s = openSession();
+ t = s.beginTransaction();
+ s.update( u );
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ s.delete( u );
+ t.commit();
+ s.close();
+
+ }
+
+ public void testValueMap() {
+ Session s = openSession();
+ Transaction t = s.beginTransaction();
+ User u = new User( "gavin" );
+ u.getSessionData().put( "foo", "foo value" );
+ u.getSessionData().put( "bar", null );
+ u.getEmailAddresses().add( null );
+ u.getEmailAddresses().add( new Email( "gavin.king(a)jboss.com" ) );
+ u.getEmailAddresses().add( null );
+ u.getEmailAddresses().add( null );
+ s.persist( u );
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ User u2 = ( User ) s.createCriteria( User.class ).uniqueResult();
+ assertFalse( Hibernate.isInitialized( u2.getSessionData() ) );
+ assertEquals( u2.getSessionData().size(), 1 );
+ assertEquals( u2.getEmailAddresses().size(), 2 );
+ u2.getSessionData().put( "foo", "new foo value" );
+ u2.getEmailAddresses().set( 1, new Email( "gavin(a)hibernate.org" ) );
+ //u2.getEmailAddresses().remove(3);
+ //u2.getEmailAddresses().remove(2);
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ u2 = ( User ) s.createCriteria( User.class ).uniqueResult();
+ assertFalse( Hibernate.isInitialized( u2.getSessionData() ) );
+ assertEquals( u2.getSessionData().size(), 1 );
+ assertEquals( u2.getEmailAddresses().size(), 2 );
+ assertEquals( u2.getSessionData().get( "foo" ), "new foo value" );
+ assertEquals( ( ( Email ) u2.getEmailAddresses().get( 1 ) ).getAddress(), "gavin(a)hibernate.org" );
+ s.delete( u2 );
+ t.commit();
+ s.close();
+ }
+
+
+}
+
Property changes on: trunk/Hibernate3/test/org/hibernate/test/collection/original/CollectionTest.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/Hibernate3/test/org/hibernate/test/collection/original/Email.java (from rev 10964, trunk/Hibernate3/test/org/hibernate/test/collection/Email.java)
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/collection/Email.java 2006-12-08 16:06:49 UTC (rev 10964)
+++ trunk/Hibernate3/test/org/hibernate/test/collection/original/Email.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,27 @@
+//$Id$
+package org.hibernate.test.collection.original;
+
+/**
+ * @author Gavin King
+ */
+public class Email {
+ private String address;
+ Email() {}
+ public String getAddress() {
+ return address;
+ }
+ public void setAddress(String type) {
+ this.address = type;
+ }
+ public Email(String type) {
+ this.address = type;
+ }
+ public boolean equals(Object that) {
+ if ( !(that instanceof Email) ) return false;
+ Email p = (Email) that;
+ return this.address.equals(p.address);
+ }
+ public int hashCode() {
+ return address.hashCode();
+ }
+}
Property changes on: trunk/Hibernate3/test/org/hibernate/test/collection/original/Email.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/Hibernate3/test/org/hibernate/test/collection/original/Permission.java (from rev 10964, trunk/Hibernate3/test/org/hibernate/test/collection/Permission.java)
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/collection/Permission.java 2006-12-08 16:06:49 UTC (rev 10964)
+++ trunk/Hibernate3/test/org/hibernate/test/collection/original/Permission.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,27 @@
+//$Id$
+package org.hibernate.test.collection.original;
+
+/**
+ * @author Gavin King
+ */
+public class Permission {
+ private String type;
+ Permission() {}
+ public String getType() {
+ return type;
+ }
+ public void setType(String type) {
+ this.type = type;
+ }
+ public Permission(String type) {
+ this.type = type;
+ }
+ public boolean equals(Object that) {
+ if ( !(that instanceof Permission) ) return false;
+ Permission p = (Permission) that;
+ return this.type.equals(p.type);
+ }
+ public int hashCode() {
+ return type.hashCode();
+ }
+}
Property changes on: trunk/Hibernate3/test/org/hibernate/test/collection/original/Permission.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/Hibernate3/test/org/hibernate/test/collection/original/User.java (from rev 10964, trunk/Hibernate3/test/org/hibernate/test/collection/User.java)
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/collection/User.java 2006-12-08 16:06:49 UTC (rev 10964)
+++ trunk/Hibernate3/test/org/hibernate/test/collection/original/User.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,55 @@
+//$Id$
+package org.hibernate.test.collection.original;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author Gavin King
+ */
+public class User {
+ private String userName;
+ private List permissions = new ArrayList();
+ private List emailAddresses = new ArrayList();
+ private Map sessionData = new HashMap();
+ private Set sessionAttributeNames = new HashSet();
+
+ User() {}
+ public User(String name) {
+ userName = name;
+ }
+ public List getPermissions() {
+ return permissions;
+ }
+ public void setPermissions(List permissions) {
+ this.permissions = permissions;
+ }
+ public String getUserName() {
+ return userName;
+ }
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+ public List getEmailAddresses() {
+ return emailAddresses;
+ }
+ public void setEmailAddresses(List emailAddresses) {
+ this.emailAddresses = emailAddresses;
+ }
+ public Map getSessionData() {
+ return sessionData;
+ }
+ public void setSessionData(Map sessionData) {
+ this.sessionData = sessionData;
+ }
+ public Set getSessionAttributeNames() {
+ return sessionAttributeNames;
+ }
+ public void setSessionAttributeNames(Set sessionAttributeNames) {
+ this.sessionAttributeNames = sessionAttributeNames;
+ }
+}
Property changes on: trunk/Hibernate3/test/org/hibernate/test/collection/original/User.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/Hibernate3/test/org/hibernate/test/collection/original/UserPermissions.hbm.xml (from rev 10964, trunk/Hibernate3/test/org/hibernate/test/collection/UserPermissions.hbm.xml)
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/collection/UserPermissions.hbm.xml 2006-12-08 16:06:49 UTC (rev 10964)
+++ trunk/Hibernate3/test/org/hibernate/test/collection/original/UserPermissions.hbm.xml 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,53 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<!--
+
+ This mapping demonstrates how to use a composite
+ element mapping to model a parent/child association.
+
+-->
+
+<hibernate-mapping package="org.hibernate.test.collection.original">
+
+ <import class="Permission"/>
+
+ <class name="User" table="`Users`">
+ <id name="userName"/>
+ <list name="permissions" lazy="extra">
+ <key column="userName"/>
+ <list-index column="displayOrder" base="1"/>
+ <composite-element class="Permission">
+ <property name="type" column="permissionType"/>
+ </composite-element>
+ </list>
+ <list name="emailAddresses" fetch="join">
+ <key column="userName"/>
+ <list-index column="displayOrder" base="1"/>
+ <composite-element class="Email">
+ <property name="address"/>
+ </composite-element>
+ </list>
+ <map name="sessionData"
+ order-by="lower(`attributeName`) asc"
+ lazy="extra">
+ <key column="userName"/>
+ <map-key column="`attributeName`"
+ type="string"/>
+ <element column="`attributeValue`"
+ type="serializable"
+ not-null="true"/>
+ </map>
+ <set name="sessionAttributeNames"
+ lazy="extra"
+ inverse="true">
+ <key column="userName"/>
+ <element column="`attributeName`"
+ type="string"/>
+ </set>
+ </class>
+
+
+</hibernate-mapping>
Property changes on: trunk/Hibernate3/test/org/hibernate/test/collection/original/UserPermissions.hbm.xml
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/Hibernate3/test/org/hibernate/test/collection/set/PersistentSetTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/collection/set/PersistentSetTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/collection/set/PersistentSetTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,30 +1,30 @@
package org.hibernate.test.collection.set;
-import org.hibernate.test.TestCase;
-import org.hibernate.Session;
-import org.hibernate.collection.PersistentSet;
-
import java.util.HashSet;
import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.Session;
+import org.hibernate.collection.PersistentSet;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+
/**
* todo: describe PersistentSetTest
*
* @author Steve Ebersole
*/
-public class PersistentSetTest extends TestCase {
+public class PersistentSetTest extends FunctionalTestCase {
public PersistentSetTest(String name) {
super( name );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "collection/set/Mappings.hbm.xml" };
}
public static Test suite() {
- return new TestSuite( PersistentSetTest.class );
+ return new FunctionalTestClassTestSuite( PersistentSetTest.class );
}
public void testWriteMethodDirtying() {
Deleted: trunk/Hibernate3/test/org/hibernate/test/component/A.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/component/A.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/component/A.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,42 +0,0 @@
-package org.hibernate.test.component;
-
-import java.util.Map;
-
-public class A {
-
- public int id;
- public Map dynComp;
-
- public A() {
- this(-1);
- }
-
- public A(int id) {
- this.id = id;
- }
-
- public Map getDynComp() {
- return dynComp;
- }
-
- public void setDynComp(Map dynComp) {
- this.dynComp = dynComp;
- }
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public boolean equals(Object obj) {
- if ( !( obj instanceof A ) ) return false;
- return id == ( (A) obj ).id;
- }
-
- public int hashCode() {
- return id == -1 ? super.hashCode() : id;
- }
-}
Deleted: trunk/Hibernate3/test/org/hibernate/test/component/ABC.hbm.xml
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/component/ABC.hbm.xml 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/component/ABC.hbm.xml 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,30 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-
-<hibernate-mapping package="org.hibernate.test.component">
-
- <class name="A" table="aa">
- <id name="id"/>
- <dynamic-component name="dynComp">
- <property name="a" type="string"/>
- </dynamic-component>
- </class>
-
- <joined-subclass name="B" extends="A" table="bb">
- <key column="A"/>
- <dynamic-component name="dynComp">
- <property name="b" type="string"/>
- </dynamic-component>
- </joined-subclass>
-
- <joined-subclass name="C" extends="B" table="cc">
- <key column="B"/>
- <dynamic-component name="dynComp">
- <property name="c" type="string"/>
- </dynamic-component>
- </joined-subclass>
-
-
-</hibernate-mapping>
Deleted: trunk/Hibernate3/test/org/hibernate/test/component/B.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/component/B.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/component/B.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,13 +0,0 @@
-package org.hibernate.test.component;
-
-
-public class B extends A {
-
- public B() {
- super(-1);
- }
-
- public B(int id) {
- super(id);
- }
-}
Deleted: trunk/Hibernate3/test/org/hibernate/test/component/C.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/component/C.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/component/C.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,13 +0,0 @@
-package org.hibernate.test.component;
-
-
-public class C extends B {
-
- public C() {
- super(-1);
- }
-
- public C(int id) {
- super(id);
- }
-}
Modified: trunk/Hibernate3/test/org/hibernate/test/component/ComponentTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/component/ComponentTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/component/ComponentTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,36 +1,74 @@
//$Id$
package org.hibernate.test.component;
+import java.util.ArrayList;
import java.util.Date;
+import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
+import org.hibernate.cfg.Mappings;
import org.hibernate.criterion.Property;
+import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.HSQLDialect;
-import org.hibernate.dialect.Oracle9Dialect;
-import org.hibernate.dialect.PostgreSQLDialect;
-import org.hibernate.dialect.SQLServerDialect;
-import org.hibernate.test.TestCase;
+import org.hibernate.dialect.function.SQLFunction;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.mapping.Component;
+import org.hibernate.mapping.Formula;
+import org.hibernate.mapping.PersistentClass;
/**
* @author Gavin King
*/
-public class ComponentTest extends TestCase {
+public class ComponentTest extends FunctionalTestCase {
public ComponentTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "component/User.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
+ }
+
+ public void afterConfigurationBuilt(Mappings mappings, Dialect dialect) {
+ super.afterConfigurationBuilt( mappings, dialect );
+ // Oracle and Postgres do not have year() functions, so we need to
+ // redefine the 'User.person.yob' formula
+ //
+ // consider temporary until we add the capability to define
+ // mapping foprmulas which can use dialect-registered functions...
+ PersistentClass user = mappings.getClass( User.class.getName() );
+ org.hibernate.mapping.Property personProperty = user.getProperty( "person" );
+ Component component = ( Component ) personProperty.getValue();
+ Formula f = ( Formula ) component.getProperty( "yob" ).getValue().getColumnIterator().next();
+
+ SQLFunction yearFunction = ( SQLFunction ) dialect.getFunctions().get( "year" );
+ if ( yearFunction == null ) {
+ // the dialect not know to support a year() function, so rely on the
+ // ANSI SQL extract function
+ f.setFormula( "extract( year from dob )");
+ }
+ else {
+ List args = new ArrayList();
+ args.add( "dob" );
+ f.setFormula( yearFunction.render( args, null ) );
+ }
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite(ComponentTest.class);
+ }
public void testUpdateFalse() {
-
- if ( getDialect() instanceof PostgreSQLDialect ) return; //postgres got no year() function
- if ( getDialect() instanceof Oracle9Dialect ) return; //oracle got no year() function
-
getSessions().getStatistics().clear();
Session s = openSession();
@@ -57,10 +95,6 @@
}
public void testComponent() {
-
- if ( getDialect() instanceof PostgreSQLDialect ) return; //postgres got no year() function
- if ( getDialect() instanceof Oracle9Dialect ) return; //oracle got no year() function
-
Session s = openSession();
Transaction t = s.beginTransaction();
User u = new User( "gavin", "secret", new Person("Gavin King", new Date(), "Karbarook Ave") );
@@ -92,9 +126,6 @@
}
public void testComponentQueries() {
-// if ( !dialectSupportsRowValueConstructorSyntax() ) {
-// return;
-// }
Session s = openSession();
Transaction t = s.beginTransaction();
Employee emp = new Employee();
@@ -114,17 +145,13 @@
}
public void testComponentFormulaQuery() {
-
- if ( getDialect() instanceof PostgreSQLDialect ) return; //postgres got no year() function
- if ( getDialect() instanceof Oracle9Dialect ) return; //oracle got no year() function
-
Session s = openSession();
Transaction t = s.beginTransaction();
s.createQuery("from User u where u.person.yob = 1999").list();
s.createCriteria(User.class)
.add( Property.forName("person.yob").between( new Integer(1999), new Integer(2002) ) )
.list();
- if ( ! (getDialect() instanceof HSQLDialect) ) {
+ if ( getDialect().supportsRowValueConstructorSyntax() ) {
s.createQuery("from User u where u.person = ('gavin', :dob, 'Peachtree Rd', 'Karbarook Ave', 1974, 'Peachtree Rd')")
.setDate("dob", new Date("March 25, 1974")).list();
s.createQuery("from User where person = ('gavin', :dob, 'Peachtree Rd', 'Karbarook Ave', 1974, 'Peachtree Rd')")
@@ -135,9 +162,6 @@
}
public void testNamedQuery() {
- if ( getDialect() instanceof PostgreSQLDialect ) return; //postgres got no year() function
- if ( getDialect() instanceof Oracle9Dialect ) return; //oracle got no year() function
-
Session s = openSession();
Transaction t = s.beginTransaction();
s.getNamedQuery("userNameIn")
@@ -146,18 +170,6 @@
t.commit();
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "component/User.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(ComponentTest.class);
- }
-
- protected void configure(Configuration cfg) {
- cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
- }
-
}
Deleted: trunk/Hibernate3/test/org/hibernate/test/component/DynamicComponentTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/component/DynamicComponentTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/component/DynamicComponentTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,84 +0,0 @@
-package org.hibernate.test.component;
-
-import java.util.HashMap;
-import java.util.List;
-
-import org.hibernate.classic.Session;
-import org.hibernate.test.TestCase;
-
-public class DynamicComponentTest extends TestCase {
-
- public DynamicComponentTest(String x) {
- super(x);
- }
-
- public void testQuery() throws Exception {
- Session session = openSession();
-
- A a = new A(1);
- a.setDynComp(new HashMap());
- a.getDynComp().put("a", "a-a");
- session.save(a);
-
- B b = new B(2);
- b.setDynComp(new HashMap());
- b.getDynComp().put("a", "b-a");
- b.getDynComp().put("b", "b-b");
- session.save(b);
-
- C c = new C(3);
- c.setDynComp(new HashMap());
- c.getDynComp().put("a", "c-a");
- c.getDynComp().put("b", "c-b");
- c.getDynComp().put("c", "c-c");
- session.save(c);
-
- session.flush();
-
- List list = session.createQuery("from A a where a.dynComp.a = ?")
- .setParameter(0, "a-a")
- .list();
-
- assertEquals(1, list.size());
- assertTrue(a.equals(list.get(0)));
-
- list = session.createQuery("from B b where b.dynComp.b = ?")
- .setParameter(0, "b-b")
- .list();
-
- assertEquals(1, list.size());
- assertTrue(b.equals(list.get(0)));
-
- list = session.createQuery("from B b where b.dynComp.a = ?")
- .setParameter(0, "b-a")
- .list();
-
- assertEquals(1, list.size());
- assertTrue(b.equals(list.get(0)));
-
- list = session.createQuery("from C c where c.dynComp.c = ?")
- .setParameter(0, "c-c")
- .list();
-
- list = session.createQuery("from C c where c.dynComp.b = ?")
- .setParameter(0, "c-b")
- .list();
-
- list = session.createQuery("from C c where c.dynComp.a = ?")
- .setParameter(0, "c-a")
- .list();
-
- assertEquals(1, list.size());
- assertTrue(c.equals(list.get(0)));
-
- session.delete(c);
- session.delete(b);
- session.delete(a);
- session.close();
- }
-
- protected String[] getMappings() {
- return new String[] { "component/ABC.hbm.xml" };
- }
-
-}
Modified: trunk/Hibernate3/test/org/hibernate/test/compositeelement/CompositeElementTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/compositeelement/CompositeElementTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/compositeelement/CompositeElementTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,130 +1,90 @@
//$Id$
package org.hibernate.test.compositeelement;
+import java.util.ArrayList;
+
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.HibernateException;
-import org.hibernate.util.XMLHelper;
-import org.hibernate.util.StringHelper;
-import org.hibernate.util.CollectionHelper;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.cfg.HbmBinder;
-import org.hibernate.dialect.SybaseDialect;
-import org.hibernate.dialect.SQLServerDialect;
-import org.hibernate.test.TestCase;
-import org.xml.sax.InputSource;
-import org.dom4j.Element;
+import org.hibernate.cfg.Mappings;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.dialect.function.SQLFunction;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.mapping.Collection;
+import org.hibernate.mapping.Component;
+import org.hibernate.mapping.Formula;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Iterator;
-
/**
* @author Gavin King
*/
-public class CompositeElementTest extends TestCase {
+public class CompositeElementTest extends FunctionalTestCase {
public CompositeElementTest(String str) {
- super(str);
+ super( str );
}
- private boolean hasLengthFunction() {
- // neither support length() as a function, but each has len() which
- // is the same semantic
- return ! ( getDialect() instanceof SybaseDialect || getDialect() instanceof SQLServerDialect );
+ public String[] getMappings() {
+ return new String[] { "compositeelement/Parent.hbm.xml" };
}
- protected String[] getMappings() {
- return hasLengthFunction() ? new String[] { "compositeelement/Parent.hbm.xml" } : new String[0];
- }
+ public void afterConfigurationBuilt(Mappings mappings, Dialect dialect) {
+ super.afterConfigurationBuilt( mappings, dialect );
+ Collection children = mappings.getCollection( Parent.class.getName() + ".children" );
+ Component childComponents = ( Component ) children.getElement();
+ Formula f = ( Formula ) childComponents.getProperty( "bioLength" ).getValue().getColumnIterator().next();
- protected void configure(Configuration cfg) {
- super.configure( cfg );
- if ( !hasLengthFunction() ) {
- try {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- InputStream xmlInputStream = cl.getResourceAsStream( getBaseForMappings() + "compositeelement/Parent.hbm.xml" );
- XMLHelper xmlHelper = new XMLHelper();
- ArrayList errors = new ArrayList();
- org.dom4j.Document doc = xmlHelper.createSAXReader( "XML InputStream", errors, cfg.getEntityResolver() )
- .read( new InputSource( xmlInputStream ) );
-
- Element hmNode = doc.getRootElement();
- Iterator classNodes = hmNode.elementIterator( "class" );
- while ( classNodes.hasNext() ) {
- Element classNode = ( Element ) classNodes.next();
- if ( "Parent".equals( classNode.attributeValue( "name" ) ) ) {
- Iterator sets = classNode.elementIterator( "set" );
- while ( sets.hasNext() ) {
- Element set = ( Element ) sets.next();
- if ( "children".equals( set.attributeValue( "name" ) ) ) {
- Element component = set.element( "composite-element" );
- Iterator componentProperties = component.elementIterator( "property" );
- while ( componentProperties.hasNext() ) {
- Element property = ( Element ) componentProperties.next();
- if ( "bioLength".equals( property.attributeValue( "name" ) ) ) {
- String formula = property.attributeValue( "formula" );
- property.attribute( "formula" ).setValue( StringHelper.replace( formula, "length", "len" ) );
- }
- }
- }
- }
- }
- }
-
- // Whew! ;)
- HbmBinder.bindRoot( doc, cfg.createMappings(), CollectionHelper.EMPTY_MAP );
- }
- catch( Throwable t ) {
- throw new HibernateException( "Grrr" );
- }
+ SQLFunction lengthFunction = ( SQLFunction ) dialect.getFunctions().get( "length" );
+ if ( lengthFunction != null ) {
+ ArrayList args = new ArrayList();
+ args.add( "bio" );
+ f.setFormula( lengthFunction.render( args, null ) );
}
}
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( CompositeElementTest.class );
+ }
+
public void testHandSQL() {
Session s = openSession();
Transaction t = s.beginTransaction();
- Child c = new Child("Child One");
- Parent p = new Parent("Parent");
- p.getChildren().add(c);
- c.setParent(p);
- s.save(p);
+ Child c = new Child( "Child One" );
+ Parent p = new Parent( "Parent" );
+ p.getChildren().add( c );
+ c.setParent( p );
+ s.save( p );
s.flush();
- p.getChildren().remove(c);
- c.setParent(null);
+ p.getChildren().remove( c );
+ c.setParent( null );
s.flush();
- p.getChildren().add(c);
- c.setParent(p);
+ p.getChildren().add( c );
+ c.setParent( p );
t.commit();
s.close();
s = openSession();
t = s.beginTransaction();
- s.createQuery("select distinct p from Parent p join p.children c where c.name like 'Child%'").uniqueResult();
+ s.createQuery( "select distinct p from Parent p join p.children c where c.name like 'Child%'" ).uniqueResult();
s.clear();
- s.createQuery("select new Child(c.name) from Parent p left outer join p.children c where c.name like 'Child%'").uniqueResult();
+ s.createQuery( "select new Child(c.name) from Parent p left outer join p.children c where c.name like 'Child%'" )
+ .uniqueResult();
s.clear();
//s.createQuery("select c from Parent p left outer join p.children c where c.name like 'Child%'").uniqueResult(); //we really need to be able to do this!
s.clear();
- p = (Parent) s.createQuery("from Parent p left join fetch p.children").uniqueResult();
+ p = ( Parent ) s.createQuery( "from Parent p left join fetch p.children" ).uniqueResult();
t.commit();
s.close();
s = openSession();
t = s.beginTransaction();
- s.delete(p);
+ s.delete( p );
t.commit();
s.close();
}
- public static Test suite() {
- return new TestSuite(CompositeElementTest.class);
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/connections/AggressiveReleaseTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/connections/AggressiveReleaseTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/connections/AggressiveReleaseTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,27 +1,27 @@
// $Id$
package org.hibernate.test.connections;
-import org.hibernate.Session;
+import java.sql.Connection;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import junit.framework.Test;
+
import org.hibernate.ConnectionReleaseMode;
+import org.hibernate.Hibernate;
import org.hibernate.ScrollableResults;
-import org.hibernate.Hibernate;
-import org.hibernate.transaction.CMTTransactionFactory;
+import org.hibernate.Session;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
import org.hibernate.impl.SessionImpl;
-import org.hibernate.util.SerializationHelper;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.test.tm.DummyConnectionProvider;
+import org.hibernate.test.tm.DummyTransactionManager;
import org.hibernate.test.tm.DummyTransactionManagerLookup;
-import org.hibernate.test.tm.DummyTransactionManager;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.cfg.Environment;
+import org.hibernate.transaction.CMTTransactionFactory;
+import org.hibernate.util.SerializationHelper;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import java.sql.Connection;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Iterator;
-
/**
* Implementation of AggressiveReleaseTest.
*
@@ -34,10 +34,10 @@
}
public static Test suite() {
- return new TestSuite( AggressiveReleaseTest.class );
+ return new FunctionalTestClassTestSuite( AggressiveReleaseTest.class );
}
- protected void configure(Configuration cfg) {
+ public void configure(Configuration cfg) {
super.configure( cfg );
cfg.setProperty( Environment.RELEASE_CONNECTIONS, ConnectionReleaseMode.AFTER_STATEMENT.toString() );
cfg.setProperty( Environment.CONNECTION_PROVIDER, DummyConnectionProvider.class.getName() );
Modified: trunk/Hibernate3/test/org/hibernate/test/connections/BasicConnectionProviderTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/connections/BasicConnectionProviderTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/connections/BasicConnectionProviderTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,14 +1,14 @@
// $Id$
package org.hibernate.test.connections;
+import junit.framework.Test;
+
+import org.hibernate.ConnectionReleaseMode;
import org.hibernate.Session;
-import org.hibernate.ConnectionReleaseMode;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
/**
* Implementation of BasicConnectionProviderTest.
*
@@ -21,7 +21,7 @@
}
public static Test suite() {
- return new TestSuite( BasicConnectionProviderTest.class );
+ return new FunctionalTestClassTestSuite( BasicConnectionProviderTest.class );
}
protected Session getSessionUnderTest() {
@@ -32,7 +32,7 @@
session.reconnect();
}
- protected void configure(Configuration cfg) {
+ public void configure(Configuration cfg) {
super.configure( cfg );
cfg.setProperty( Environment.RELEASE_CONNECTIONS, ConnectionReleaseMode.ON_CLOSE.toString() );
}
Modified: trunk/Hibernate3/test/org/hibernate/test/connections/ConnectionManagementTestCase.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/connections/ConnectionManagementTestCase.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/connections/ConnectionManagementTestCase.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -4,6 +4,7 @@
import org.hibernate.test.TestCase;
import org.hibernate.Session;
import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestCase;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.util.SerializationHelper;
@@ -20,19 +21,16 @@
*
* @author Steve Ebersole
*/
-public abstract class ConnectionManagementTestCase extends TestCase {
+public abstract class ConnectionManagementTestCase extends FunctionalTestCase {
public ConnectionManagementTestCase(String name) {
super( name );
}
- protected final String[] getMappings() {
+ public final String[] getMappings() {
return new String[] { "connections/Silly.hbm.xml" };
}
- protected void configure(Configuration cfg) {
- super.configure( cfg );
- }
// hooks ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Modified: trunk/Hibernate3/test/org/hibernate/test/connections/ConnectionsSuite.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/connections/ConnectionsSuite.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/connections/ConnectionsSuite.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -13,10 +13,11 @@
public static Test suite() {
TestSuite suite = new TestSuite( "Connection-management tests");
+ suite.addTest( AggressiveReleaseTest.suite() );
suite.addTest( BasicConnectionProviderTest.suite() );
+ suite.addTest( CurrentSessionConnectionTest.suite() );
suite.addTest( SuppliedConnectionTest.suite() );
- suite.addTest( AggressiveReleaseTest.suite() );
- suite.addTest( CurrentSessionConnectionTest.suite() );
+ suite.addTest( ThreadLocalCurrentSessionTest.suite() );
return suite;
}
}
Modified: trunk/Hibernate3/test/org/hibernate/test/connections/CurrentSessionConnectionTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/connections/CurrentSessionConnectionTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/connections/CurrentSessionConnectionTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,10 +1,11 @@
// $Id$
package org.hibernate.test.connections;
-import org.hibernate.Session;
import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.Session;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+
/**
* Implementation of CurrentSessionConnectionTest.
*
@@ -17,7 +18,7 @@
}
public static Test suite() {
- return new TestSuite( CurrentSessionConnectionTest.class );
+ return new FunctionalTestClassTestSuite( CurrentSessionConnectionTest.class );
}
protected Session getSessionUnderTest() throws Throwable {
Modified: trunk/Hibernate3/test/org/hibernate/test/connections/SuppliedConnectionTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/connections/SuppliedConnectionTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/connections/SuppliedConnectionTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,21 +1,21 @@
// $Id$
package org.hibernate.test.connections;
+import java.sql.Connection;
+import java.sql.ResultSet;
+
+import junit.framework.Test;
+
+import org.hibernate.ConnectionReleaseMode;
+import org.hibernate.Session;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
-import org.hibernate.ConnectionReleaseMode;
-import org.hibernate.Session;
-import org.hibernate.tool.hbm2ddl.SchemaExport;
import org.hibernate.connection.ConnectionProvider;
import org.hibernate.connection.ConnectionProviderFactory;
import org.hibernate.connection.UserSuppliedConnectionProvider;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.tool.hbm2ddl.SchemaExport;
-import java.sql.Connection;
-import java.sql.ResultSet;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
/**
* Implementation of SuppliedConnectionTest.
*
@@ -31,7 +31,7 @@
}
public static Test suite() {
- return new TestSuite( SuppliedConnectionTest.class );
+ return new FunctionalTestClassTestSuite( SuppliedConnectionTest.class );
}
protected Session getSessionUnderTest() throws Throwable {
@@ -47,7 +47,7 @@
cp.closeConnection( connectionUnderTest );
}
- protected void configure(Configuration cfg) {
+ public void configure(Configuration cfg) {
super.configure( cfg );
cfg.setProperty( Environment.RELEASE_CONNECTIONS, ConnectionReleaseMode.ON_CLOSE.toString() );
cfg.setProperty( Environment.CONNECTION_PROVIDER, UserSuppliedConnectionProvider.class.getName() );
@@ -69,8 +69,8 @@
return false;
}
- protected void setUp() throws Exception {
- super.setUp();
+ protected void prepareTest() throws Exception {
+ super.prepareTest();
Connection conn = cp.getConnection();
try {
new SchemaExport( getCfg(), conn ).create( false, true );
@@ -86,7 +86,7 @@
}
}
- protected void tearDown() throws Exception {
+ protected void cleanupTest() throws Exception {
Connection conn = cp.getConnection();
try {
new SchemaExport( getCfg(), conn ).drop( false, true );
@@ -105,6 +105,6 @@
}
catch( Throwable ignore ) {
}
- super.tearDown();
+ super.cleanupTest();
}
}
Modified: trunk/Hibernate3/test/org/hibernate/test/connections/ThreadLocalCurrentSessionTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/connections/ThreadLocalCurrentSessionTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/connections/ThreadLocalCurrentSessionTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,14 +1,17 @@
package org.hibernate.test.connections;
+import junit.framework.Test;
+
+import org.hibernate.HibernateException;
import org.hibernate.Session;
-import org.hibernate.HibernateException;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.context.ThreadLocalSessionContext;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
+import org.hibernate.context.ThreadLocalSessionContext;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
- * @author <a href="mailto:steve@hibernate.org">Steve Ebersole </a>
+ * @author Steve Ebersole
*/
public class ThreadLocalCurrentSessionTest extends ConnectionManagementTestCase {
@@ -16,7 +19,11 @@
super( name );
}
- protected void configure(Configuration cfg) {
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( ThreadLocalCurrentSessionTest.class );
+ }
+
+ public void configure(Configuration cfg) {
super.configure( cfg );
cfg.setProperty( Environment.CURRENT_SESSION_CONTEXT_CLASS, TestableThreadLocalContext.class.getName() );
cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
@@ -56,7 +63,7 @@
session.createQuery( "from Silly" );
fail( "method other than beginTransaction{} allowed" );
}
- catch( HibernateException e ) {
+ catch ( HibernateException e ) {
// ok
}
}
@@ -77,14 +84,17 @@
public static class TestableThreadLocalContext extends ThreadLocalSessionContext {
private static TestableThreadLocalContext me;
+
public TestableThreadLocalContext(SessionFactoryImplementor factory) {
super( factory );
me = this;
}
+
public static boolean isSessionBound(Session session) {
return sessionMap() != null && sessionMap().containsKey( me.factory )
&& sessionMap().get( me.factory ) == session;
}
+
public static boolean hasBind() {
return sessionMap() != null && sessionMap().containsKey( me.factory );
}
Modified: trunk/Hibernate3/test/org/hibernate/test/criteria/CriteriaQueryTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/criteria/CriteriaQueryTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/criteria/CriteriaQueryTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -5,7 +5,6 @@
import java.util.Map;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Criteria;
import org.hibernate.FetchMode;
@@ -16,6 +15,7 @@
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.criterion.DetachedCriteria;
+import org.hibernate.criterion.Example;
import org.hibernate.criterion.Expression;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Order;
@@ -24,8 +24,8 @@
import org.hibernate.criterion.Property;
import org.hibernate.criterion.Restrictions;
import org.hibernate.criterion.Subqueries;
-import org.hibernate.criterion.Example;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.test.hql.Animal;
import org.hibernate.test.hql.Reptile;
import org.hibernate.transform.Transformers;
@@ -35,12 +35,28 @@
/**
* @author Gavin King
*/
-public class CriteriaQueryTest extends TestCase {
+public class CriteriaQueryTest extends FunctionalTestCase {
public CriteriaQueryTest(String str) {
super(str);
}
+ public String[] getMappings() {
+ return new String[] { "criteria/Enrolment.hbm.xml", "hql/Animal.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ super.configure( cfg );
+ cfg.setProperty( Environment.USE_QUERY_CACHE, "true" );
+ cfg.setProperty( Environment.CACHE_REGION_PREFIX, "criteriaquerytest" );
+ cfg.setProperty( Environment.USE_SECOND_LEVEL_CACHE, "true" );
+ cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( CriteriaQueryTest.class );
+ }
+
public void testEscapeCharacter() {
Session session = openSession();
Transaction t = session.beginTransaction();
@@ -780,21 +796,5 @@
t.commit();
session.close();
}
-
- protected String[] getMappings() {
- return new String[] { "criteria/Enrolment.hbm.xml", "hql/Animal.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(CriteriaQueryTest.class);
- }
-
- protected void configure(Configuration cfg) {
- super.configure( cfg );
- cfg.setProperty( Environment.USE_QUERY_CACHE, "true" );
- cfg.setProperty( Environment.CACHE_REGION_PREFIX, "criteriaquerytest" );
- cfg.setProperty( Environment.USE_SECOND_LEVEL_CACHE, "true" );
- cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
- }
}
Modified: trunk/Hibernate3/test/org/hibernate/test/cuk/CompositePropertyRefTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/cuk/CompositePropertyRefTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/cuk/CompositePropertyRefTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -5,23 +5,35 @@
import java.util.Set;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class CompositePropertyRefTest extends TestCase {
+public class CompositePropertyRefTest extends FunctionalTestCase {
public CompositePropertyRefTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "cuk/Person.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty(Environment.DEFAULT_BATCH_FETCH_SIZE, "1");
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( CompositePropertyRefTest.class );
+ }
public void testOneToOnePropertyRef() {
Session s = openSession();
@@ -101,24 +113,12 @@
l = s.createQuery("from Person p left join fetch p.address").list();
s.clear();
- ((org.hibernate.classic.Session)s).delete( "from Address" );
- ((org.hibernate.classic.Session)s).delete( "from Person" );
- ((org.hibernate.classic.Session)s).delete( "from Account" );
+ s.createQuery( "delete Address" ).executeUpdate();
+ s.createQuery( "delete Account" ).executeUpdate();
+ s.createQuery( "delete Person" ).executeUpdate();
t.commit();
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "cuk/Person.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(CompositePropertyRefTest.class);
- }
-
- protected void configure(Configuration cfg) {
- cfg.setProperty(Environment.DEFAULT_BATCH_FETCH_SIZE, "1");
- }
}
Modified: trunk/Hibernate3/test/org/hibernate/test/cuk/Person.hbm.xml
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/cuk/Person.hbm.xml 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/cuk/Person.hbm.xml 2006-12-12 23:28:04 UTC (rev 10977)
@@ -20,29 +20,19 @@
<hibernate-mapping package="org.hibernate.test.cuk">
<class name="Person">
-
<id name="id">
<generator class="hilo"/>
</id>
-
<property name="name" length="100"/>
-
- <one-to-one name="address"
- property-ref="person"
- cascade="all"
- fetch="join"/>
-
- <set name="accounts"
- inverse="true">
- <key property-ref="userIdAndDeleted">
+ <one-to-one name="address" property-ref="person" cascade="all" fetch="join"/>
+ <set name="accounts" inverse="true">
+ <key property-ref="userIdAndDeleted">
<column name="userId"/>
<column name="userDeleted"/>
</key>
<one-to-many class="Account"/>
</set>
-
- <properties name="userIdAndDeleted"
- update="false">
+ <properties name="userIdAndDeleted" update="false" unique="true">
<property name="userId" length="8"/>
<property name="deleted"/>
</properties>
@@ -50,32 +40,24 @@
</class>
<class name="Address">
-
- <id name="id">
+ <id name="id">
<generator class="hilo"/>
</id>
-
<property name="address" length="300"/>
<property name="zip" length="5"/>
<property name="country" length="25"/>
<many-to-one name="person" unique="true" not-null="true"/>
-
</class>
<class name="Account">
-
<id name="accountId" length="32">
<generator class="uuid.hex"/>
</id>
-
- <many-to-one name="user"
- property-ref="userIdAndDeleted">
+ <many-to-one name="user" property-ref="userIdAndDeleted">
<column name="userId"/>
<column name="userDeleted"/>
</many-to-one>
-
<property name="type" not-null="true"/>
-
</class>
</hibernate-mapping>
\ No newline at end of file
Modified: trunk/Hibernate3/test/org/hibernate/test/cut/CompositeUserTypeTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/cut/CompositeUserTypeTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/cut/CompositeUserTypeTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -6,21 +6,29 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Session;
import org.hibernate.dialect.HSQLDialect;
import org.hibernate.dialect.Oracle9Dialect;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class CompositeUserTypeTest extends TestCase {
+public class CompositeUserTypeTest extends FunctionalTestCase {
public CompositeUserTypeTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "cut/types.hbm.xml", "cut/Transaction.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( CompositeUserTypeTest.class );
+ }
public void testCompositeUserType() {
Session s = openSession();
@@ -51,14 +59,5 @@
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "cut/types.hbm.xml", "cut/Transaction.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(CompositeUserTypeTest.class);
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/deletetransient/DeleteTransientEntityTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/deletetransient/DeleteTransientEntityTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/deletetransient/DeleteTransientEntityTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,23 +1,30 @@
package org.hibernate.test.deletetransient;
-import org.hibernate.test.TestCase;
+import junit.framework.Test;
+
import org.hibernate.Session;
import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* todo: describe DeleteTransientEntityTest
*
* @author Steve Ebersole
*/
-public class DeleteTransientEntityTest extends TestCase {
+public class DeleteTransientEntityTest extends FunctionalTestCase {
public DeleteTransientEntityTest(String name) {
super( name );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "deletetransient/Person.hbm.xml" };
}
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( DeleteTransientEntityTest.class );
+ }
+
public void testTransientEntityDeletionNoCascades() {
Session s = openSession();
Transaction t = s.beginTransaction();
Modified: trunk/Hibernate3/test/org/hibernate/test/dialect/cache/SQLFunctionsInterSystemsTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/dialect/cache/SQLFunctionsInterSystemsTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/dialect/cache/SQLFunctionsInterSystemsTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -22,6 +22,7 @@
import org.hibernate.Transaction;
import org.hibernate.classic.Session;
import org.hibernate.dialect.Cache71Dialect;
+import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.HSQLDialect;
import org.hibernate.dialect.InterbaseDialect;
import org.hibernate.dialect.MckoiDialect;
@@ -29,21 +30,21 @@
import org.hibernate.dialect.Oracle9Dialect;
import org.hibernate.dialect.SybaseDialect;
import org.hibernate.dialect.TimesTenDialect;
-import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.function.SQLFunction;
-import org.hibernate.test.DatabaseSpecificTestCase;
+import org.hibernate.junit.functional.DatabaseSpecificFunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.test.legacy.Blobber;
+import org.hibernate.test.legacy.Broken;
+import org.hibernate.test.legacy.Fixed;
import org.hibernate.test.legacy.Simple;
import org.hibernate.test.legacy.Single;
-import org.hibernate.test.legacy.Broken;
-import org.hibernate.test.legacy.Fixed;
-import org.hibernate.test.legacy.Blobber;
/**
* Tests for function support on CacheSQL...
*
* @author Jonathan Levinson
*/
-public class SQLFunctionsInterSystemsTest extends DatabaseSpecificTestCase {
+public class SQLFunctionsInterSystemsTest extends DatabaseSpecificFunctionalTestCase {
private static final Log log = LogFactory.getLog(SQLFunctionsInterSystemsTest.class);
@@ -61,10 +62,9 @@
}
public static Test suite() {
- return new TestSuite(SQLFunctionsInterSystemsTest.class);
+ return new FunctionalTestClassTestSuite( SQLFunctionsInterSystemsTest.class );
}
-
public boolean appliesTo(Dialect dialect) {
// all these test case apply only to testing InterSystems' CacheSQL dialect
return dialect instanceof Cache71Dialect;
Modified: trunk/Hibernate3/test/org/hibernate/test/discriminator/DiscriminatorTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/discriminator/DiscriminatorTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/discriminator/DiscriminatorTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,28 +1,36 @@
//$Id$
package org.hibernate.test.discriminator;
+import java.math.BigDecimal;
import java.util.Iterator;
import java.util.List;
-import java.math.BigDecimal;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.criterion.Property;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class DiscriminatorTest extends TestCase {
+public class DiscriminatorTest extends FunctionalTestCase {
public DiscriminatorTest(String str) {
super(str);
}
+ public String[] getMappings() {
+ return new String[] { "discriminator/Person.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( DiscriminatorTest.class );
+ }
+
public void testDiscriminatorSubclass() {
Session s = openSession();
Transaction t = s.beginTransaction();
@@ -164,13 +172,5 @@
}
- protected String[] getMappings() {
- return new String[] { "discriminator/Person.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(DiscriminatorTest.class);
- }
-
}
Added: trunk/Hibernate3/test/org/hibernate/test/dynamicentity/DynamicEntitySuite.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/dynamicentity/DynamicEntitySuite.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/dynamicentity/DynamicEntitySuite.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,21 @@
+package org.hibernate.test.dynamicentity;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.hibernate.test.dynamicentity.interceptor.InterceptorDynamicEntityTest;
+import org.hibernate.test.dynamicentity.tuplizer.TuplizerDynamicEntityTest;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class DynamicEntitySuite {
+ public static Test suite() {
+ TestSuite suite = new TestSuite( "dynamic entity suite" );
+ suite.addTest( InterceptorDynamicEntityTest.suite() );
+ suite.addTest( TuplizerDynamicEntityTest.suite() );
+ return suite;
+ }
+}
Modified: trunk/Hibernate3/test/org/hibernate/test/dynamicentity/interceptor/InterceptorDynamicEntityTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/dynamicentity/interceptor/InterceptorDynamicEntityTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/dynamicentity/interceptor/InterceptorDynamicEntityTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,13 +1,15 @@
package org.hibernate.test.dynamicentity.interceptor;
-import org.hibernate.test.TestCase;
+import junit.framework.TestSuite;
+
+import org.hibernate.Hibernate;
+import org.hibernate.Session;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.test.dynamicentity.Company;
import org.hibernate.test.dynamicentity.Customer;
-import org.hibernate.test.dynamicentity.Company;
import org.hibernate.test.dynamicentity.ProxyHelper;
-import org.hibernate.Session;
-import org.hibernate.Hibernate;
-import org.hibernate.cfg.Configuration;
-import junit.framework.TestSuite;
/**
* Demonstrates custom interpretation of entity-name through
@@ -25,21 +27,21 @@
*
* @author Steve Ebersole
*/
-public class InterceptorDynamicEntityTest extends TestCase {
+public class InterceptorDynamicEntityTest extends FunctionalTestCase {
public InterceptorDynamicEntityTest(String x) {
super( x );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "dynamicentity/interceptor/Customer.hbm.xml" };
}
- public static TestSuite suite() {
- return new TestSuite( InterceptorDynamicEntityTest.class );
+ public void configure(Configuration cfg) {
+ cfg.setInterceptor( new ProxyInterceptor() );
}
- protected void configure(Configuration cfg) {
- cfg.setInterceptor( new ProxyInterceptor() );
+ public static TestSuite suite() {
+ return new FunctionalTestClassTestSuite( InterceptorDynamicEntityTest.class );
}
public void testIt() {
Modified: trunk/Hibernate3/test/org/hibernate/test/dynamicentity/tuplizer/TuplizerDynamicEntityTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/dynamicentity/tuplizer/TuplizerDynamicEntityTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/dynamicentity/tuplizer/TuplizerDynamicEntityTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -8,6 +8,10 @@
import org.hibernate.test.dynamicentity.Person;
import org.hibernate.Session;
import org.hibernate.Hibernate;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+
import junit.framework.TestSuite;
import java.util.HashSet;
@@ -21,24 +25,29 @@
* allow us to not have to explicitly supply the appropriate entity
* name to the Session calls.
*
- * @author <a href="mailto:steve@hibernate.org">Steve Ebersole </a>
+ * @author Steve Ebersole
*/
-public class TuplizerDynamicEntityTest extends TestCase {
+public class TuplizerDynamicEntityTest extends FunctionalTestCase {
public TuplizerDynamicEntityTest(String x) {
super( x );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "dynamicentity/tuplizer/Customer.hbm.xml" };
}
+ public void configure(Configuration cfg) {
+ super.configure( cfg );
+ cfg.setInterceptor( new EntityNameInterceptor() );
+ }
+
public static TestSuite suite() {
- return new TestSuite( TuplizerDynamicEntityTest.class );
+ return new FunctionalTestClassTestSuite( TuplizerDynamicEntityTest.class );
}
public void testIt() {
// Test saving these dyna-proxies
- Session session = openSession( new EntityNameInterceptor() );
+ Session session = openSession();
session.beginTransaction();
Company company = ProxyHelper.newCompanyProxy();
company.setName( "acme" );
@@ -69,7 +78,7 @@
assertNotNull( "wife:Person id not assigned", wife.getId() );
// Test loading these dyna-proxies, along with flush processing
- session = openSession( new EntityNameInterceptor() );
+ session = openSession();
session.beginTransaction();
customer = ( Customer ) session.load( Customer.class, customer.getId() );
assertFalse( "should-be-proxy was initialized", Hibernate.isInitialized( customer ) );
@@ -87,7 +96,7 @@
// Test detached entity re-attachment with these dyna-proxies
customer.setName( "Steve" );
- session = openSession( new EntityNameInterceptor() );
+ session = openSession();
session.beginTransaction();
session.update( customer );
session.flush();
@@ -97,7 +106,7 @@
session.close();
// Test querying
- session = openSession( new EntityNameInterceptor() );
+ session = openSession();
session.beginTransaction();
int count = session.createQuery( "from Customer" ).list().size();
assertEquals( "querying dynamic entity", 1, count );
@@ -108,7 +117,7 @@
session.close();
// test deleteing
- session = openSession( new EntityNameInterceptor() );
+ session = openSession();
session.beginTransaction();
session.delete( company );
session.delete( customer );
Modified: trunk/Hibernate3/test/org/hibernate/test/ecid/EmbeddedCompositeIdTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/ecid/EmbeddedCompositeIdTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/ecid/EmbeddedCompositeIdTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -4,22 +4,30 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.proxy.HibernateProxy;
-import org.hibernate.test.TestCase;
/**
* @author Gavin King
*/
-public class EmbeddedCompositeIdTest extends TestCase {
+public class EmbeddedCompositeIdTest extends FunctionalTestCase {
public EmbeddedCompositeIdTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "ecid/Course.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( EmbeddedCompositeIdTest.class );
+ }
public void testMerge() {
Session s = openSession();
@@ -150,14 +158,5 @@
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "ecid/Course.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(EmbeddedCompositeIdTest.class);
- }
-
}
Added: trunk/Hibernate3/test/org/hibernate/test/entitymode/EntityModeSuite.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/entitymode/EntityModeSuite.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/entitymode/EntityModeSuite.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,23 @@
+package org.hibernate.test.entitymode;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.hibernate.test.entitymode.dom4j.Dom4jSuite;
+import org.hibernate.test.entitymode.map.MapSuite;
+import org.hibernate.test.entitymode.multi.MultiRepresentationTest;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class EntityModeSuite {
+ public static Test suite() {
+ TestSuite suite = new TestSuite( "entity-mode tests" );
+ suite.addTest( Dom4jSuite.suite() );
+ suite.addTest( MapSuite.suite() );
+ suite.addTest( MultiRepresentationTest.suite() );
+ return suite;
+ }
+}
Added: trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/Dom4jSuite.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/Dom4jSuite.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/Dom4jSuite.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,23 @@
+package org.hibernate.test.entitymode.dom4j;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.hibernate.test.entitymode.dom4j.accessors.Dom4jAccessorTest;
+import org.hibernate.test.entitymode.dom4j.basic.Dom4jTest;
+import org.hibernate.test.entitymode.dom4j.many2one.Dom4jManyToOneTest;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class Dom4jSuite {
+ public static Test suite() {
+ TestSuite suite = new TestSuite( "dom4j entity-mode suite" );
+ suite.addTest( Dom4jAccessorTest.suite() );
+ suite.addTest( Dom4jTest.suite() );
+ suite.addTest( Dom4jManyToOneTest.suite() );
+ return suite;
+ }
+}
Copied: trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/accessors/Dom4jAccessorTest.java (from rev 10964, trunk/Hibernate3/test/org/hibernate/test/dom4j/Dom4jAccessorTest.java)
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/dom4j/Dom4jAccessorTest.java 2006-12-08 16:06:49 UTC (rev 10964)
+++ trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/accessors/Dom4jAccessorTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,157 @@
+// $Id$
+package org.hibernate.test.entitymode.dom4j.accessors;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import org.dom4j.DocumentFactory;
+import org.dom4j.Element;
+import org.dom4j.util.NodeComparator;
+
+import org.hibernate.EntityMode;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.mapping.Property;
+import org.hibernate.mapping.SimpleValue;
+import org.hibernate.property.Getter;
+import org.hibernate.property.PropertyAccessorFactory;
+import org.hibernate.property.Setter;
+
+/**
+ * Unit test of dom4j-based accessors
+ *
+ * @author Steve Ebersole
+ */
+public class Dom4jAccessorTest extends TestCase {
+
+ public static final Element DOM = generateTestElement();
+
+ public Dom4jAccessorTest(String name) {
+ super( name );
+ }
+
+ public void testStringElementExtraction() throws Throwable {
+ Property property = generateNameProperty();
+ Getter getter = PropertyAccessorFactory.getPropertyAccessor( property, EntityMode.DOM4J )
+ .getGetter( null, null );
+ String name = ( String ) getter.get( DOM );
+ assertEquals( "Not equals", "JBoss", name );
+ }
+
+ public void testStringTextExtraction() throws Throwable {
+ Property property = generateTextProperty();
+ Getter getter = PropertyAccessorFactory.getPropertyAccessor( property, EntityMode.DOM4J )
+ .getGetter( null, null );
+ String name = ( String ) getter.get( DOM );
+ assertEquals( "Not equals", "description...", name );
+ }
+
+ public void testLongAttributeExtraction() throws Throwable {
+ Property property = generateIdProperty();
+ Getter getter = PropertyAccessorFactory.getPropertyAccessor( property, EntityMode.DOM4J )
+ .getGetter( null, null );
+ Long id = ( Long ) getter.get( DOM );
+ assertEquals( "Not equals", new Long( 123 ), id );
+ }
+
+ public void testLongElementAttributeExtraction() throws Throwable {
+ Property property = generateAccountIdProperty();
+ Getter getter = PropertyAccessorFactory.getPropertyAccessor( property, EntityMode.DOM4J )
+ .getGetter( null, null );
+ Long id = ( Long ) getter.get( DOM );
+ assertEquals( "Not equals", new Long( 456 ), id );
+ }
+
+ public void testCompanyElementGeneration() throws Throwable {
+ Setter idSetter = PropertyAccessorFactory.getPropertyAccessor( generateIdProperty(), EntityMode.DOM4J )
+ .getSetter( null, null );
+ Setter nameSetter = PropertyAccessorFactory.getPropertyAccessor( generateNameProperty(), EntityMode.DOM4J )
+ .getSetter( null, null );
+ Setter textSetter = PropertyAccessorFactory.getPropertyAccessor( generateTextProperty(), EntityMode.DOM4J )
+ .getSetter( null, null );
+ Setter accountIdSetter = PropertyAccessorFactory.getPropertyAccessor(
+ generateAccountIdProperty(), EntityMode.DOM4J
+ )
+ .getSetter( null, null );
+
+ Element root = generateRootTestElement();
+
+ idSetter.set( root, new Long( 123 ), getSFI() );
+ textSetter.set( root, "description...", getSFI() );
+ nameSetter.set( root, "JBoss", getSFI() );
+ accountIdSetter.set( root, new Long( 456 ), getSFI() );
+
+ assertTrue( "DOMs not equal", new NodeComparator().compare( DOM, root ) == 0 );
+ }
+
+ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ private static Element generateTestElement() {
+ Element company = generateRootTestElement();
+ company.addAttribute( "id", "123" );
+ company.setText( "description..." );
+ company.addElement( "name" ).setText( "JBoss" );
+ company.addElement( "account" ).addAttribute( "num", "456" );
+
+ return company;
+ }
+
+ private static Element generateRootTestElement() {
+ return DocumentFactory.getInstance().createElement( "company" );
+ }
+
+ public static Test suite() {
+ return new TestSuite( Dom4jAccessorTest.class );
+ }
+
+ private SessionFactoryImplementor getSFI() {
+ return null;
+ }
+
+ private Property generateIdProperty() {
+ SimpleValue value = new SimpleValue();
+ value.setTypeName( "long" );
+
+ Property property = new Property();
+ property.setName( "id" );
+ property.setNodeName( "@id" );
+ property.setValue( value );
+
+ return property;
+ }
+
+ private Property generateTextProperty() {
+ SimpleValue value = new SimpleValue();
+ value.setTypeName( "string" );
+
+ Property property = new Property();
+ property.setName( "text" );
+ property.setNodeName( "." );
+ property.setValue( value );
+
+ return property;
+ }
+
+ private Property generateAccountIdProperty() {
+ SimpleValue value = new SimpleValue();
+ value.setTypeName( "long" );
+
+ Property property = new Property();
+ property.setName( "number" );
+ property.setNodeName( "account/@num" );
+ property.setValue( value );
+
+ return property;
+ }
+
+ private Property generateNameProperty() {
+ SimpleValue value = new SimpleValue();
+ value.setTypeName( "string" );
+
+ Property property = new Property();
+ property.setName( "name" );
+ property.setNodeName( "name" );
+ property.setValue( value );
+
+ return property;
+ }
+}
Property changes on: trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/accessors/Dom4jAccessorTest.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/basic/AB.hbm.xml (from rev 10964, trunk/Hibernate3/test/org/hibernate/test/dom4j/AB.hbm.xml)
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/dom4j/AB.hbm.xml 2006-12-08 16:06:49 UTC (rev 10964)
+++ trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/basic/AB.hbm.xml 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping >
+
+ <class entity-name="A" table="AX" node="a">
+ <id name="aId" type="int" column="aId" node="@id"/>
+ <property name="x" type="string"/>
+ <set name="bs" node="." embed-xml="true" cascade="all" inverse="true">
+ <key column="aId"/>
+ <one-to-many class="B"/>
+ </set>
+ </class>
+
+
+ <class entity-name="B" table="BX" node="b">
+ <composite-id>
+ <key-property name="bId" column="bId" type="int" node="@bId"/>
+ <key-property name="aId" column="aId" type="int" node="@aId"/>
+ </composite-id>
+ <property name="y" type="string" node="."/>
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Property changes on: trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/basic/AB.hbm.xml
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/basic/Account.hbm.xml (from rev 10964, trunk/Hibernate3/test/org/hibernate/test/dom4j/Account.hbm.xml)
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/dom4j/Account.hbm.xml 2006-12-08 16:06:49 UTC (rev 10964)
+++ trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/basic/Account.hbm.xml 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,51 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping>
+
+ <class entity-name="Customer" node="customer">
+ <id name="customerId" type="string" node="@id"/>
+ <component name="name">
+ <property name="first" type="string"/>
+ <property name="last" type="string"/>
+ </component>
+ <property name="address" type="string" node="address"/>
+ <map name="stuff">
+ <key column="customerId"/>
+ <map-key type="string" column="bar" node="@bar"/>
+ <element type="string" node="foo" column="foo"/>
+ </map>
+ <bag name="morestuff" node=".">
+ <key column="customerId"/>
+ <element type="integer" node="amount" column="amount"/>
+ </bag>
+ <list name="accounts" cascade="all">
+ <key column="customerId2"/>
+ <list-index column="acctno" base="1"/>
+ <one-to-many entity-name="Account" node="account"/>
+ </list>
+ <many-to-one name="location" node="location/@id" entity-name="Location" embed-xml="false"/>
+ <property name="description" node="." type="string"/>
+ <set name="unembedded" embed-xml="false">
+ <key column="x"/>
+ <element type="string" column="y" not-null="true"/>
+ </set>
+ </class>
+
+ <class entity-name="Account" node="account">
+ <id name="accountId" type="string" node="@id"/>
+ <many-to-one name="customer" column="customerId" entity-name="Customer" cascade="all" embed-xml="true" />
+ <!--not-null="true"-->
+ <property name="balance" type="big_decimal" node="balance" precision="10" scale="0" />
+ </class>
+
+ <class entity-name="Location" node="location">
+ <id name="id" node="@id" type="long">
+ <generator class="increment"/>
+ </id>
+ <property name="address" type="string"/>
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Property changes on: trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/basic/Account.hbm.xml
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/basic/Dom4jTest.java (from rev 10964, trunk/Hibernate3/test/org/hibernate/test/dom4j/Dom4jTest.java)
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/dom4j/Dom4jTest.java 2006-12-08 16:06:49 UTC (rev 10964)
+++ trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/basic/Dom4jTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,360 @@
+// $Id$
+package org.hibernate.test.entitymode.dom4j.basic;
+
+import java.util.Map;
+
+import junit.framework.Test;
+import org.dom4j.DocumentFactory;
+import org.dom4j.Element;
+
+import org.hibernate.EntityMode;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
+import org.hibernate.criterion.Example;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.transform.Transformers;
+import org.hibernate.util.XMLHelper;
+
+/**
+ * @author Gavin King
+ */
+public class Dom4jTest extends FunctionalTestCase {
+
+ public Dom4jTest(String str) {
+ super( str );
+ }
+
+ public String[] getMappings() {
+ return new String[] {
+ "entitymode/dom4j/basic/Account.hbm.xml",
+ "entitymode/dom4j/basic/AB.hbm.xml",
+ "entitymode/dom4j/basic/Employer.hbm.xml"
+ };
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty( Environment.DEFAULT_ENTITY_MODE, EntityMode.DOM4J.toString() );
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( Dom4jTest.class );
+ }
+
+// TODO : still need to figure out inheritence support within the DOM4J entity-mode
+//
+// public void testSubtyping() throws Exception {
+// Element employer = DocumentFactory.getInstance().createElement( "employer" );
+// employer.addAttribute( "name", "JBoss" );
+// Element gavin = employer.addElement( "techie" );
+// gavin.addAttribute( "name", "Gavin" );
+// Element ben = employer.addElement( "sales-dude" );
+// ben.addAttribute( "name", "Ben" );
+// print( employer );
+//
+// Session s = openSession();
+// Transaction t = s.beginTransaction();
+// s.persist( "Employer", employer );
+// Long eid = new Long( employer.attributeValue( "id" ) );
+// t.commit();
+// s.close();
+//
+// s = openSession();
+// t = s.beginTransaction();
+// employer = (Element) s.get( "Employer", eid );
+// print( employer );
+// s.delete( "Employer", employer );
+// t.commit();
+// s.close();
+//
+// Element dept = DocumentFactory.getInstance().createElement( "department" );
+// dept.addAttribute( "name", "engineering" );
+// Element steve = dept.addElement( "manager" ).addElement( "techie" );
+// steve.addAttribute( "name", "Steve" );
+// print( dept );
+//
+// s = openSession();
+// t = s.beginTransaction();
+// s.persist( "Department", dept );
+// Long did = new Long( dept.attributeValue( "id" ) );
+// t.commit();
+// s.close();
+//
+// s = openSession();
+// t = s.beginTransaction();
+// dept = ( Element ) s.load( "Department", did );
+// print( dept );
+// s.delete( "Department", dept );
+// t.commit();
+// s.close();
+// }
+
+ public void testCompositeId() throws Exception {
+ Element a = DocumentFactory.getInstance().createElement( "a" );
+ a.addAttribute("id", "1");
+ a.addElement("x").setText("foo bar");
+ //Element bs = a.addElement("bs");
+ Element b = a.addElement("b");
+ //b.addElement("bId").setText("1");
+ //b.addElement("aId").setText("1");
+ b.addAttribute("bId", "1");
+ b.addAttribute("aId", "1");
+ b.setText("foo foo");
+ b = a.addElement("b");
+ //b.addElement("bId").setText("2");
+ //b.addElement("aId").setText("1");
+ b.addAttribute("bId", "2");
+ b.addAttribute("aId", "1");
+ b.setText("bar bar");
+
+ Session s = openSession();
+ Transaction t = s.beginTransaction();
+ s.persist("A", a);
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ a = (Element) s.createCriteria("A").uniqueResult();
+ assertEquals( a.elements("b").size(), 2 );
+ print(a);
+ s.delete("A", a);
+ t.commit();
+ s.close();
+ }
+
+ public void testDom4j() throws Exception {
+ Element acct = DocumentFactory.getInstance().createElement( "account" );
+ acct.addAttribute( "id", "abc123" );
+ acct.addElement( "balance" ).setText( "123.45" );
+ Element cust = acct.addElement( "customer" );
+ cust.addAttribute( "id", "xyz123" );
+ Element foo1 = cust.addElement( "stuff" ).addElement( "foo" );
+ foo1.setText( "foo" );
+ foo1.addAttribute("bar", "x");
+ Element foo2 = cust.element( "stuff" ).addElement( "foo" );
+ foo2.setText( "bar" );
+ foo2.addAttribute("bar", "y");
+ cust.addElement( "amount" ).setText( "45" );
+ cust.setText( "An example customer" );
+ Element name = cust.addElement( "name" );
+ name.addElement( "first" ).setText( "Gavin" );
+ name.addElement( "last" ).setText( "King" );
+
+ Element loc = DocumentFactory.getInstance().createElement( "location" );
+ loc.addElement( "address" ).setText( "Karbarook Avenue" );
+
+ print( acct );
+
+ Session s = openSession();
+ Transaction t = s.beginTransaction();
+ s.persist( "Location", loc );
+ cust.addElement( "location" ).addAttribute( "id", loc.attributeValue( "id" ) );
+ s.persist( "Account", acct );
+ t.commit();
+ s.close();
+
+ print( loc );
+
+ s = openSession();
+ t = s.beginTransaction();
+ cust = (Element) s.get( "Customer", "xyz123" );
+ print( cust );
+ acct = (Element) s.get( "Account", "abc123" );
+ print( acct );
+ assertEquals( acct.element( "customer" ), cust );
+ cust.element( "name" ).element( "first" ).setText( "Gavin A" );
+ Element foo3 = cust.element("stuff").addElement("foo");
+ foo3.setText("baz");
+ foo3.addAttribute("bar", "z");
+ cust.element("amount").setText("3");
+ cust.addElement("amount").setText("56");
+ t.commit();
+ s.close();
+
+ System.out.println();
+
+ acct.element( "balance" ).setText( "3456.12" );
+ cust.addElement( "address" ).setText( "Karbarook Ave" );
+
+ assertEquals( acct.element( "customer" ), cust );
+
+ cust.setText( "Still the same example!" );
+
+ s = openSession();
+ t = s.beginTransaction();
+ s.saveOrUpdate( "Account", acct );
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ cust = (Element) s.get( "Customer", "xyz123" );
+ print( cust );
+ acct = (Element) s.get( "Account", "abc123" );
+ print( acct );
+ assertEquals( acct.element( "customer" ), cust );
+ t.commit();
+ s.close();
+
+ System.out.println();
+
+ s = openSession();
+ t = s.beginTransaction();
+ cust = (Element) s.createCriteria( "Customer" )
+ .add( Example.create( cust ) )
+ .uniqueResult();
+ print( cust );
+ t.commit();
+ s.close();
+
+ System.out.println();
+
+ s = openSession();
+ t = s.beginTransaction();
+ acct = (Element) s.createQuery( "from Account a left join fetch a.customer" )
+ .uniqueResult();
+ print( acct );
+ t.commit();
+ s.close();
+
+ System.out.println();
+
+ s = openSession();
+ t = s.beginTransaction();
+ Map m = (Map) s.createQuery( "select a as acc from Account a left join fetch a.customer" )
+ .setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP).uniqueResult();
+ acct = (Element)m.get("acc");
+ print( acct );
+ t.commit();
+ s.close();
+
+ System.out.println();
+
+ s = openSession();
+ t = s.beginTransaction();
+ acct = (Element) s.createQuery( "from Account" ).uniqueResult();
+ print( acct );
+ t.commit();
+ s.close();
+
+ System.out.println();
+
+ s = openSession();
+ t = s.beginTransaction();
+ cust = (Element) s.createQuery( "from Customer c left join fetch c.stuff" ).uniqueResult();
+ print( cust );
+ t.commit();
+ s.close();
+
+ System.out.println();
+
+ s = openSession();
+ t = s.beginTransaction();
+ cust = (Element) s.createQuery( "from Customer c left join fetch c.morestuff" ).uniqueResult();
+ print( cust );
+ t.commit();
+ s.close();
+
+ System.out.println();
+
+ s = openSession();
+ t = s.beginTransaction();
+ cust = (Element) s.createQuery( "from Customer c left join fetch c.morestuff" ).uniqueResult();
+ print( cust );
+ cust = (Element) s.createQuery( "from Customer c left join fetch c.stuff" ).uniqueResult();
+ print( cust );
+ t.commit();
+ s.close();
+
+ System.out.println();
+
+ s = openSession();
+ t = s.beginTransaction();
+ cust = (Element) s.createQuery( "from Customer c left join fetch c.accounts" ).uniqueResult();
+ Element a1 = cust.element( "accounts" ).addElement( "account" );
+ a1.addElement( "balance" ).setText( "12.67" );
+ a1.addAttribute( "id", "lkj345" );
+ a1.addAttribute("acnum", "0");
+ Element a2 = cust.element( "accounts" ).addElement( "account" );
+ a2.addElement( "balance" ).setText( "10000.00" );
+ a2.addAttribute( "id", "hsh987" );
+ a2.addAttribute("acnum", "1");
+ print( cust );
+ t.commit();
+ s.close();
+
+ System.out.println();
+
+ s = openSession();
+ t = s.beginTransaction();
+ cust = (Element) s.createQuery( "from Customer c left join fetch c.accounts" ).uniqueResult();
+ print( cust );
+ t.commit();
+ s.close();
+
+ // clean up
+ s = openSession();
+ t = s.beginTransaction();
+ s.delete( "Account", acct );
+ s.delete( "Location", loc );
+ s.createQuery( "delete from Account" ).executeUpdate();
+ t.commit();
+ s.close();
+ }
+
+ public void testMapIndexEmision() throws Throwable {
+ Element acct = DocumentFactory.getInstance().createElement( "account" );
+ acct.addAttribute( "id", "abc123" );
+ acct.addElement( "balance" ).setText( "123.45" );
+ Element cust = acct.addElement( "customer" );
+ cust.addAttribute( "id", "xyz123" );
+ Element foo1 = cust.addElement( "stuff" ).addElement( "foo" );
+ foo1.setText( "foo" );
+ foo1.addAttribute("bar", "x");
+ Element foo2 = cust.element( "stuff" ).addElement( "foo" );
+ foo2.setText( "bar" );
+ foo2.addAttribute("bar", "y");
+ cust.addElement( "amount" ).setText( "45" );
+ cust.setText( "An example customer" );
+ Element name = cust.addElement( "name" );
+ name.addElement( "first" ).setText( "Gavin" );
+ name.addElement( "last" ).setText( "King" );
+
+ print( acct );
+
+ Element loc = DocumentFactory.getInstance().createElement( "location" );
+ loc.addElement( "address" ).setText( "Karbarook Avenue" );
+
+ Session s = openSession();
+ Transaction t = s.beginTransaction();
+ s.persist( "Location", loc );
+ cust.addElement( "location" ).addAttribute( "id", loc.attributeValue( "id" ) );
+ s.persist( "Account", acct );
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ cust = ( Element ) s.get( "Customer", "xyz123" );
+ print( cust );
+ assertEquals( "Incorrect stuff-map size", 2, cust.element( "stuff" ).elements( "foo" ).size() );
+ Element stuffElement = ( Element ) cust.element( "stuff" ).elements( "foo" ).get( 0 );
+ assertNotNull( "No map-key value present", stuffElement.attribute( "bar" ) );
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ s.delete( "Account", acct );
+ s.delete( "Location", loc );
+ t.commit();
+ s.close();
+ }
+
+ public static void print(Element elt) throws Exception {
+ XMLHelper.dump( elt );
+ }
+}
Property changes on: trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/basic/Dom4jTest.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/basic/Employer.hbm.xml (from rev 10964, trunk/Hibernate3/test/org/hibernate/test/dom4j/Employer.hbm.xml)
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/dom4j/Employer.hbm.xml 2006-12-08 16:06:49 UTC (rev 10964)
+++ trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/basic/Employer.hbm.xml 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,36 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<hibernate-mapping>
+
+ <class entity-name="Employer" node="employer">
+ <id name="id" node="@id" type="long">
+ <generator class="increment"/>
+ </id>
+ <property name="name" node="@name" type="string"/>
+ <set name="employees" node="." cascade="all,delete-orphan" fetch="join" lazy="false">
+ <key not-null="true" column="employerId"/>
+ <one-to-many entity-name="Employee" />
+ </set>
+ </class>
+
+ <class entity-name="Employee" node="employee">
+ <id name="id" node="@id" type="long">
+ <generator class="increment"/>
+ </id>
+ <discriminator column="role" type="string" length="10"/>
+ <property name="name" node="@name" type="string"/>
+ <subclass entity-name="Techie" node="techie" />
+ <subclass entity-name="Salesdude" node="sales-dude"/>
+ </class>
+
+ <class entity-name="Department" node="department">
+ <id name="id" node="@id" type="long">
+ <generator class="increment"/>
+ </id>
+ <property name="name" node="@name" type="string"/>
+ <many-to-one name="manager" entity-name="Employee" cascade="all" fetch="join" lazy="false" embed-xml="true" node="manager" />
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Property changes on: trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/basic/Employer.hbm.xml
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/many2one/Car.hbm.xml (from rev 10964, trunk/Hibernate3/test/org/hibernate/test/dom4j/Car.hbm.xml)
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/dom4j/Car.hbm.xml 2006-12-08 16:06:49 UTC (rev 10964)
+++ trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/many2one/Car.hbm.xml 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,34 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="org.hibernate.test.entitymode.dom4j.many2one">
+
+ <class name="Car" lazy="false" node="car">
+ <id name="id" node="@id" type="long">
+ <generator class="increment"/>
+ </id>
+ <property name="model" type="string" node="model"/>
+ <many-to-one name="carType" node="carType" class="CarType"/>
+ <set name="carParts" node="." cascade="all">
+ <key column="car" not-null="true"/>
+ <one-to-many class="CarPart" node="carPart" embed-xml="false"/>
+ </set>
+ </class>
+
+ <class name="CarType" lazy="true" node="carType">
+ <id name="id" node="@id" type="long">
+ <generator class="increment"/>
+ </id>
+ <property name="typeName" type="string" node="typeName"/>
+ </class>
+
+ <class name="CarPart" node="carPart">
+ <id name="id" node="@id" type="long">
+ <generator class="increment"/>
+ </id>
+ <property name="partName" type="string" node="partName"/>
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Property changes on: trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/many2one/Car.hbm.xml
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/many2one/Car.java (from rev 10964, trunk/Hibernate3/test/org/hibernate/test/dom4j/Car.java)
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/dom4j/Car.java 2006-12-08 16:06:49 UTC (rev 10964)
+++ trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/many2one/Car.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,58 @@
+package org.hibernate.test.entitymode.dom4j.many2one;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author Paco Hern�ndez
+ */
+public class Car implements java.io.Serializable {
+
+ private long id;
+ private String model;
+ private CarType carType;
+ private Set carParts = new HashSet();
+
+ /**
+ * @return Returns the carType.
+ */
+ public CarType getCarType() {
+ return carType;
+ }
+ /**
+ * @param carType The carType to set.
+ */
+ public void setCarType(CarType carType) {
+ this.carType = carType;
+ }
+ /**
+ * @return Returns the id.
+ */
+ public long getId() {
+ return id;
+ }
+ /**
+ * @param id The id to set.
+ */
+ public void setId(long id) {
+ this.id = id;
+ }
+ /**
+ * @return Returns the model.
+ */
+ public String getModel() {
+ return model;
+ }
+ /**
+ * @param model The model to set.
+ */
+ public void setModel(String model) {
+ this.model = model;
+ }
+ public Set getCarParts() {
+ return carParts;
+ }
+ public void setCarParts(Set carParts) {
+ this.carParts = carParts;
+ }
+}
Property changes on: trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/many2one/Car.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/many2one/CarPart.java (from rev 10964, trunk/Hibernate3/test/org/hibernate/test/dom4j/CarPart.java)
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/dom4j/CarPart.java 2006-12-08 16:06:49 UTC (rev 10964)
+++ trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/many2one/CarPart.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,35 @@
+package org.hibernate.test.entitymode.dom4j.many2one;
+
+/**
+ * @author Paco Hern�ndez
+ */
+public class CarPart implements java.io.Serializable {
+
+ private long id;
+ private String partName;
+
+ /**
+ * @return Returns the id.
+ */
+ public long getId() {
+ return id;
+ }
+ /**
+ * @param id The id to set.
+ */
+ public void setId(long id) {
+ this.id = id;
+ }
+ /**
+ * @return Returns the typeName.
+ */
+ public String getPartName() {
+ return partName;
+ }
+ /**
+ * @param typeName The typeName to set.
+ */
+ public void setPartName(String typeName) {
+ this.partName = typeName;
+ }
+}
Property changes on: trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/many2one/CarPart.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/many2one/CarType.java (from rev 10964, trunk/Hibernate3/test/org/hibernate/test/dom4j/CarType.java)
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/dom4j/CarType.java 2006-12-08 16:06:49 UTC (rev 10964)
+++ trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/many2one/CarType.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,35 @@
+package org.hibernate.test.entitymode.dom4j.many2one;
+
+/**
+ * @author Paco Hern�ndez
+ */
+public class CarType implements java.io.Serializable {
+
+ private long id;
+ private String typeName;
+
+ /**
+ * @return Returns the id.
+ */
+ public long getId() {
+ return id;
+ }
+ /**
+ * @param id The id to set.
+ */
+ public void setId(long id) {
+ this.id = id;
+ }
+ /**
+ * @return Returns the typeName.
+ */
+ public String getTypeName() {
+ return typeName;
+ }
+ /**
+ * @param typeName The typeName to set.
+ */
+ public void setTypeName(String typeName) {
+ this.typeName = typeName;
+ }
+}
Property changes on: trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/many2one/CarType.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/many2one/Dom4jManyToOneTest.java (from rev 10964, trunk/Hibernate3/test/org/hibernate/test/dom4j/Dom4jManyToOneTest.java)
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/dom4j/Dom4jManyToOneTest.java 2006-12-08 16:06:49 UTC (rev 10964)
+++ trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/many2one/Dom4jManyToOneTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,141 @@
+package org.hibernate.test.entitymode.dom4j.many2one;
+
+import java.util.List;
+
+import junit.framework.Test;
+import org.dom4j.Element;
+import org.dom4j.io.OutputFormat;
+import org.dom4j.io.XMLWriter;
+
+import org.hibernate.EntityMode;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+
+/**
+ * @author Paco Hern�ndez
+ */
+public class Dom4jManyToOneTest extends FunctionalTestCase {
+
+ public Dom4jManyToOneTest(String str) {
+ super( str );
+ }
+
+ public String[] getMappings() {
+ return new String[] { "entitymode/dom4j/many2one/Car.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( Dom4jManyToOneTest.class );
+ }
+
+ public void testDom4jOneToMany() throws Exception {
+ Session s = openSession();
+ Transaction t = s.beginTransaction();
+
+ CarType carType = new CarType();
+ carType.setTypeName("Type 1");
+ s.save(carType);
+
+ Car car = new Car();
+ car.setCarType(carType);
+ car.setModel("Model 1");
+ s.save(car);
+
+ CarPart carPart1 = new CarPart();
+ carPart1.setPartName("chassis");
+ car.getCarParts().add(carPart1);
+
+ t.commit();
+ s.close();
+
+ s = openSession();
+ Session dom4jSession = s.getSession( EntityMode.DOM4J );
+ t = s.beginTransaction();
+
+ Element element = (Element) dom4jSession.createQuery( "from Car c join fetch c.carParts" ).uniqueResult();
+
+ String expectedResult = "<car id=\"" +
+ car.getId() +
+ "\"><carPart>" +
+ carPart1.getId() +
+ "</carPart><model>Model 1</model><carType id=\"" +
+ carType.getId() +
+ "\"><typeName>Type 1</typeName></carType></car>";
+
+ print(element);
+ assertTrue(element.asXML().equals(expectedResult));
+
+ s.createQuery("delete from CarPart").executeUpdate();
+ s.createQuery("delete from Car").executeUpdate();
+ s.createQuery("delete from CarType").executeUpdate();
+
+ t.commit();
+ s.close();
+ }
+
+ public void testDom4jManyToOne() throws Exception {
+
+ Session s = openSession();
+ Transaction t = s.beginTransaction();
+
+ CarType carType = new CarType();
+ carType.setTypeName("Type 1");
+ s.save(carType);
+
+ Car car1 = new Car();
+ car1.setCarType(carType);
+ car1.setModel("Model 1");
+ s.save(car1);
+
+ Car car2 = new Car();
+ car2.setCarType(carType);
+ car2.setModel("Model 2");
+ s.save(car2);
+
+ t.commit();
+ s.close();
+
+ s = openSession();
+ Session dom4jSession = s.getSession( EntityMode.DOM4J );
+ t = s.beginTransaction();
+
+ List list = dom4jSession.createQuery( "from Car c join fetch c.carType order by c.model asc" ).list();
+
+ String[] expectedResults = new String[] {
+ "<car id=\"" +
+ car1.getId() +
+ "\"><model>Model 1</model><carType id=\"" +
+ carType.getId() +
+ "\"><typeName>Type 1</typeName></carType></car>",
+ "<car id=\"" +
+ car2.getId() +
+ "\"><model>Model 2</model><carType id=\"" +
+ carType.getId() +
+ "\"><typeName>Type 1</typeName></carType></car>"
+ };
+
+ for (int i = 0; i < list.size(); i++) {
+ Element element = (Element) list.get(i);
+
+ print(element);
+ assertTrue(element.asXML().equals(expectedResults[i]));
+ }
+
+ s.createQuery("delete from Car").executeUpdate();
+ s.createQuery("delete from CarType").executeUpdate();
+
+ t.commit();
+ s.close();
+ }
+
+ public static void print(Element elt) throws Exception {
+ OutputFormat outformat = OutputFormat.createPrettyPrint();
+ // outformat.setEncoding(aEncodingScheme);
+ XMLWriter writer = new XMLWriter( System.out, outformat );
+ writer.write( elt );
+ writer.flush();
+ // System.out.println( elt.asXML() );
+ }
+}
Property changes on: trunk/Hibernate3/test/org/hibernate/test/entitymode/dom4j/many2one/Dom4jManyToOneTest.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: trunk/Hibernate3/test/org/hibernate/test/entitymode/map/MapSuite.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/entitymode/map/MapSuite.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/entitymode/map/MapSuite.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,19 @@
+package org.hibernate.test.entitymode.map;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.hibernate.test.entitymode.map.basic.DynamicClassTest;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class MapSuite {
+ public static Test suite() {
+ TestSuite suite = new TestSuite( "map entity-mode suite");
+ suite.addTest( DynamicClassTest.suite() );
+ return suite;
+ }
+}
Copied: trunk/Hibernate3/test/org/hibernate/test/entitymode/map/basic/DynamicClassTest.java (from rev 10964, trunk/Hibernate3/test/org/hibernate/test/dynamic/DynamicClassTest.java)
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/dynamic/DynamicClassTest.java 2006-12-08 16:06:49 UTC (rev 10964)
+++ trunk/Hibernate3/test/org/hibernate/test/entitymode/map/basic/DynamicClassTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,109 @@
+//$Id$
+package org.hibernate.test.entitymode.map.basic;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.Test;
+
+import org.hibernate.EntityMode;
+import org.hibernate.Hibernate;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+
+/**
+ * @author Gavin King
+ */
+public class DynamicClassTest extends FunctionalTestCase {
+
+ public DynamicClassTest(String str) {
+ super(str);
+ }
+
+ public String[] getMappings() {
+ return new String[] { "entitymode/map/basic/ProductLine.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty(Environment.DEFAULT_ENTITY_MODE, EntityMode.MAP.toString());
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( DynamicClassTest.class );
+ }
+
+ public void testLazyDynamicClass() {
+ Session s = openSession();
+ assertTrue( "Incorrectly handled default_entity_mode", s.getEntityMode() == EntityMode.MAP );
+ Session other = s.getSession( EntityMode.MAP );
+ assertEquals( "openSession() using same entity-mode returned new session", s, other );
+
+ other = s.getSession( EntityMode.POJO );
+ other.close();
+ assertTrue( !other.isOpen() );
+// this is no longer allowed since the session does much more up-front closed checking
+// assertTrue( other.isConnected() ); // because it is linked to the "root" session's connection
+
+ s.close();
+
+ s = openSession();
+ Transaction t = s.beginTransaction();
+
+ Map cars = new HashMap();
+ cars.put("description", "Cars");
+ Map monaro = new HashMap();
+ monaro.put("productLine", cars);
+ monaro.put("name", "monaro");
+ monaro.put("description", "Holden Monaro");
+ Map hsv = new HashMap();
+ hsv.put("productLine", cars);
+ hsv.put("name", "hsv");
+ hsv.put("description", "Holden Commodore HSV");
+ List models = new ArrayList();
+ cars.put("models", models);
+ models.add(hsv);
+ models.add(monaro);
+ s.save("ProductLine", cars);
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+
+ cars = (Map) s.createQuery("from ProductLine pl order by pl.description").uniqueResult();
+ models = (List) cars.get("models");
+ assertFalse( Hibernate.isInitialized(models) );
+ assertEquals( models.size(), 2);
+ assertTrue( Hibernate.isInitialized(models) );
+
+ s.clear();
+
+ List list = s.createQuery("from Model m").list();
+ for ( Iterator i=list.iterator(); i.hasNext(); ) {
+ assertFalse( Hibernate.isInitialized( ( (Map) i.next() ).get("productLine") ) );
+ }
+ Map model = (Map) list.get(0);
+ assertTrue( ( (List) ( (Map) model.get("productLine") ).get("models") ).contains(model) );
+ s.clear();
+
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ cars = (Map) s.createQuery("from ProductLine pl order by pl.description").uniqueResult();
+ s.delete(cars);
+ t.commit();
+ s.close();
+ }
+
+
+}
+
Property changes on: trunk/Hibernate3/test/org/hibernate/test/entitymode/map/basic/DynamicClassTest.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/Hibernate3/test/org/hibernate/test/entitymode/map/basic/ProductLine.hbm.xml (from rev 10964, trunk/Hibernate3/test/org/hibernate/test/dynamic/ProductLine.hbm.xml)
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/dynamic/ProductLine.hbm.xml 2006-12-08 16:06:49 UTC (rev 10964)
+++ trunk/Hibernate3/test/org/hibernate/test/entitymode/map/basic/ProductLine.hbm.xml 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,38 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping>
+
+<!--
+ This mapping demonstrates "dynamic" entities.
+-->
+
+ <class entity-name="ProductLine">
+ <id name="id" column="productId" length="32" type="string">
+ <generator class="uuid.hex"/>
+ </id>
+
+ <property name="description" not-null="true" length="200" type="string"/>
+
+ <!-- don't use sets for associations, unless you want stack overflows! -->
+ <bag name="models" cascade="all" inverse="true">
+ <key column="productId"/>
+ <one-to-many class="Model"/>
+ </bag>
+
+ </class>
+
+ <class entity-name="Model">
+ <id name="id" column="modelId" length="32" type="string">
+ <generator class="uuid.hex"/>
+ </id>
+
+ <property name="name" not-null="true" length="25" type="string"/>
+ <property name="description" not-null="true" length="200" type="string"/>
+ <many-to-one name="productLine" column="productId" not-null="true" class="ProductLine"/>
+
+ </class>
+
+</hibernate-mapping>
Property changes on: trunk/Hibernate3/test/org/hibernate/test/entitymode/map/basic/ProductLine.hbm.xml
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/Hibernate3/test/org/hibernate/test/entitymode/multi/MultiRepresentationTest.java (from rev 10964, trunk/Hibernate3/test/org/hibernate/test/entity/MultiRepresentationTest.java)
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/entity/MultiRepresentationTest.java 2006-12-08 16:06:49 UTC (rev 10964)
+++ trunk/Hibernate3/test/org/hibernate/test/entitymode/multi/MultiRepresentationTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,194 @@
+// $Id$
+package org.hibernate.test.entitymode.multi;
+
+import java.sql.Date;
+import java.util.Iterator;
+import java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.dom4j.DocumentFactory;
+import org.dom4j.Element;
+import org.dom4j.io.OutputFormat;
+import org.dom4j.io.XMLWriter;
+
+import org.hibernate.EntityMode;
+import org.hibernate.Transaction;
+import org.hibernate.classic.Session;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+
+/**
+ * Implementation of MultiRepresentationTest.
+ *
+ * @author Steve Ebersole
+ */
+public class MultiRepresentationTest extends FunctionalTestCase {
+
+
+ public MultiRepresentationTest(String name) {
+ super( name );
+ }
+
+ public String[] getMappings() {
+ return new String[] { "entitymode/multi/Stock.hbm.xml", "entitymode/multi/Valuation.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( MultiRepresentationTest.class );
+ }
+
+ public void testPojoRetreival() {
+ TestData testData = new TestData();
+ testData.create();
+
+ Session session = openSession();
+ Transaction txn = session.beginTransaction();
+
+ Stock stock = ( Stock ) session.get( Stock.class, new Long( 1 ) );
+ assertEquals( "Something wrong!", new Long( 1 ), stock.getId() );
+
+ txn.commit();
+ session.close();
+
+ testData.destroy();
+ }
+
+ public void testDom4jRetreival() {
+ TestData testData = new TestData();
+ testData.create();
+
+ Session session = openSession();
+ Transaction txn = session.beginTransaction();
+ org.hibernate.Session dom4j = session.getSession( EntityMode.DOM4J );
+
+ Object rtn = dom4j.get( Stock.class.getName(), testData.stockId );
+ Element element = ( Element ) rtn;
+
+ assertEquals( "Something wrong!", testData.stockId, Long.valueOf( element.attributeValue( "id" ) ) );
+
+ System.out.println( "**** XML: ****************************************************" );
+ prettyPrint( element );
+ System.out.println( "**************************************************************" );
+
+ Element currVal = element.element( "currentValuation" );
+
+ System.out.println( "**** XML: ****************************************************" );
+ prettyPrint( currVal );
+ System.out.println( "**************************************************************" );
+
+ txn.rollback();
+ session.close();
+
+ testData.destroy();
+ }
+
+ public void testDom4jSave() {
+ TestData testData = new TestData();
+ testData.create();
+
+ Session pojos = openSession();
+ Transaction txn = pojos.beginTransaction();
+ org.hibernate.Session dom4j = pojos.getSession( EntityMode.DOM4J );
+
+ Element stock = DocumentFactory.getInstance().createElement( "stock" );
+ stock.addElement( "tradeSymbol" ).setText( "IBM" );
+
+ Element val = stock.addElement( "currentValuation" ).addElement( "valuation" );
+ val.appendContent( stock );
+ val.addElement( "valuationDate" ).setText( new java.util.Date().toString() );
+ val.addElement( "value" ).setText( "121.00" );
+
+ dom4j.save( Stock.class.getName(), stock );
+ dom4j.flush();
+
+ txn.rollback();
+ pojos.close();
+
+ assertTrue( !pojos.isOpen() );
+ assertTrue( !dom4j.isOpen() );
+
+ prettyPrint( stock );
+
+ testData.destroy();
+ }
+
+ public void testDom4jHQL() {
+ TestData testData = new TestData();
+ testData.create();
+
+ Session session = openSession();
+ Transaction txn = session.beginTransaction();
+ org.hibernate.Session dom4j = session.getSession( EntityMode.DOM4J );
+
+ List result = dom4j.createQuery( "from Stock" ).list();
+
+ assertEquals( "Incorrect result size", 1, result.size() );
+ Element element = ( Element ) result.get( 0 );
+ assertEquals( "Something wrong!", testData.stockId, Long.valueOf( element.attributeValue( "id" ) ) );
+
+ System.out.println( "**** XML: ****************************************************" );
+ prettyPrint( element );
+ System.out.println( "**************************************************************" );
+
+ txn.rollback();
+ session.close();
+
+ testData.destroy();
+ }
+
+ private class TestData {
+ private Long stockId;
+
+ private void create() {
+ Session session = getSessions().openSession();
+ session.beginTransaction();
+ Stock stock = new Stock();
+ stock.setTradeSymbol( "JBOSS" );
+ Valuation valuation = new Valuation();
+ valuation.setStock( stock );
+ valuation.setValuationDate( new Date( new java.util.Date().getTime() ) );
+ valuation.setValue( new Double( 200.0 ) );
+ stock.setCurrentValuation( valuation );
+ stock.getValuations().add( valuation );
+
+ session.save( stock );
+ session.save( valuation );
+
+ session.getTransaction().commit();
+ session.close();
+
+ stockId = stock.getId();
+ }
+
+ private void destroy() {
+ Session session = getSessions().openSession();
+ session.beginTransaction();
+ Iterator stocks = session.createQuery( "from Stock" ).list().iterator();
+ while ( stocks.hasNext() ) {
+ final Stock stock = ( Stock ) stocks.next();
+ stock.setCurrentValuation( null );
+ session.flush();
+ Iterator valuations = stock.getValuations().iterator();
+ while ( valuations.hasNext() ) {
+ session.delete( valuations.next() );
+ }
+ session.delete( stock );
+ }
+ session.getTransaction().commit();
+ session.close();
+ }
+ }
+
+ private void prettyPrint(Element element) {
+ //System.out.println( element.asXML() );
+ try {
+ OutputFormat format = OutputFormat.createPrettyPrint();
+ new XMLWriter( System.out, format ).write( element );
+ System.out.println();
+ }
+ catch ( Throwable t ) {
+ System.err.println( "Unable to pretty print element : " + t );
+ }
+ }
+}
Property changes on: trunk/Hibernate3/test/org/hibernate/test/entitymode/multi/MultiRepresentationTest.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/Hibernate3/test/org/hibernate/test/entitymode/multi/Stock.hbm.xml (from rev 10964, trunk/Hibernate3/test/org/hibernate/test/entity/Stock.hbm.xml)
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/entity/Stock.hbm.xml 2006-12-08 16:06:49 UTC (rev 10964)
+++ trunk/Hibernate3/test/org/hibernate/test/entitymode/multi/Stock.hbm.xml 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping
+ SYSTEM
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
+
+<hibernate-mapping package="org.hibernate.test.entitymode.multi">
+
+ <class table="STOCK" name="Stock" node="stock">
+
+ <id name="id" column="STOCK_ID" node="@id">
+ <generator class="increment"/>
+ </id>
+
+ <property name="tradeSymbol" type="string" column="SYMBOL"/>
+
+ <many-to-one name="currentValuation" class="Valuation" column="CURR_VAL_ID" cascade="all" />
+
+ <set name="valuations" cascade="all" lazy="true">
+ <key column="STOCK_ID"/>
+ <one-to-many class="Valuation"/>
+ </set>
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Property changes on: trunk/Hibernate3/test/org/hibernate/test/entitymode/multi/Stock.hbm.xml
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/Hibernate3/test/org/hibernate/test/entitymode/multi/Stock.java (from rev 10964, trunk/Hibernate3/test/org/hibernate/test/entity/Stock.java)
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/entity/Stock.java 2006-12-08 16:06:49 UTC (rev 10964)
+++ trunk/Hibernate3/test/org/hibernate/test/entitymode/multi/Stock.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,49 @@
+// $Id$
+package org.hibernate.test.entitymode.multi;
+
+import java.util.Set;
+import java.util.HashSet;
+
+/**
+ * POJO implementation of Stock entity.
+ *
+ * @author Steve Ebersole
+ */
+public class Stock {
+ private Long id;
+ private String tradeSymbol;
+ private Valuation currentValuation;
+ private Set valuations = new HashSet();
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getTradeSymbol() {
+ return tradeSymbol;
+ }
+
+ public void setTradeSymbol(String tradeSymbol) {
+ this.tradeSymbol = tradeSymbol;
+ }
+
+ public Valuation getCurrentValuation() {
+ return currentValuation;
+ }
+
+ public void setCurrentValuation(Valuation currentValuation) {
+ this.currentValuation = currentValuation;
+ }
+
+ public Set getValuations() {
+ return valuations;
+ }
+
+ public void setValuations(Set valuations) {
+ this.valuations = valuations;
+ }
+}
Property changes on: trunk/Hibernate3/test/org/hibernate/test/entitymode/multi/Stock.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/Hibernate3/test/org/hibernate/test/entitymode/multi/Valuation.hbm.xml (from rev 10964, trunk/Hibernate3/test/org/hibernate/test/entity/Valuation.hbm.xml)
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/entity/Valuation.hbm.xml 2006-12-08 16:06:49 UTC (rev 10964)
+++ trunk/Hibernate3/test/org/hibernate/test/entitymode/multi/Valuation.hbm.xml 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping
+ SYSTEM
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
+
+<hibernate-mapping package="org.hibernate.test.entitymode.multi">
+
+ <class table="STOCK_VAL" name="Valuation" node="valuation">
+
+ <id name="id" column="VAL_ID" node="@id">
+ <generator class="increment"/>
+ </id>
+
+ <many-to-one name="stock" embed-xml="false"
+ class="Stock" column="STOCK_ID" cascade="none" />
+
+ <property name="valuationDate" type="date" column="DT"/>
+ <property name="value" type="double" column="VAL"/>
+
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Property changes on: trunk/Hibernate3/test/org/hibernate/test/entitymode/multi/Valuation.hbm.xml
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/Hibernate3/test/org/hibernate/test/entitymode/multi/Valuation.java (from rev 10964, trunk/Hibernate3/test/org/hibernate/test/entity/Valuation.java)
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/entity/Valuation.java 2006-12-08 16:06:49 UTC (rev 10964)
+++ trunk/Hibernate3/test/org/hibernate/test/entitymode/multi/Valuation.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,48 @@
+// $Id$
+package org.hibernate.test.entitymode.multi;
+
+import java.util.Date;
+
+/**
+ * Implementation of Valuation.
+ *
+ * @author Steve Ebersole
+ */
+public class Valuation {
+ private Long id;
+ private Stock stock;
+ private Date valuationDate;
+ private Double value;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public Stock getStock() {
+ return stock;
+ }
+
+ public void setStock(Stock stock) {
+ this.stock = stock;
+ }
+
+ public Date getValuationDate() {
+ return valuationDate;
+ }
+
+ public void setValuationDate(Date valuationDate) {
+ this.valuationDate = valuationDate;
+ }
+
+ public Double getValue() {
+ return value;
+ }
+
+ public void setValue(Double value) {
+ this.value = value;
+ }
+}
Property changes on: trunk/Hibernate3/test/org/hibernate/test/entitymode/multi/Valuation.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/Hibernate3/test/org/hibernate/test/exception/SQLExceptionConversionTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/exception/SQLExceptionConversionTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/exception/SQLExceptionConversionTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -6,7 +6,6 @@
import java.sql.SQLException;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.JDBCException;
import org.hibernate.Session;
@@ -14,7 +13,8 @@
import org.hibernate.exception.ConstraintViolationException;
import org.hibernate.exception.SQLExceptionConverter;
import org.hibernate.exception.SQLGrammarException;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.util.JDBCExceptionReporter;
/**
@@ -22,18 +22,25 @@
*
* @author Steve Ebersole
*/
-public class SQLExceptionConversionTest extends TestCase {
+public class SQLExceptionConversionTest extends FunctionalTestCase {
public SQLExceptionConversionTest(String name) {
super(name);
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] {"exception/User.hbm.xml", "exception/Group.hbm.xml"};
}
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite(SQLExceptionConversionTest.class);
+ }
+
public void testIntegrityViolation() throws Exception {
- if ( getDialect() instanceof MySQLMyISAMDialect ) return;
+ if ( getDialect() instanceof MySQLMyISAMDialect ) {
+ reportSkip( "MySQL (ISAM) does not support FK violation checking", "exception conversion" );
+ return;
+ }
SQLExceptionConverter converter = getDialect().buildSQLExceptionConverter();
@@ -82,8 +89,4 @@
session.close();
}
-
- public static Test suite() {
- return new TestSuite(SQLExceptionConversionTest.class);
- }
}
Modified: trunk/Hibernate3/test/org/hibernate/test/extendshbm/ExtendsTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/extendshbm/ExtendsTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/extendshbm/ExtendsTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -6,168 +6,186 @@
import org.hibernate.HibernateException;
import org.hibernate.cfg.Configuration;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.UnitTestCase;
/**
* @author Gavin King
*/
-public class ExtendsTest extends TestCase {
-
+public class ExtendsTest extends UnitTestCase {
+
public ExtendsTest(String str) {
- super(str);
+ super( str );
}
-
- public void testAllInOne() {
- Configuration cfg = new Configuration();
-
- cfg.addResource(getBaseForMappings() + "extendshbm/allinone.hbm.xml");
- assertNotNull(cfg.getClassMapping("org.hibernate.test.extendshbm.Customer"));
- assertNotNull(cfg.getClassMapping("org.hibernate.test.extendshbm.Person"));
- assertNotNull(cfg.getClassMapping("org.hibernate.test.extendshbm.Employee"));
- }
-
+
+ public static Test suite() {
+ return new TestSuite( ExtendsTest.class );
+ }
+
+ private String getBaseForMappings() {
+ return "org/hibernate/test/";
+ }
+
+ public void testAllInOne() {
+ Configuration cfg = new Configuration();
+
+ cfg.addResource( getBaseForMappings() + "extendshbm/allinone.hbm.xml" );
+ assertNotNull( cfg.getClassMapping( "org.hibernate.test.extendshbm.Customer" ) );
+ assertNotNull( cfg.getClassMapping( "org.hibernate.test.extendshbm.Person" ) );
+ assertNotNull( cfg.getClassMapping( "org.hibernate.test.extendshbm.Employee" ) );
+ }
+
public void testOutOfOrder() {
- Configuration cfg = new Configuration();
-
- try {
- cfg.addResource(getBaseForMappings() + "extendshbm/Customer.hbm.xml");
- assertNull("cannot be in the configuration yet!", cfg.getClassMapping("org.hibernate.test.extendshbm.Customer"));
- cfg.addResource(getBaseForMappings() + "extendshbm/Person.hbm.xml");
- cfg.addResource(getBaseForMappings() + "extendshbm/Employee.hbm.xml");
-
- cfg.buildSessionFactory();
-
- assertNotNull(cfg.getClassMapping("org.hibernate.test.extendshbm.Customer"));
- assertNotNull(cfg.getClassMapping("org.hibernate.test.extendshbm.Person"));
- assertNotNull(cfg.getClassMapping("org.hibernate.test.extendshbm.Employee"));
-
- } catch(HibernateException e) {
- fail("should not fail with exception! " + e);
- }
-
+ Configuration cfg = new Configuration();
+
+ try {
+ cfg.addResource( getBaseForMappings() + "extendshbm/Customer.hbm.xml" );
+ assertNull(
+ "cannot be in the configuration yet!",
+ cfg.getClassMapping( "org.hibernate.test.extendshbm.Customer" )
+ );
+ cfg.addResource( getBaseForMappings() + "extendshbm/Person.hbm.xml" );
+ cfg.addResource( getBaseForMappings() + "extendshbm/Employee.hbm.xml" );
+
+ cfg.buildSessionFactory();
+
+ assertNotNull( cfg.getClassMapping( "org.hibernate.test.extendshbm.Customer" ) );
+ assertNotNull( cfg.getClassMapping( "org.hibernate.test.extendshbm.Person" ) );
+ assertNotNull( cfg.getClassMapping( "org.hibernate.test.extendshbm.Employee" ) );
+
+ }
+ catch ( HibernateException e ) {
+ fail( "should not fail with exception! " + e );
+ }
+
}
public void testNwaitingForSuper() {
- Configuration cfg = new Configuration();
-
- try {
- cfg.addResource(getBaseForMappings() + "extendshbm/Customer.hbm.xml");
- assertNull("cannot be in the configuration yet!", cfg.getClassMapping("org.hibernate.test.extendshbm.Customer"));
- cfg.addResource(getBaseForMappings() + "extendshbm/Employee.hbm.xml");
- assertNull("cannot be in the configuration yet!", cfg.getClassMapping("org.hibernate.test.extendshbm.Employee"));
- cfg.addResource(getBaseForMappings() + "extendshbm/Person.hbm.xml");
-
- cfg.buildMappings();
-
- assertNotNull(cfg.getClassMapping("org.hibernate.test.extendshbm.Person"));
- assertNotNull(cfg.getClassMapping("org.hibernate.test.extendshbm.Employee"));
- assertNotNull(cfg.getClassMapping("org.hibernate.test.extendshbm.Customer"));
-
-
- } catch(HibernateException e) {
+ Configuration cfg = new Configuration();
+
+ try {
+ cfg.addResource( getBaseForMappings() + "extendshbm/Customer.hbm.xml" );
+ assertNull(
+ "cannot be in the configuration yet!",
+ cfg.getClassMapping( "org.hibernate.test.extendshbm.Customer" )
+ );
+ cfg.addResource( getBaseForMappings() + "extendshbm/Employee.hbm.xml" );
+ assertNull(
+ "cannot be in the configuration yet!",
+ cfg.getClassMapping( "org.hibernate.test.extendshbm.Employee" )
+ );
+ cfg.addResource( getBaseForMappings() + "extendshbm/Person.hbm.xml" );
+
+ cfg.buildMappings();
+
+ assertNotNull( cfg.getClassMapping( "org.hibernate.test.extendshbm.Person" ) );
+ assertNotNull( cfg.getClassMapping( "org.hibernate.test.extendshbm.Employee" ) );
+ assertNotNull( cfg.getClassMapping( "org.hibernate.test.extendshbm.Customer" ) );
+
+
+ }
+ catch ( HibernateException e ) {
e.printStackTrace();
- fail("should not fail with exception! " + e);
-
- }
-
+ fail( "should not fail with exception! " + e );
+
+ }
+
}
-
- public void testMissingSuper() {
- Configuration cfg = new Configuration();
-
- try {
- cfg.addResource(getBaseForMappings() + "extendshbm/Customer.hbm.xml");
- assertNull("cannot be in the configuration yet!", cfg.getClassMapping("org.hibernate.test.extendshbm.Customer"));
- cfg.addResource(getBaseForMappings() + "extendshbm/Employee.hbm.xml");
-
- cfg.buildSessionFactory();
-
- fail("Should not be able to build sessionfactory without a Person");
- } catch(HibernateException e) {
-
- }
-
- }
-
- public void testAllSeparateInOne() {
- Configuration cfg = new Configuration();
-
- try {
- cfg.addResource(getBaseForMappings() + "extendshbm/allseparateinone.hbm.xml");
-
- cfg.buildSessionFactory();
-
- assertNotNull(cfg.getClassMapping("org.hibernate.test.extendshbm.Customer"));
- assertNotNull(cfg.getClassMapping("org.hibernate.test.extendshbm.Person"));
- assertNotNull(cfg.getClassMapping("org.hibernate.test.extendshbm.Employee"));
-
- } catch(HibernateException e) {
- fail("should not fail with exception! " + e);
- }
-
- }
-
- public void testJoinedSubclassAndEntityNamesOnly() {
- Configuration cfg = new Configuration();
-
+
+ public void testMissingSuper() {
+ Configuration cfg = new Configuration();
+
try {
- cfg.addResource(getBaseForMappings() + "extendshbm/entitynames.hbm.xml");
-
- cfg.buildMappings();
-
- assertNotNull(cfg.getClassMapping("EntityHasName"));
- assertNotNull(cfg.getClassMapping("EntityCompany"));
-
- } catch(HibernateException e) {
+ cfg.addResource( getBaseForMappings() + "extendshbm/Customer.hbm.xml" );
+ assertNull(
+ "cannot be in the configuration yet!",
+ cfg.getClassMapping( "org.hibernate.test.extendshbm.Customer" )
+ );
+ cfg.addResource( getBaseForMappings() + "extendshbm/Employee.hbm.xml" );
+
+ cfg.buildSessionFactory();
+
+ fail( "Should not be able to build sessionfactory without a Person" );
+ }
+ catch ( HibernateException e ) {
+
+ }
+
+ }
+
+ public void testAllSeparateInOne() {
+ Configuration cfg = new Configuration();
+
+ try {
+ cfg.addResource( getBaseForMappings() + "extendshbm/allseparateinone.hbm.xml" );
+
+ cfg.buildSessionFactory();
+
+ assertNotNull( cfg.getClassMapping( "org.hibernate.test.extendshbm.Customer" ) );
+ assertNotNull( cfg.getClassMapping( "org.hibernate.test.extendshbm.Person" ) );
+ assertNotNull( cfg.getClassMapping( "org.hibernate.test.extendshbm.Employee" ) );
+
+ }
+ catch ( HibernateException e ) {
+ fail( "should not fail with exception! " + e );
+ }
+
+ }
+
+ public void testJoinedSubclassAndEntityNamesOnly() {
+ Configuration cfg = new Configuration();
+
+ try {
+ cfg.addResource( getBaseForMappings() + "extendshbm/entitynames.hbm.xml" );
+
+ cfg.buildMappings();
+
+ assertNotNull( cfg.getClassMapping( "EntityHasName" ) );
+ assertNotNull( cfg.getClassMapping( "EntityCompany" ) );
+
+ }
+ catch ( HibernateException e ) {
e.printStackTrace();
- fail("should not fail with exception! " + e);
-
- }
+ fail( "should not fail with exception! " + e );
+
+ }
}
-
+
public void testEntityNamesWithPackageFailureExpected() {
Configuration cfg = new Configuration();
try {
- cfg.addResource(getBaseForMappings() + "extendshbm/packageentitynames.hbm.xml");
-
- cfg.buildMappings();
-
- assertNotNull(cfg.getClassMapping("EntityHasName"));
- assertNotNull(cfg.getClassMapping("EntityCompany"));
-
- } catch(HibernateException e) {
+ cfg.addResource( getBaseForMappings() + "extendshbm/packageentitynames.hbm.xml" );
+
+ cfg.buildMappings();
+
+ assertNotNull( cfg.getClassMapping( "EntityHasName" ) );
+ assertNotNull( cfg.getClassMapping( "EntityCompany" ) );
+
+ }
+ catch ( HibernateException e ) {
e.printStackTrace();
- fail("should not fail with exception! " + e);
-
- }
+ fail( "should not fail with exception! " + e );
+
+ }
}
-
- public void testUnionSubclass() {
- Configuration cfg = new Configuration();
-
+
+ public void testUnionSubclass() {
+ Configuration cfg = new Configuration();
+
try {
- cfg.addResource(getBaseForMappings() + "extendshbm/unionsubclass.hbm.xml");
-
- cfg.buildMappings();
-
- assertNotNull(cfg.getClassMapping("org.hibernate.test.extendshbm.Person"));
- assertNotNull(cfg.getClassMapping("org.hibernate.test.extendshbm.Customer"));
-
- } catch(HibernateException e) {
+ cfg.addResource( getBaseForMappings() + "extendshbm/unionsubclass.hbm.xml" );
+
+ cfg.buildMappings();
+
+ assertNotNull( cfg.getClassMapping( "org.hibernate.test.extendshbm.Person" ) );
+ assertNotNull( cfg.getClassMapping( "org.hibernate.test.extendshbm.Customer" ) );
+
+ }
+ catch ( HibernateException e ) {
e.printStackTrace();
- fail("should not fail with exception! " + e);
-
- }
- }
-
-
- protected String[] getMappings() {
- return new String[] { };
- }
+ fail( "should not fail with exception! " + e );
- public static Test suite() {
- return new TestSuite(ExtendsTest.class);
+ }
}
}
Modified: trunk/Hibernate3/test/org/hibernate/test/extralazy/ExtraLazyTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/extralazy/ExtraLazyTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/extralazy/ExtraLazyTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -5,22 +5,30 @@
import java.util.Map;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class ExtraLazyTest extends TestCase {
-
+public class ExtraLazyTest extends FunctionalTestCase {
+
public ExtraLazyTest(String str) {
super(str);
}
-
+
+ public String[] getMappings() {
+ return new String[] { "extralazy/UserGroup.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( ExtraLazyTest.class );
+ }
+
public void testOrphanDelete() {
Session s = openSession();
Transaction t = s.beginTransaction();
@@ -208,14 +216,6 @@
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "extralazy/UserGroup.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(ExtraLazyTest.class);
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/filter/DynamicFilterTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/filter/DynamicFilterTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/filter/DynamicFilterTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -19,6 +19,8 @@
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.cache.CacheKey;
import org.hibernate.cache.entry.CollectionCacheEntry;
import org.hibernate.cfg.Configuration;
@@ -35,15 +37,36 @@
*
* @author Steve
*/
-public class DynamicFilterTest extends TestCase {
+public class DynamicFilterTest extends FunctionalTestCase {
private Log log = LogFactory.getLog( DynamicFilterTest.class );
-
public DynamicFilterTest(String testName) {
super( testName );
}
+ public String[] getMappings() {
+ return new String[]{
+ "filter/defs.hbm.xml",
+ "filter/LineItem.hbm.xml",
+ "filter/Order.hbm.xml",
+ "filter/Product.hbm.xml",
+ "filter/Salesperson.hbm.xml",
+ "filter/Department.hbm.xml",
+ "filter/Category.hbm.xml"
+ };
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty( Environment.MAX_FETCH_DEPTH, "1" );
+ cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
+ cfg.setProperty( Environment.USE_QUERY_CACHE, "true" );
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( DynamicFilterTest.class );
+ }
+
public void testSecondLevelCachedCollectionsFiltering() {
TestData testData = new TestData();
testData.prepare();
@@ -428,35 +451,6 @@
testData.release();
}
-
- /**
- * Define the mappings needed for these tests.
- *
- * @return Mappings for these tests.
- */
- protected String[] getMappings() {
- return new String[]{
- "filter/defs.hbm.xml",
- "filter/LineItem.hbm.xml",
- "filter/Order.hbm.xml",
- "filter/Product.hbm.xml",
- "filter/Salesperson.hbm.xml",
- "filter/Department.hbm.xml",
- "filter/Category.hbm.xml"
- };
- }
-
- protected void configure(Configuration cfg) {
- cfg.setProperty( Environment.MAX_FETCH_DEPTH, "1" );
-// cfg.setProperty( Environment.MAX_FETCH_DEPTH, "2" );
- cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
- cfg.setProperty( Environment.USE_QUERY_CACHE, "true" );
- }
-
- public static Test suite() {
- return new TestSuite( DynamicFilterTest.class );
- }
-
private class TestData {
private Long steveId;
private Long deptId;
Modified: trunk/Hibernate3/test/org/hibernate/test/formulajoin/FormulaJoinTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/formulajoin/FormulaJoinTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/formulajoin/FormulaJoinTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -4,21 +4,29 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.dialect.PostgreSQLDialect;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class FormulaJoinTest extends TestCase {
+public class FormulaJoinTest extends FunctionalTestCase {
public FormulaJoinTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "formulajoin/Master.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( FormulaJoinTest.class );
+ }
public void testFormulaJoin() {
Session s = openSession();
@@ -88,14 +96,5 @@
}
-
- protected String[] getMappings() {
- return new String[] { "formulajoin/Master.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(FormulaJoinTest.class);
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/generated/AbstractGeneratedPropertyTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/generated/AbstractGeneratedPropertyTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/generated/AbstractGeneratedPropertyTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,17 +1,17 @@
// $Id$
package org.hibernate.test.generated;
-import org.hibernate.test.DatabaseSpecificTestCase;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.Hibernate;
+import org.hibernate.junit.functional.DatabaseSpecificFunctionalTestCase;
/**
* Implementation of AbstractGeneratedPropertyTest.
*
* @author Steve Ebersole
*/
-public abstract class AbstractGeneratedPropertyTest extends DatabaseSpecificTestCase {
+public abstract class AbstractGeneratedPropertyTest extends DatabaseSpecificFunctionalTestCase {
public AbstractGeneratedPropertyTest(String x) {
super( x );
}
Added: trunk/Hibernate3/test/org/hibernate/test/generated/GeneratedPropertySuite.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/generated/GeneratedPropertySuite.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/generated/GeneratedPropertySuite.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,19 @@
+package org.hibernate.test.generated;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class GeneratedPropertySuite {
+ public static Test suite() {
+ TestSuite suite = new TestSuite( "generated property suite" );
+ suite.addTest( TimestampGeneratedValuesWithCachingTest.suite() );
+ suite.addTest( TriggerGeneratedValuesWithCachingTest.suite() );
+ suite.addTest( TriggerGeneratedValuesWithoutCachingTest.suite() );
+ return suite;
+ }
+}
Modified: trunk/Hibernate3/test/org/hibernate/test/generated/TimestampGeneratedValuesWithCachingTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/generated/TimestampGeneratedValuesWithCachingTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/generated/TimestampGeneratedValuesWithCachingTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,12 +1,12 @@
// $Id$
package org.hibernate.test.generated;
+import junit.framework.Test;
+
+import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.SybaseDialect;
-import org.hibernate.dialect.Dialect;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
-import junit.framework.TestSuite;
-import junit.framework.Test;
-
/**
* Implementation of TimestampGeneratedValuesWithCachingTest.
*
@@ -18,7 +18,7 @@
super( x );
}
- protected final String[] getMappings() {
+ public final String[] getMappings() {
return new String[] { "generated/MSSQLGeneratedPropertyEntity.hbm.xml" };
}
@@ -29,6 +29,6 @@
}
public static Test suite() {
- return new TestSuite( TimestampGeneratedValuesWithCachingTest.class );
+ return new FunctionalTestClassTestSuite( TimestampGeneratedValuesWithCachingTest.class );
}
}
Modified: trunk/Hibernate3/test/org/hibernate/test/generated/TriggerGeneratedValuesWithCachingTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/generated/TriggerGeneratedValuesWithCachingTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/generated/TriggerGeneratedValuesWithCachingTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -3,6 +3,7 @@
import org.hibernate.dialect.Oracle9Dialect;
import org.hibernate.dialect.Dialect;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -18,7 +19,7 @@
super( x );
}
- protected final String[] getMappings() {
+ public final String[] getMappings() {
return new String[] { "generated/GeneratedPropertyEntity.hbm.xml" };
}
@@ -29,6 +30,6 @@
}
public static Test suite() {
- return new TestSuite( TriggerGeneratedValuesWithCachingTest.class );
+ return new FunctionalTestClassTestSuite( TriggerGeneratedValuesWithCachingTest.class );
}
}
Modified: trunk/Hibernate3/test/org/hibernate/test/generated/TriggerGeneratedValuesWithoutCachingTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/generated/TriggerGeneratedValuesWithoutCachingTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/generated/TriggerGeneratedValuesWithoutCachingTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,12 +1,12 @@
// $Id$
package org.hibernate.test.generated;
+import junit.framework.Test;
+
+import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.Oracle9Dialect;
-import org.hibernate.dialect.Dialect;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
/**
* Implementation of TriggerGeneratedValuesWithoutCachingTest.
*
@@ -18,7 +18,7 @@
super( x );
}
- protected final String[] getMappings() {
+ public final String[] getMappings() {
return new String[] { "generated/GeneratedPropertyEntity.hbm.xml" };
}
@@ -33,6 +33,6 @@
}
public static Test suite() {
- return new TestSuite( TriggerGeneratedValuesWithoutCachingTest.class );
+ return new FunctionalTestClassTestSuite( TriggerGeneratedValuesWithoutCachingTest.class );
}
}
Added: trunk/Hibernate3/test/org/hibernate/test/generatedkeys/GeneratedKeysSuite.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/generatedkeys/GeneratedKeysSuite.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/generatedkeys/GeneratedKeysSuite.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,23 @@
+package org.hibernate.test.generatedkeys;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.hibernate.test.generatedkeys.identity.IdentityGeneratedKeysTest;
+import org.hibernate.test.generatedkeys.select.SelectGeneratorTest;
+import org.hibernate.test.generatedkeys.seqidentity.SequenceIdentityTest;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class GeneratedKeysSuite {
+ public static Test suite() {
+ TestSuite suite = new TestSuite( "generated keys suite" );
+ suite.addTest( IdentityGeneratedKeysTest.suite() );
+ suite.addTest( SelectGeneratorTest.suite() );
+ suite.addTest( SequenceIdentityTest.suite() );
+ return suite;
+ }
+}
Modified: trunk/Hibernate3/test/org/hibernate/test/generatedkeys/identity/IdentityGeneratedKeysTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/generatedkeys/identity/IdentityGeneratedKeysTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/generatedkeys/identity/IdentityGeneratedKeysTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,27 +1,28 @@
package org.hibernate.test.generatedkeys.identity;
-import org.hibernate.test.DatabaseSpecificTestCase;
-import org.hibernate.dialect.Dialect;
+import junit.framework.Test;
+
import org.hibernate.Session;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.junit.functional.DatabaseSpecificFunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Steve Ebersole
*/
-public class IdentityGeneratedKeysTest extends DatabaseSpecificTestCase {
+public class IdentityGeneratedKeysTest extends DatabaseSpecificFunctionalTestCase {
public IdentityGeneratedKeysTest(String name) {
super( name );
}
- protected void configure(Configuration cfg) {
+ public void configure(Configuration cfg) {
super.configure( cfg );
cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "generatedkeys/identity/MyEntity.hbm.xml" };
}
@@ -30,7 +31,7 @@
}
public static Test suite() {
- return new TestSuite( IdentityGeneratedKeysTest.class );
+ return new FunctionalTestClassTestSuite( IdentityGeneratedKeysTest.class );
}
public void testIdentityColumnGeneratedIds() {
Modified: trunk/Hibernate3/test/org/hibernate/test/generatedkeys/select/SelectGeneratorTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/generatedkeys/select/SelectGeneratorTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/generatedkeys/select/SelectGeneratorTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,40 +1,34 @@
package org.hibernate.test.generatedkeys.select;
-import org.hibernate.test.DatabaseSpecificTestCase;
+import junit.framework.Test;
+
import org.hibernate.Session;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.dialect.Oracle9Dialect;
-import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.DataDirectOracle9Dialect;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.dialect.Oracle9Dialect;
+import org.hibernate.junit.functional.DatabaseSpecificFunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Steve Ebersole
*/
-public class SelectGeneratorTest extends DatabaseSpecificTestCase {
+public class SelectGeneratorTest extends DatabaseSpecificFunctionalTestCase {
public SelectGeneratorTest(String x) {
super( x );
}
// TODO : need to determine appropriate physical generation strategies for select-generator testing on other databases...
- protected void configure(Configuration cfg) {
- super.configure( cfg );
+ public String[] getMappings() {
+ return new String[] { "generatedkeys/select/MyEntity.hbm.xml" };
}
public boolean appliesTo(Dialect dialect) {
return ( dialect instanceof Oracle9Dialect );
}
- protected String[] getMappings() {
- return new String[] {
- "generatedkeys/select/MyEntity.hbm.xml"
- };
- }
-
public static Test suite() {
- return new TestSuite( SelectGeneratorTest.class );
+ return new FunctionalTestClassTestSuite( SelectGeneratorTest.class );
}
public void testJDBC3GetGeneratedKeysSupportOnOracle() {
Modified: trunk/Hibernate3/test/org/hibernate/test/generatedkeys/seqidentity/SequenceIdentityTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/generatedkeys/seqidentity/SequenceIdentityTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/generatedkeys/seqidentity/SequenceIdentityTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,23 +1,24 @@
package org.hibernate.test.generatedkeys.seqidentity;
-import org.hibernate.test.DatabaseSpecificTestCase;
+import junit.framework.Test;
+
import org.hibernate.Session;
import org.hibernate.cfg.Configuration;
-import org.hibernate.dialect.Oracle9Dialect;
-import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.DataDirectOracle9Dialect;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.dialect.Oracle9Dialect;
+import org.hibernate.junit.functional.DatabaseSpecificFunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Steve Ebersole
*/
-public class SequenceIdentityTest extends DatabaseSpecificTestCase {
+public class SequenceIdentityTest extends DatabaseSpecificFunctionalTestCase {
public SequenceIdentityTest(String x) {
super( x );
}
- protected void configure(Configuration cfg) {
+ public void configure(Configuration cfg) {
super.configure( cfg );
}
@@ -27,14 +28,12 @@
return ( dialect instanceof Oracle9Dialect ) && ( ! ( dialect instanceof DataDirectOracle9Dialect ) ) ;
}
- protected String[] getMappings() {
- return new String[] {
- "generatedkeys/seqidentity/MyEntity.hbm.xml"
- };
+ public String[] getMappings() {
+ return new String[] { "generatedkeys/seqidentity/MyEntity.hbm.xml" };
}
public static Test suite() {
- return new TestSuite( SequenceIdentityTest.class );
+ return new FunctionalTestClassTestSuite( SequenceIdentityTest.class );
}
public void testSequenceIdentityGenerator() {
Modified: trunk/Hibernate3/test/org/hibernate/test/hql/ASTParserLoadingTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/hql/ASTParserLoadingTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/hql/ASTParserLoadingTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -13,7 +13,6 @@
import java.util.Map;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.HibernateException;
@@ -29,24 +28,26 @@
import org.hibernate.dialect.HSQLDialect;
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.dialect.Oracle9Dialect;
+import org.hibernate.dialect.PostgreSQLDialect;
import org.hibernate.dialect.SQLServerDialect;
import org.hibernate.dialect.SybaseDialect;
-import org.hibernate.dialect.PostgreSQLDialect;
+import org.hibernate.hql.ast.ASTQueryTranslatorFactory;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.stat.QueryStatistics;
-import org.hibernate.test.TestCase;
+import org.hibernate.test.any.IntegerPropertyValue;
+import org.hibernate.test.any.PropertySet;
import org.hibernate.test.any.PropertyValue;
import org.hibernate.test.any.StringPropertyValue;
-import org.hibernate.test.any.IntegerPropertyValue;
-import org.hibernate.test.any.PropertySet;
import org.hibernate.test.cid.Customer;
import org.hibernate.test.cid.LineItem;
import org.hibernate.test.cid.Order;
import org.hibernate.test.cid.Product;
import org.hibernate.transform.DistinctRootEntityResultTransformer;
import org.hibernate.transform.Transformers;
+import org.hibernate.type.ComponentType;
import org.hibernate.type.ManyToOneType;
import org.hibernate.type.Type;
-import org.hibernate.type.ComponentType;
import org.hibernate.util.StringHelper;
/**
@@ -59,21 +60,15 @@
*
* @author Steve
*/
-public class ASTParserLoadingTest extends TestCase {
+public class ASTParserLoadingTest extends FunctionalTestCase {
+ private List createdAnimalIds = new ArrayList();
+
public ASTParserLoadingTest(String name) {
super( name );
}
- private List createdAnimalIds = new ArrayList();
-
- public static Test suite() {
- return new TestSuite( ASTParserLoadingTest.class );
- }
-
- protected String[] getMappings() {
- // Make sure we are using the new AST parser translator...
- System.setProperty( Environment.QUERY_TRANSLATOR, "org.hibernate.hql.ast.ASTQueryTranslatorFactory" );
+ public String[] getMappings() {
return new String[] {
"hql/Animal.hbm.xml",
"hql/FooBarCopy.hbm.xml",
@@ -90,12 +85,17 @@
};
}
- protected void configure(Configuration cfg) {
+ public void configure(Configuration cfg) {
super.configure( cfg );
cfg.setProperty( Environment.USE_QUERY_CACHE, "true" );
cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
+ cfg.setProperty( Environment.QUERY_TRANSLATOR, ASTQueryTranslatorFactory.class.getName() );
}
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( ASTParserLoadingTest.class );
+ }
+
/**
* Copied from {@link HQLTest#testConcatenation}
*/
@@ -116,7 +116,10 @@
s.beginTransaction();
s.createQuery( "from Animal a where abs(a.bodyWeight-:param) < 2.0" ).setLong( "param", 1 ).list();
s.createQuery( "from Animal a where abs(:param - a.bodyWeight) < 2.0" ).setLong( "param", 1 ).list();
- s.createQuery( "from Animal where abs(:x - :y) < 2.0" ).setLong( "x", 1 ).setLong( "y", 1 ).list();
+ if ( ! ( getDialect() instanceof HSQLDialect ) ) {
+ // HSQLDB does not like the abs(? - ?) syntax...
+ s.createQuery( "from Animal where abs(:x - :y) < 2.0" ).setLong( "x", 1 ).setLong( "y", 1 ).list();
+ }
s.createQuery( "from Animal where lower(upper(:foo)) like 'f%'" ).setString( "foo", "foo" ).list();
s.createQuery( "from Animal a where abs(abs(a.bodyWeight - 1.0 + :param) * abs(length('ffobar')-3)) = 3.0" ).setLong( "param", 1 ).list();
s.createQuery( "from Animal where lower(upper('foo') || upper(:bar)) like 'f%'" ).setString( "bar", "xyz" ).list();
@@ -1782,15 +1785,15 @@
}
public void testSubselectBetween() {
- if(supportsSubselectOnLeftSideIn()) {
- assertResultSize("from Animal x where (select max(a.bodyWeight) from Animal a) in (1,2,3)", 0);
- assertResultSize("from Animal x where (select max(a.bodyWeight) from Animal a) between 0 and 100", 0);
- assertResultSize("from Animal x where (select max(a.description) from Animal a) like 'big%'", 0);
- assertResultSize("from Animal x where (select max(a.bodyWeight) from Animal a) is not null", 0);
+ if ( supportsSubselectOnLeftSideIn() ) {
+ assertResultSize( "from Animal x where (select max(a.bodyWeight) from Animal a) in (1,2,3)", 0 );
+ assertResultSize( "from Animal x where (select max(a.bodyWeight) from Animal a) between 0 and 100", 0 );
+ assertResultSize( "from Animal x where (select max(a.description) from Animal a) like 'big%'", 0 );
+ assertResultSize( "from Animal x where (select max(a.bodyWeight) from Animal a) is not null", 0 );
}
- assertResultSize("from Animal x where exists (select max(a.bodyWeight) from Animal a)", 0);
+ assertResultSize( "from Animal x where exists (select max(a.bodyWeight) from Animal a)", 0 );
}
-
+
private void assertResultSize(String hql, int size) {
Session session = openSession();
Transaction txn = session.beginTransaction();
Modified: trunk/Hibernate3/test/org/hibernate/test/hql/BulkManipulationTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/hql/BulkManipulationTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/hql/BulkManipulationTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,12 +1,11 @@
// $Id$
package org.hibernate.test.hql;
+import java.util.ArrayList;
import java.util.Date;
import java.util.List;
-import java.util.ArrayList;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.QueryException;
import org.hibernate.Transaction;
@@ -14,8 +13,9 @@
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.hql.ast.HqlSqlWalker;
import org.hibernate.id.IdentifierGenerator;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.persister.entity.EntityPersister;
-import org.hibernate.test.TestCase;
/**
@@ -23,17 +23,17 @@
*
* @author Steve Ebersole
*/
-public class BulkManipulationTest extends TestCase {
+public class BulkManipulationTest extends FunctionalTestCase {
public BulkManipulationTest(String name) {
super( name );
}
public static Test suite() {
- return new TestSuite( BulkManipulationTest.class );
+ return new FunctionalTestClassTestSuite( BulkManipulationTest.class );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] {
"hql/Animal.hbm.xml",
"hql/Vehicle.hbm.xml",
Modified: trunk/Hibernate3/test/org/hibernate/test/hql/ClassicTranslatorTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/hql/ClassicTranslatorTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/hql/ClassicTranslatorTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,11 +1,12 @@
package org.hibernate.test.hql;
+import junit.framework.Test;
+
+import org.hibernate.Session;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.hql.classic.ClassicQueryTranslatorFactory;
-import org.hibernate.Session;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* Some simple test queries using the classic translator explicitly
@@ -13,7 +14,7 @@
* <p/>
* Only really checking translation and syntax, not results.
*
- * @author <a href="mailto:steve@hibernate.org">Steve Ebersole </a>
+ * @author Steve Ebersole
*/
public class ClassicTranslatorTest extends QueryTranslatorTestCase {
@@ -22,15 +23,21 @@
}
public static Test suite() {
- return new TestSuite( ClassicTranslatorTest.class );
+ return new FunctionalTestClassTestSuite( ClassicTranslatorTest.class );
}
- protected boolean recreateSchema() {
+ public void configure(Configuration cfg) {
+ super.configure( cfg );
+ cfg.setProperty( Environment.QUERY_TRANSLATOR, ClassicQueryTranslatorFactory.class.getName() );
+ }
+
+
+ public boolean createSchema() {
return true;
}
- protected void configure(Configuration cfg) {
- cfg.setProperty( Environment.QUERY_TRANSLATOR, ClassicQueryTranslatorFactory.class.getName() );
+ public boolean recreateSchemaAfterFailure() {
+ return true;
}
public void testQueries() {
Added: trunk/Hibernate3/test/org/hibernate/test/hql/CriteriaClassicAggregationReturnTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/hql/CriteriaClassicAggregationReturnTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/hql/CriteriaClassicAggregationReturnTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,107 @@
+package org.hibernate.test.hql;
+
+import java.util.Collections;
+
+import junit.framework.Test;
+
+import org.hibernate.cfg.Configuration;
+import org.hibernate.dialect.function.ClassicCountFunction;
+import org.hibernate.dialect.function.ClassicAvgFunction;
+import org.hibernate.dialect.function.ClassicSumFunction;
+import org.hibernate.hql.ast.QueryTranslatorImpl;
+import org.hibernate.hql.QueryTranslator;
+import org.hibernate.hql.QueryTranslatorFactory;
+import org.hibernate.hql.classic.ClassicQueryTranslatorFactory;
+import org.hibernate.Hibernate;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class CriteriaClassicAggregationReturnTest extends QueryTranslatorTestCase {
+
+ public CriteriaClassicAggregationReturnTest(String x) {
+ super( x );
+ }
+
+ public void configure(Configuration cfg) {
+ super.configure( cfg );
+ cfg.addSqlFunction( "count", new ClassicCountFunction() );
+ cfg.addSqlFunction( "avg", new ClassicAvgFunction() );
+ cfg.addSqlFunction( "sum", new ClassicSumFunction() );
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( CriteriaClassicAggregationReturnTest.class );
+ }
+
+ public void testClassicHQLAggregationReturnTypes() {
+ // EJB3: COUNT returns Long
+ QueryTranslatorImpl translator = createNewQueryTranslator( "select count(*) from Human h", sfi() );
+ assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
+ assertEquals( "incorrect return type", Hibernate.INTEGER, translator.getReturnTypes()[0] );
+
+ translator = createNewQueryTranslator( "select count(h.height) from Human h", sfi() );
+ assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
+ assertEquals( "incorrect return type", Hibernate.INTEGER, translator.getReturnTypes()[0] );
+
+ // MAX, MIN return the type of the state-field to which they are applied.
+ translator = createNewQueryTranslator( "select max(h.height) from Human h", sfi() );
+ assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
+ assertEquals( "incorrect return type", Hibernate.DOUBLE, translator.getReturnTypes()[0] );
+
+ translator = createNewQueryTranslator( "select max(h.id) from Human h", sfi() );
+ assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
+ assertEquals( "incorrect return type", Hibernate.LONG, translator.getReturnTypes()[0] );
+
+ // AVG returns Float integrals, and otherwise the field type.
+ translator = createNewQueryTranslator( "select avg(h.height) from Human h", sfi() );
+ assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
+ assertEquals( "incorrect return type", Hibernate.DOUBLE, translator.getReturnTypes()[0] );
+
+ translator = createNewQueryTranslator( "select avg(h.id) from Human h", sfi() );
+ assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
+ assertEquals( "incorrect return type", Hibernate.FLOAT, translator.getReturnTypes()[0] );
+
+ translator = createNewQueryTranslator( "select avg(h.bigIntegerValue) from Human h", sfi() );
+ assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
+ assertEquals( "incorrect return type", Hibernate.BIG_INTEGER, translator.getReturnTypes()[0] );
+
+ // SUM returns underlying type sum
+ translator = createNewQueryTranslator( "select sum(h.id) from Human h", sfi() );
+ assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
+ assertEquals( "incorrect return type", Hibernate.LONG, translator.getReturnTypes()[0] );
+
+ translator = createNewQueryTranslator( "select sum(h.intValue) from Human h", sfi() );
+ assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
+ assertEquals( "incorrect return type", Hibernate.INTEGER, translator.getReturnTypes()[0] );
+
+ translator = createNewQueryTranslator( "select sum(h.height) from Human h", sfi() );
+ assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
+ assertEquals( "incorrect return type", Hibernate.DOUBLE, translator.getReturnTypes()[0] );
+
+ translator = createNewQueryTranslator( "select sum(h.floatValue) from Human h", sfi() );
+ assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
+ assertEquals( "incorrect return type", Hibernate.FLOAT, translator.getReturnTypes()[0] );
+
+ translator = createNewQueryTranslator( "select sum(h.bigIntegerValue) from Human h", sfi() );
+ assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
+ assertEquals( "incorrect return type", Hibernate.BIG_INTEGER, translator.getReturnTypes()[0] );
+
+ translator = createNewQueryTranslator( "select sum(h.bigDecimalValue) from Human h", sfi() );
+ assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
+ assertEquals( "incorrect return type", Hibernate.BIG_DECIMAL, translator.getReturnTypes()[0] );
+
+ // special case to test classicquery special case handling of count(*)
+ QueryTranslator oldQueryTranslator = null;
+ String hql = "select count(*) from Human h";
+ QueryTranslatorFactory classic = new ClassicQueryTranslatorFactory();
+ oldQueryTranslator = classic.createQueryTranslator( hql, hql, Collections.EMPTY_MAP, sfi() );
+ oldQueryTranslator.compile( Collections.EMPTY_MAP, true);
+ assertEquals( "incorrect return type count", 1, oldQueryTranslator.getReturnTypes().length );
+ assertEquals( "incorrect return type", Hibernate.INTEGER, oldQueryTranslator.getReturnTypes()[0] );
+
+ }
+}
Modified: trunk/Hibernate3/test/org/hibernate/test/hql/CriteriaHQLAlignmentTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/hql/CriteriaHQLAlignmentTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/hql/CriteriaHQLAlignmentTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -6,18 +6,11 @@
import java.util.Collections;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
-import org.hibernate.MappingException;
-import org.hibernate.QueryException;
-import org.hibernate.cfg.Configuration;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.classic.Session;
import org.hibernate.criterion.Projections;
-import org.hibernate.dialect.function.ClassicAvgFunction;
-import org.hibernate.dialect.function.ClassicCountFunction;
-import org.hibernate.dialect.function.ClassicSumFunction;
-import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.hql.QueryTranslator;
import org.hibernate.hql.QueryTranslatorFactory;
import org.hibernate.hql.ast.QueryTranslatorImpl;
@@ -36,14 +29,18 @@
SelectClause.VERSION2_SQL = true;
}
- protected boolean dropAfterFailure() {
+ public boolean createSchema() {
+ return true; // needed for the Criteria return type test
+ }
+
+ public boolean recreateSchemaAfterFailure() {
return true;
}
- protected boolean recreateSchema() {
- return true; // needed for the Criteria return type test
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( CriteriaHQLAlignmentTest.class );
}
-
+
public void testHQLAggregationReturnType() {
// EJB3: COUNT returns Long
QueryTranslatorImpl translator = createNewQueryTranslator( "select count(*) from Human h" );
@@ -173,84 +170,4 @@
s.close();
}
- public void testClassicHQLAggregationReturnTypes() {
- Configuration classicCfg = new Configuration();
- classicCfg.addSqlFunction( "count", new ClassicCountFunction());
- classicCfg.addSqlFunction( "avg", new ClassicAvgFunction());
- classicCfg.addSqlFunction( "sum", new ClassicSumFunction());
-
- addMappings(getMappings(), classicCfg);
- SessionFactoryImplementor factory = (SessionFactoryImplementor) classicCfg.buildSessionFactory();
-
- // EJB3: COUNT returns Long
- QueryTranslatorImpl translator = createNewQueryTranslator( "select count(*) from Human h", factory );
- assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
- assertEquals( "incorrect return type", Hibernate.INTEGER, translator.getReturnTypes()[0] );
-
- translator = createNewQueryTranslator( "select count(h.height) from Human h", factory );
- assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
- assertEquals( "incorrect return type", Hibernate.INTEGER, translator.getReturnTypes()[0] );
-
- // MAX, MIN return the type of the state-field to which they are applied.
- translator = createNewQueryTranslator( "select max(h.height) from Human h", factory );
- assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
- assertEquals( "incorrect return type", Hibernate.DOUBLE, translator.getReturnTypes()[0] );
-
- translator = createNewQueryTranslator( "select max(h.id) from Human h", factory );
- assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
- assertEquals( "incorrect return type", Hibernate.LONG, translator.getReturnTypes()[0] );
-
- // AVG returns Float integrals, and otherwise the field type.
- translator = createNewQueryTranslator( "select avg(h.height) from Human h", factory );
- assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
- assertEquals( "incorrect return type", Hibernate.DOUBLE, translator.getReturnTypes()[0] );
-
- translator = createNewQueryTranslator( "select avg(h.id) from Human h", factory );
- assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
- assertEquals( "incorrect return type", Hibernate.FLOAT, translator.getReturnTypes()[0] );
-
- translator = createNewQueryTranslator( "select avg(h.bigIntegerValue) from Human h", factory );
- assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
- assertEquals( "incorrect return type", Hibernate.BIG_INTEGER, translator.getReturnTypes()[0] );
-
- // SUM returns underlying type sum
- translator = createNewQueryTranslator( "select sum(h.id) from Human h", factory );
- assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
- assertEquals( "incorrect return type", Hibernate.LONG, translator.getReturnTypes()[0] );
-
- translator = createNewQueryTranslator( "select sum(h.intValue) from Human h", factory );
- assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
- assertEquals( "incorrect return type", Hibernate.INTEGER, translator.getReturnTypes()[0] );
-
- translator = createNewQueryTranslator( "select sum(h.height) from Human h", factory );
- assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
- assertEquals( "incorrect return type", Hibernate.DOUBLE, translator.getReturnTypes()[0] );
-
- translator = createNewQueryTranslator( "select sum(h.floatValue) from Human h", factory );
- assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
- assertEquals( "incorrect return type", Hibernate.FLOAT, translator.getReturnTypes()[0] );
-
- translator = createNewQueryTranslator( "select sum(h.bigIntegerValue) from Human h", factory );
- assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
- assertEquals( "incorrect return type", Hibernate.BIG_INTEGER, translator.getReturnTypes()[0] );
-
- translator = createNewQueryTranslator( "select sum(h.bigDecimalValue) from Human h", factory );
- assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
- assertEquals( "incorrect return type", Hibernate.BIG_DECIMAL, translator.getReturnTypes()[0] );
-
- // special case to test classicquery special case handling of count(*)
- QueryTranslator oldQueryTranslator = null;
- String hql = "select count(*) from Human h";
- QueryTranslatorFactory classic = new ClassicQueryTranslatorFactory();
- oldQueryTranslator = classic.createQueryTranslator( hql, hql, Collections.EMPTY_MAP, factory );
- oldQueryTranslator.compile( Collections.EMPTY_MAP, true);
- assertEquals( "incorrect return type count", 1, oldQueryTranslator.getReturnTypes().length );
- assertEquals( "incorrect return type", Hibernate.INTEGER, oldQueryTranslator.getReturnTypes()[0] );
-
- }
-
- public static Test suite() {
- return new TestSuite( CriteriaHQLAlignmentTest.class );
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/hql/EJBQLTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/hql/EJBQLTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/hql/EJBQLTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -18,7 +18,8 @@
import org.hibernate.hql.ast.QueryTranslatorImpl;
import org.hibernate.hql.ast.util.ASTUtil;
import org.hibernate.test.TestCase;
-import org.hibernate.Session;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import antlr.RecognitionException;
import antlr.TokenStreamException;
@@ -28,13 +29,49 @@
/**
* @author <a href="mailto:alex@jboss.org">Alexey Loubyansky</a>
*/
-public class EJBQLTest
- extends TestCase {
+public class EJBQLTest extends FunctionalTestCase {
public EJBQLTest(String x) {
super( x );
}
+ public String[] getMappings() {
+ return new String[]{
+ "hql/Animal.hbm.xml",
+ "batchfetch/ProductLine.hbm.xml",
+ "cid/Customer.hbm.xml",
+ "cid/Order.hbm.xml",
+ "cid/LineItem.hbm.xml",
+ "cid/Product.hbm.xml",
+ "legacy/Glarch.hbm.xml",
+ "legacy/Fee.hbm.xml",
+ "legacy/Qux.hbm.xml",
+ "legacy/Fum.hbm.xml",
+ "legacy/Holder.hbm.xml",
+ "legacy/One.hbm.xml",
+ "legacy/FooBar.hbm.xml",
+ "legacy/Many.hbm.xml",
+ "legacy/Baz.hbm.xml",
+ "legacy/Simple.hbm.xml",
+ "legacy/Middle.hbm.xml",
+ "legacy/Category.hbm.xml",
+ "legacy/Multi.hbm.xml",
+ "legacy/Commento.hbm.xml",
+ "legacy/Marelo.hbm.xml",
+ "compositeelement/Parent.hbm.xml",
+ "legacy/Container.hbm.xml",
+ };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( EJBQLTest.class );
+ }
+
+
+ public boolean createSchema() {
+ return false;
+ }
+
public void testEjb3PositionalParameters() throws Exception {
QueryTranslatorImpl qt = compile( "from Animal a where a.bodyWeight = ?1" );
AST ast = ( AST ) qt.getSqlAST();
@@ -222,32 +259,22 @@
// Private
private void assertEjbqlEqualsHql(String ejbql, String hql) {
- SessionFactoryImplementor factory = getSessionFactoryImplementor();
QueryTranslatorFactory ast = new ASTQueryTranslatorFactory();
- QueryTranslator queryTranslator = ast.createQueryTranslator( hql, hql, Collections.EMPTY_MAP, factory );
+ QueryTranslator queryTranslator = ast.createQueryTranslator( hql, hql, Collections.EMPTY_MAP, sfi() );
queryTranslator.compile( Collections.EMPTY_MAP, true );
String hqlSql = queryTranslator.getSQLString();
- queryTranslator = ast.createQueryTranslator( ejbql, ejbql, Collections.EMPTY_MAP, factory );
+ queryTranslator = ast.createQueryTranslator( ejbql, ejbql, Collections.EMPTY_MAP, sfi() );
queryTranslator.compile( Collections.EMPTY_MAP, true );
String ejbqlSql = queryTranslator.getSQLString();
assertEquals( hqlSql, ejbqlSql );
}
- private void assertEjbqlEqualsSql(String sql, String hql) {
- SessionFactoryImplementor factory = getSessionFactoryImplementor();
- QueryTranslatorFactory ast = new ASTQueryTranslatorFactory();
- QueryTranslator queryTranslator = ast.createQueryTranslator( hql, hql, Collections.EMPTY_MAP, factory );
- queryTranslator.compile( Collections.EMPTY_MAP, true );
- assertEquals( sql, queryTranslator.getSQLString() );
- }
-
private QueryTranslatorImpl compile(String input) {
- SessionFactoryImplementor factory = getSessionFactoryImplementor();
QueryTranslatorFactory ast = new ASTQueryTranslatorFactory();
- QueryTranslator queryTranslator = ast.createQueryTranslator( input, input, Collections.EMPTY_MAP, factory );
+ QueryTranslator queryTranslator = ast.createQueryTranslator( input, input, Collections.EMPTY_MAP, sfi() );
queryTranslator.compile( Collections.EMPTY_MAP, true );
return ( QueryTranslatorImpl ) queryTranslator;
@@ -276,50 +303,9 @@
}
private String toSql(String hql) {
- SessionFactoryImplementor factory = getSessionFactoryImplementor();
QueryTranslatorFactory ast = new ASTQueryTranslatorFactory();
- QueryTranslator queryTranslator = ast.createQueryTranslator( hql, hql, Collections.EMPTY_MAP, factory );
+ QueryTranslator queryTranslator = ast.createQueryTranslator( hql, hql, Collections.EMPTY_MAP, sfi() );
queryTranslator.compile( Collections.EMPTY_MAP, true );
return queryTranslator.getSQLString();
}
-
- private SessionFactoryImplementor getSessionFactoryImplementor() {
- SessionFactoryImplementor factory = ( SessionFactoryImplementor ) getSessions();
- if ( factory == null ) {
- throw new NullPointerException( "Unable to create factory!" );
- }
- return factory;
- }
-
- protected String[] getMappings() {
- return new String[]{
- "hql/Animal.hbm.xml",
- "batchfetch/ProductLine.hbm.xml",
- "cid/Customer.hbm.xml",
- "cid/Order.hbm.xml",
- "cid/LineItem.hbm.xml",
- "cid/Product.hbm.xml",
- "legacy/Glarch.hbm.xml",
- "legacy/Fee.hbm.xml",
- "legacy/Qux.hbm.xml",
- "legacy/Fum.hbm.xml",
- "legacy/Holder.hbm.xml",
- "legacy/One.hbm.xml",
- "legacy/FooBar.hbm.xml",
- "legacy/Many.hbm.xml",
- "legacy/Baz.hbm.xml",
- "legacy/Simple.hbm.xml",
- "legacy/Middle.hbm.xml",
- "legacy/Category.hbm.xml",
- "legacy/Multi.hbm.xml",
- "legacy/Commento.hbm.xml",
- "legacy/Marelo.hbm.xml",
- "compositeelement/Parent.hbm.xml",
- "legacy/Container.hbm.xml",
- };
- }
-
- public static Test suite() {
- return new TestSuite( EJBQLTest.class );
- }
}
Modified: trunk/Hibernate3/test/org/hibernate/test/hql/HQLSuite.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/hql/HQLSuite.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/hql/HQLSuite.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -23,6 +23,7 @@
suite.addTest( ScrollableCollectionFetchingTest.suite() );
suite.addTest( ClassicTranslatorTest.suite() );
suite.addTest( CriteriaHQLAlignmentTest.suite() );
+ suite.addTest( CriteriaClassicAggregationReturnTest.suite() );
return suite;
}
}
Modified: trunk/Hibernate3/test/org/hibernate/test/hql/HQLTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/hql/HQLTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/hql/HQLTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -14,6 +14,7 @@
import junit.framework.TestSuite;
import org.hibernate.Hibernate;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.dialect.DB2Dialect;
import org.hibernate.dialect.HSQLDialect;
import org.hibernate.dialect.MySQLDialect;
@@ -50,16 +51,20 @@
return false;
}
- protected void setUp() throws Exception {
- super.setUp();
+ protected void prepareTest() throws Exception {
+ super.prepareTest();
SelectClause.VERSION2_SQL = true;
DotNode.REGRESSION_STYLE_JOIN_SUPPRESSION = true;
}
- protected void tearDown() throws Exception {
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( HQLTest.class );
+ }
+
+ protected void cleanupTest() throws Exception {
SelectClause.VERSION2_SQL = false;
DotNode.REGRESSION_STYLE_JOIN_SUPPRESSION = false;
- super.tearDown();
+ super.cleanupTest();
}
//FAILING TESTS:
@@ -1314,8 +1319,4 @@
compileWithAstQueryTranslator( "from Human where name.first = 'Gavin'", false);
}
- public static Test suite() {
- return new TestSuite( HQLTest.class );
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/hql/HqlParserTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/hql/HqlParserTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/hql/HqlParserTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -11,6 +11,7 @@
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
+
import org.hibernate.hql.ast.HqlParser;
import org.hibernate.hql.ast.tree.Node;
import org.hibernate.hql.ast.util.ASTIterator;
Modified: trunk/Hibernate3/test/org/hibernate/test/hql/QueryTranslatorTestCase.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/hql/QueryTranslatorTestCase.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/hql/QueryTranslatorTestCase.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -20,6 +20,7 @@
import org.hibernate.EntityMode;
import org.hibernate.MappingException;
import org.hibernate.QueryException;
+import org.hibernate.junit.functional.FunctionalTestCase;
import org.hibernate.classic.Session;
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.engine.query.HQLQueryPlan;
@@ -30,7 +31,6 @@
import org.hibernate.hql.ast.QueryTranslatorImpl;
import org.hibernate.hql.ast.util.ASTPrinter;
import org.hibernate.hql.classic.ClassicQueryTranslatorFactory;
-import org.hibernate.test.TestCase;
import org.hibernate.type.Type;
import org.hibernate.type.TypeFactory;
import org.hibernate.util.StringHelper;
@@ -40,7 +40,8 @@
*
* @author josh Dec 6, 2004 8:21:21 AM
*/
-public abstract class QueryTranslatorTestCase extends TestCase {
+public abstract class QueryTranslatorTestCase extends FunctionalTestCase {
+
public QueryTranslatorTestCase(String x) {
super( x );
// Create an instance of HqlToken, so that it will have an entry point outside the package. This
@@ -48,6 +49,55 @@
new HqlToken();
}
+ public String[] getMappings() {
+ return new String[] {
+ "hql/Animal.hbm.xml",
+ "hql/EntityWithCrazyCompositeKey.hbm.xml",
+ "hql/CrazyIdFieldNames.hbm.xml",
+ "hql/SimpleEntityWithAssociation.hbm.xml",
+ "hql/ComponentContainer.hbm.xml",
+ "batchfetch/ProductLine.hbm.xml",
+ "cid/Customer.hbm.xml",
+ "cid/Order.hbm.xml",
+ "cid/LineItem.hbm.xml",
+ "cid/Product.hbm.xml",
+ "legacy/Baz.hbm.xml",
+ "legacy/Category.hbm.xml",
+ "legacy/Commento.hbm.xml",
+ "legacy/Container.hbm.xml",
+ "legacy/Custom.hbm.xml",
+ "legacy/Eye.hbm.xml",
+ "legacy/Fee.hbm.xml",
+ "legacy/FooBar.hbm.xml",
+ "legacy/Fum.hbm.xml",
+ "legacy/Glarch.hbm.xml",
+ "legacy/Holder.hbm.xml",
+ "legacy/Many.hbm.xml",
+ "legacy/Marelo.hbm.xml",
+ "legacy/MasterDetail.hbm.xml",
+ "legacy/Middle.hbm.xml",
+ "legacy/Multi.hbm.xml",
+ "legacy/Nameable.hbm.xml",
+ "legacy/One.hbm.xml",
+ "legacy/Qux.hbm.xml",
+ "legacy/Simple.hbm.xml",
+ "legacy/SingleSeveral.hbm.xml",
+ "legacy/WZ.hbm.xml",
+ "legacy/UpDown.hbm.xml",
+ "compositeelement/Parent.hbm.xml",
+ "onetoone/joined/Person.hbm.xml",
+ "any/Properties.hbm.xml"
+ };
+ }
+
+ public boolean createSchema() {
+ return false;
+ }
+
+ public boolean recreateSchemaAfterFailure() {
+ return false;
+ }
+
public void assertTranslation(String hql) throws QueryException, MappingException {
assertTranslation( hql, null );
}
@@ -493,50 +543,4 @@
catch( Throwable t ) {}
}
}
-
- protected String[] getMappings() {
- return new String[] {
- "hql/Animal.hbm.xml",
- "hql/EntityWithCrazyCompositeKey.hbm.xml",
- "hql/CrazyIdFieldNames.hbm.xml",
- "hql/SimpleEntityWithAssociation.hbm.xml",
- "hql/ComponentContainer.hbm.xml",
- "batchfetch/ProductLine.hbm.xml",
- "cid/Customer.hbm.xml",
- "cid/Order.hbm.xml",
- "cid/LineItem.hbm.xml",
- "cid/Product.hbm.xml",
- "legacy/Baz.hbm.xml",
- "legacy/Category.hbm.xml",
- "legacy/Commento.hbm.xml",
- "legacy/Container.hbm.xml",
- "legacy/Custom.hbm.xml",
- "legacy/Eye.hbm.xml",
- "legacy/Fee.hbm.xml",
- "legacy/FooBar.hbm.xml",
- "legacy/Fum.hbm.xml",
- "legacy/Glarch.hbm.xml",
- "legacy/Holder.hbm.xml",
- "legacy/Many.hbm.xml",
- "legacy/Marelo.hbm.xml",
- "legacy/MasterDetail.hbm.xml",
- "legacy/Middle.hbm.xml",
- "legacy/Multi.hbm.xml",
- "legacy/Nameable.hbm.xml",
- "legacy/One.hbm.xml",
- "legacy/Qux.hbm.xml",
- "legacy/Simple.hbm.xml",
- "legacy/SingleSeveral.hbm.xml",
- "legacy/WZ.hbm.xml",
- "legacy/UpDown.hbm.xml",
- "compositeelement/Parent.hbm.xml",
- "onetoone/joined/Person.hbm.xml",
- "any/Properties.hbm.xml"
- };
- }
-
- protected boolean recreateSchema() {
- // we do not need to create the schema for these parser tests
- return false;
- }
}
Modified: trunk/Hibernate3/test/org/hibernate/test/hql/ScrollableCollectionFetchingTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/hql/ScrollableCollectionFetchingTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/hql/ScrollableCollectionFetchingTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,14 +1,15 @@
// $Id$
package org.hibernate.test.hql;
-import org.hibernate.test.TestCase;
+import junit.framework.Test;
+
+import org.hibernate.HibernateException;
+import org.hibernate.ScrollMode;
+import org.hibernate.ScrollableResults;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.ScrollableResults;
-import org.hibernate.HibernateException;
-import org.hibernate.ScrollMode;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* Tests the new functionality of allowing scrolling of results which
@@ -16,17 +17,17 @@
*
* @author Steve Ebersole
*/
-public class ScrollableCollectionFetchingTest extends TestCase {
+public class ScrollableCollectionFetchingTest extends FunctionalTestCase {
public ScrollableCollectionFetchingTest(String name) {
super( name );
}
public static Test suite() {
- return new TestSuite( ScrollableCollectionFetchingTest.class );
+ return new FunctionalTestClassTestSuite( ScrollableCollectionFetchingTest.class );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "hql/Animal.hbm.xml" };
}
Modified: trunk/Hibernate3/test/org/hibernate/test/id/MultipleHiLoPerTableGeneratorTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/id/MultipleHiLoPerTableGeneratorTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/id/MultipleHiLoPerTableGeneratorTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,28 +1,29 @@
//$Id$
package org.hibernate.test.id;
-import org.hibernate.test.TestCase;
+import junit.framework.Test;
+
import org.hibernate.Session;
import org.hibernate.Transaction;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Emmanuel Bernard
*/
-public class MultipleHiLoPerTableGeneratorTest extends TestCase {
+public class MultipleHiLoPerTableGeneratorTest extends FunctionalTestCase {
public MultipleHiLoPerTableGeneratorTest(String x) {
super(x);
}
- protected String[] getMappings() {
- return new String[]{
- "id/Car.hbm.xml",
- "id/Plane.hbm.xml",
- "id/Radio.hbm.xml"
- };
+ public String[] getMappings() {
+ return new String[]{ "id/Car.hbm.xml", "id/Plane.hbm.xml", "id/Radio.hbm.xml" };
}
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( MultipleHiLoPerTableGeneratorTest.class );
+ }
+
public void testDistinctId() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@@ -103,8 +104,4 @@
tx.commit();
s.close();
}
-
- public static Test suite() {
- return new TestSuite(MultipleHiLoPerTableGeneratorTest.class);
- }
}
Modified: trunk/Hibernate3/test/org/hibernate/test/idbag/IdBagTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/idbag/IdBagTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/idbag/IdBagTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -5,23 +5,31 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class IdBagTest extends TestCase {
+public class IdBagTest extends FunctionalTestCase {
public IdBagTest(String str) {
super(str);
}
+ public String[] getMappings() {
+ return new String[] { "idbag/UserGroup.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( IdBagTest.class );
+ }
+
public void testUpdateIdBag() throws HibernateException, SQLException {
Session s = openSession();
Transaction t = s.beginTransaction();
@@ -88,14 +96,6 @@
t.commit();
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "idbag/UserGroup.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(IdBagTest.class);
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/idclass/IdClassTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/idclass/IdClassTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/idclass/IdClassTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -2,25 +2,30 @@
package org.hibernate.test.idclass;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
-import org.hibernate.type.Type;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class IdClassTest extends TestCase {
+public class IdClassTest extends FunctionalTestCase {
public IdClassTest(String str) {
super(str);
}
+ public String[] getMappings() {
+ return new String[] { "idclass/Customer.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( IdClassTest.class );
+ }
+
public void testIdClass() {
- Type type = getSessions().getClassMetadata(Customer.class).getIdentifierType();
- Type[] types = getSessions().getClassMetadata(Customer.class).getPropertyTypes();
Session s = openSession();
Transaction t = s.beginTransaction();
Customer cust = new FavoriteCustomer("JBoss", "RouteOne", "Detroit");
@@ -59,14 +64,6 @@
t.commit();
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "idclass/Customer.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(IdClassTest.class);
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/idprops/IdentifierPropertyReferencesTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/idprops/IdentifierPropertyReferencesTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/idprops/IdentifierPropertyReferencesTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,31 +1,31 @@
package org.hibernate.test.idprops;
import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.hibernate.test.TestCase;
+import org.hibernate.Criteria;
+import org.hibernate.Query;
import org.hibernate.Session;
-import org.hibernate.Query;
-import org.hibernate.Criteria;
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* {@inheritDoc}
*
* @author Steve Ebersole
*/
-public class IdentifierPropertyReferencesTest extends TestCase {
+public class IdentifierPropertyReferencesTest extends FunctionalTestCase {
public IdentifierPropertyReferencesTest(String name) {
super( name );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "idprops/Mapping.hbm.xml" };
}
public static Test suite() {
- return new TestSuite( IdentifierPropertyReferencesTest.class );
+ return new FunctionalTestClassTestSuite( IdentifierPropertyReferencesTest.class );
}
public void testHqlIdPropertyReferences() {
Modified: trunk/Hibernate3/test/org/hibernate/test/immutable/ImmutableTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/immutable/ImmutableTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/immutable/ImmutableTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -2,18 +2,30 @@
package org.hibernate.test.immutable;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.criterion.Projections;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class ImmutableTest extends TestCase {
-
+public class ImmutableTest extends FunctionalTestCase {
+
+ public ImmutableTest(String str) {
+ super(str);
+ }
+
+ public String[] getMappings() {
+ return new String[] { "immutable/ContractVariation.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( ImmutableTest.class );
+ }
+
public void testImmutable() {
Contract c = new Contract("gavin", "phone");
ContractVariation cv1 = new ContractVariation(1, c);
@@ -49,18 +61,6 @@
t.commit();
s.close();
}
-
- public ImmutableTest(String str) {
- super(str);
- }
- protected String[] getMappings() {
- return new String[] { "immutable/ContractVariation.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(ImmutableTest.class);
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/instrument/buildtime/InstrumentTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/instrument/buildtime/InstrumentTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/instrument/buildtime/InstrumentTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -5,7 +5,6 @@
import junit.framework.TestSuite;
import org.hibernate.intercept.FieldInterceptionHelper;
-import org.hibernate.test.TestCase;
import org.hibernate.test.instrument.domain.Document;
import org.hibernate.test.instrument.cases.TestDirtyCheckExecutable;
import org.hibernate.test.instrument.cases.TestFetchAllExecutable;
@@ -16,16 +15,21 @@
import org.hibernate.test.instrument.cases.TestLazyPropertyCustomTypeExecutable;
import org.hibernate.test.instrument.cases.TestManyToOneProxyExecutable;
import org.hibernate.test.instrument.cases.Executable;
+import org.hibernate.junit.UnitTestCase;
/**
* @author Gavin King
*/
-public class InstrumentTest extends TestCase {
+public class InstrumentTest extends UnitTestCase {
public InstrumentTest(String str) {
super(str);
}
+ public static Test suite() {
+ return new TestSuite( InstrumentTest.class );
+ }
+
public void testDirtyCheck() {
execute( new TestDirtyCheckExecutable() );
}
@@ -68,10 +72,6 @@
}
}
- protected String[] getMappings() {
- return new String[] { "instrument/domain/Documents.hbm.xml" };
- }
-
protected void runTest() throws Throwable {
if ( isRunnable() ) {
super.runTest();
@@ -81,10 +81,6 @@
}
}
- public static Test suite() {
- return new TestSuite(InstrumentTest.class);
- }
-
public static boolean isRunnable() {
return FieldInterceptionHelper.isInstrumented( new Document() );
}
Modified: trunk/Hibernate3/test/org/hibernate/test/instrument/cases/AbstractExecutable.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/instrument/cases/AbstractExecutable.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/instrument/cases/AbstractExecutable.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -12,8 +12,7 @@
private SessionFactory factory;
public final void prepare() {
- Configuration cfg = new Configuration()
- .setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
+ Configuration cfg = new Configuration().setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
String[] resources = getResources();
for ( int i = 0; i < resources.length; i++ ) {
cfg.addResource( resources[i] );
Modified: trunk/Hibernate3/test/org/hibernate/test/instrument/domain/Documents.hbm.xml
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/instrument/domain/Documents.hbm.xml 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/instrument/domain/Documents.hbm.xml 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,20 +1,20 @@
<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
+<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-<!--
+<!--
- This mapping demonstrates
+ This mapping demonstrates
- (1) use of lazy properties - this feature requires buildtime
+ (1) use of lazy properties - this feature requires buildtime
bytecode instrumentation; we don't think this is a very
necessary feature, but provide it for completeleness; if
Hibernate encounters uninstrumented classes, lazy property
fetching will be silently disabled, to enable testing
-
+
(2) use of a formula to define a "derived property"
-
+
-->
<hibernate-mapping package="org.hibernate.test.instrument.domain" default-access="field">
@@ -23,33 +23,25 @@
<id name="id">
<generator class="increment"/>
</id>
- <property name="name"
- not-null="true"
- length="50"/>
+ <property name="name" not-null="true" length="50"/>
<many-to-one name="parent"/>
- <bag name="subfolders"
- inverse="true"
- cascade="save-update">
+ <bag name="subfolders" inverse="true" cascade="save-update">
<key column="parent"/>
<one-to-many class="Folder"/>
</bag>
- <bag name="documents"
- inverse="true"
- cascade="all-delete-orphan">
+ <bag name="documents" inverse="true" cascade="all-delete-orphan">
<key column="folder"/>
<one-to-many class="Document"/>
</bag>
</class>
-
+
<class name="Owner" table="owners" lazy="false">
<id name="id">
<generator class="increment"/>
</id>
- <property name="name"
- not-null="true"
- length="50"/>
+ <property name="name" not-null="true" length="50"/>
</class>
-
+
<class name="Document" table="documents">
<id name="id">
<generator class="increment"/>
Modified: trunk/Hibernate3/test/org/hibernate/test/instrument/runtime/AbstractTransformingClassLoaderInstrumentTestCase.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/instrument/runtime/AbstractTransformingClassLoaderInstrumentTestCase.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/instrument/runtime/AbstractTransformingClassLoaderInstrumentTestCase.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -7,13 +7,17 @@
import org.hibernate.bytecode.InstrumentedClassLoader;
import org.hibernate.bytecode.util.BasicClassFilter;
import org.hibernate.bytecode.util.FieldFilter;
-import org.hibernate.test.AbstractClassLoaderIsolatedTestCase;
+import org.hibernate.junit.AbstractClassLoaderIsolatedTestCase;
/**
* @author Steve Ebersole
*/
public abstract class AbstractTransformingClassLoaderInstrumentTestCase extends AbstractClassLoaderIsolatedTestCase {
+ public AbstractTransformingClassLoaderInstrumentTestCase(String string) {
+ super( string );
+ }
+
protected ClassLoader buildIsolatedClassLoader(ClassLoader parent) {
BytecodeProvider provider = buildBytecodeProvider();
return new InstrumentedClassLoader(
Modified: trunk/Hibernate3/test/org/hibernate/test/instrument/runtime/CGLIBInstrumentationTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/instrument/runtime/CGLIBInstrumentationTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/instrument/runtime/CGLIBInstrumentationTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -9,6 +9,10 @@
* @author Steve Ebersole
*/
public class CGLIBInstrumentationTest extends AbstractTransformingClassLoaderInstrumentTestCase {
+ public CGLIBInstrumentationTest(String string) {
+ super( string );
+ }
+
protected BytecodeProvider buildBytecodeProvider() {
return new BytecodeProviderImpl();
}
Modified: trunk/Hibernate3/test/org/hibernate/test/instrument/runtime/JavassistInstrumentationTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/instrument/runtime/JavassistInstrumentationTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/instrument/runtime/JavassistInstrumentationTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -10,6 +10,10 @@
* @author Steve Ebersole
*/
public class JavassistInstrumentationTest extends AbstractTransformingClassLoaderInstrumentTestCase {
+ public JavassistInstrumentationTest(String string) {
+ super( string );
+ }
+
protected BytecodeProvider buildBytecodeProvider() {
return new BytecodeProviderImpl();
}
Modified: trunk/Hibernate3/test/org/hibernate/test/interceptor/InterceptorTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/interceptor/InterceptorTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/interceptor/InterceptorTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,27 +1,35 @@
//$Id$
package org.hibernate.test.interceptor;
+import java.io.Serializable;
import java.util.List;
-import java.io.Serializable;
import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.EmptyInterceptor;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.EmptyInterceptor;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.type.Type;
-import org.hibernate.test.TestCase;
/**
* @author Gavin King
*/
-public class InterceptorTest extends TestCase {
+public class InterceptorTest extends FunctionalTestCase {
public InterceptorTest(String str) {
super(str);
}
+ public String[] getMappings() {
+ return new String[] { "interceptor/User.hbm.xml", "interceptor/Image.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( InterceptorTest.class );
+ }
+
public void testCollectionIntercept() {
Session s = openSession( new CollectionInterceptor() );
Transaction t = s.beginTransaction();
@@ -156,13 +164,5 @@
s.close();
}
- protected String[] getMappings() {
- return new String[] { "interceptor/User.hbm.xml", "interceptor/Image.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(InterceptorTest.class);
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/interfaceproxy/InterfaceProxyTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/interfaceproxy/InterfaceProxyTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/interfaceproxy/InterfaceProxyTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -2,26 +2,41 @@
package org.hibernate.test.interfaceproxy;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.dialect.PostgreSQLDialect;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class InterfaceProxyTest extends TestCase {
+public class InterfaceProxyTest extends FunctionalTestCase {
public InterfaceProxyTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "interfaceproxy/Item.hbm.xml" };
+ }
+
+ public String getCacheConcurrencyStrategy() {
+ return null;
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( InterfaceProxyTest.class );
+ }
public void testInterfaceProxies() {
- if ( getDialect() instanceof PostgreSQLDialect ) return;
+ if ( getDialect() instanceof PostgreSQLDialect ) {
+ // TODO : why?
+ return;
+ }
Session s = openSession( new DocumentInterceptor() );
Transaction t = s.beginTransaction();
@@ -82,18 +97,5 @@
t.commit();
s.close();
}
-
-
- protected String[] getMappings() {
- return new String[] { "interfaceproxy/Item.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(InterfaceProxyTest.class);
- }
-
- public String getCacheConcurrencyStrategy() {
- return null;
- }
}
Modified: trunk/Hibernate3/test/org/hibernate/test/iterate/IterateTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/iterate/IterateTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/iterate/IterateTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -4,7 +4,6 @@
import java.util.Iterator;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.ScrollableResults;
@@ -12,16 +11,33 @@
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class IterateTest extends TestCase {
+public class IterateTest extends FunctionalTestCase {
public IterateTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "iterate/Item.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ super.configure( cfg );
+ cfg.setProperty( Environment.USE_QUERY_CACHE, "true" );
+ cfg.setProperty( Environment.CACHE_REGION_PREFIX, "foo" );
+ cfg.setProperty( Environment.USE_SECOND_LEVEL_CACHE, "true" );
+ cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( IterateTest.class );
+ }
public void testIterate() throws Exception {
getSessions().getStatistics().clear();
@@ -85,21 +101,5 @@
s.close();
assertEquals( getSessions().getStatistics().getEntityFetchCount(), 0 );
}
-
- protected String[] getMappings() {
- return new String[] { "iterate/Item.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(IterateTest.class);
- }
-
- protected void configure(Configuration cfg) {
- super.configure( cfg );
- cfg.setProperty( Environment.USE_QUERY_CACHE, "true" );
- cfg.setProperty( Environment.CACHE_REGION_PREFIX, "foo" );
- cfg.setProperty( Environment.USE_SECOND_LEVEL_CACHE, "true" );
- cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
- }
}
Modified: trunk/Hibernate3/test/org/hibernate/test/join/JoinTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/join/JoinTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/join/JoinTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -5,21 +5,29 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class JoinTest extends TestCase {
+public class JoinTest extends FunctionalTestCase {
public JoinTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "join/Person.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( JoinTest.class );
+ }
public void testSequentialSelects() {
Session s = openSession();
@@ -123,14 +131,5 @@
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "join/Person.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(JoinTest.class);
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/join/Person.hbm.xml
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/join/Person.hbm.xml 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/join/Person.hbm.xml 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,8 +1,8 @@
<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
<!--
This mapping demonstrates
@@ -24,55 +24,55 @@
-->
<hibernate-mapping package="org.hibernate.test.join" default-access="field">
-
- <class name="Person" table="person" lazy="true" discriminator-value="null">
-
- <id name="id" column="person_id" unsaved-value="0">
- <generator class="native"/>
- </id>
+ <class name="Person" table="person" lazy="true" discriminator-value="null">
+
+ <id name="id" column="person_id" unsaved-value="0">
+ <generator class="native"/>
+ </id>
+
<!-- force is unnecessary, in case we had other unknown discriminator values -->
- <discriminator column="person_type" type="string" length="1" not-null="false" force="true"/>
+ <discriminator column="person_type" type="string" length="1" not-null="false" force="true"/>
- <property name="name" not-null="true" length="80"/>
- <property name="sex" not-null="true" update="false"/>
+ <property name="name" not-null="true" length="80"/>
+ <property name="sex" not-null="true" update="false"/>
- <join table="address">
- <key column="address_id"/>
- <property name="address"/>
- <property name="zip"/>
- <property name="country"/>
- </join>
-
- <subclass name="Employee" lazy="true" discriminator-value="E">
- <join table="employee" fetch="select">
- <key column="person_id"/>
- <property name="title" not-null="true" length="20"/>
- <property name="salary" length="0"/>
- <many-to-one name="manager"/>
- </join>
- </subclass>
-
- <subclass name="Customer" lazy="true" discriminator-value="C">
- <join table="customer" fetch="select">
- <key column="person_id"/>
- <property name="comments"/>
- <many-to-one name="salesperson"/>
- </join>
- </subclass>
-
- <subclass name="User" lazy="true" discriminator-value="U">
- <join table="t_user" fetch="select" optional="true">
- <key column="person_id"/>
- <property name="login" column="u_login"/>
- </join>
- <join table="t_silly" fetch="select" optional="true" >
+ <join table="address">
+ <key column="address_id"/>
+ <property name="address"/>
+ <property name="zip"/>
+ <property name="country"/>
+ </join>
+
+ <subclass name="Employee" lazy="true" discriminator-value="E">
+ <join table="employee" fetch="select">
<key column="person_id"/>
+ <property name="title" not-null="true" length="20"/>
+ <property name="salary" length="0"/>
+ <many-to-one name="manager"/>
+ </join>
+ </subclass>
+
+ <subclass name="Customer" lazy="true" discriminator-value="C">
+ <join table="customer" fetch="select">
+ <key column="person_id"/>
+ <property name="comments"/>
+ <many-to-one name="salesperson"/>
+ </join>
+ </subclass>
+
+ <subclass name="User" lazy="true" discriminator-value="U">
+ <join table="t_user" fetch="select" optional="true">
+ <key column="person_id"/>
+ <property name="login" column="u_login"/>
+ </join>
+ <join table="t_silly" fetch="select" optional="true">
+ <key column="person_id"/>
<property name="silly"/>
</join>
</subclass>
-
- </class>
-
+ </class>
+
+
</hibernate-mapping>
Modified: trunk/Hibernate3/test/org/hibernate/test/joinedsubclass/JoinedSubclassTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/joinedsubclass/JoinedSubclassTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/joinedsubclass/JoinedSubclassTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -6,25 +6,33 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
+import org.hibernate.LockMode;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.LockMode;
import org.hibernate.criterion.Expression;
import org.hibernate.criterion.Property;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class JoinedSubclassTest extends TestCase {
+public class JoinedSubclassTest extends FunctionalTestCase {
public JoinedSubclassTest(String str) {
super(str);
}
+ public String[] getMappings() {
+ return new String[] { "joinedsubclass/Person.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( JoinedSubclassTest.class );
+ }
+
public void testJoinedSubclass() {
Session s = openSession();
Transaction t = s.beginTransaction();
@@ -199,14 +207,5 @@
}
-
- protected String[] getMappings() {
- return new String[] { "joinedsubclass/Person.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(JoinedSubclassTest.class);
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/joinfetch/JoinFetchTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/joinfetch/JoinFetchTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/joinfetch/JoinFetchTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -4,7 +4,6 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.FetchMode;
import org.hibernate.Hibernate;
@@ -14,16 +13,30 @@
import org.hibernate.cfg.Environment;
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class JoinFetchTest extends TestCase {
+public class JoinFetchTest extends FunctionalTestCase {
public JoinFetchTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "joinfetch/ItemBid.hbm.xml", "joinfetch/UserGroup.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty(Environment.MAX_FETCH_DEPTH, "10");
+ cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "false");
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( JoinFetchTest.class );
+ }
public void testProjection() {
Session s = openSession();
@@ -249,19 +262,6 @@
t.commit();
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "joinfetch/ItemBid.hbm.xml", "joinfetch/UserGroup.hbm.xml" };
- }
- protected void configure(Configuration cfg) {
- cfg.setProperty(Environment.MAX_FETCH_DEPTH, "10");
- cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "false");
- }
-
- public static Test suite() {
- return new TestSuite(JoinFetchTest.class);
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/jpa/AbstractJPATest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/jpa/AbstractJPATest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/jpa/AbstractJPATest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -14,6 +14,7 @@
import org.hibernate.event.FlushEntityEventListener;
import org.hibernate.engine.CascadingAction;
import org.hibernate.util.IdentityMap;
+import org.hibernate.junit.functional.FunctionalTestCase;
import java.io.Serializable;
@@ -22,16 +23,16 @@
*
* @author Steve Ebersole
*/
-public class AbstractJPATest extends TestCase {
+public class AbstractJPATest extends FunctionalTestCase {
public AbstractJPATest(String name) {
super( name );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "jpa/Part.hbm.xml", "jpa/Item.hbm.xml", "jpa/MyEntity.hbm.xml" };
}
- protected void configure(Configuration cfg) {
+ public void configure(Configuration cfg) {
super.configure( cfg );
cfg.setProperty( Environment.JPAQL_STRICT_COMPLIANCE, "true" );
cfg.setProperty( Environment.USE_SECOND_LEVEL_CACHE, "false" );
Modified: trunk/Hibernate3/test/org/hibernate/test/jpa/JPAComplianceSuite.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/jpa/JPAComplianceSuite.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/jpa/JPAComplianceSuite.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -2,13 +2,14 @@
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.hibernate.test.jpa.lock.EJB3LockTest;
+import org.hibernate.test.jpa.lock.JPALockTest;
import org.hibernate.test.jpa.lock.RepeatableReadTest;
import org.hibernate.test.jpa.removed.RemovedEntityTest;
import org.hibernate.test.jpa.proxy.JPAProxyTest;
import org.hibernate.test.jpa.fetch.FetchingTest;
import org.hibernate.test.jpa.ql.JPAQLComplianceTest;
import org.hibernate.test.jpa.ql.NativeQueryTest;
+import org.hibernate.test.jpa.cascade.CascadeTest;
/**
* @author Steve Ebersole
@@ -16,10 +17,11 @@
public class JPAComplianceSuite {
public static Test suite() {
TestSuite suite = new TestSuite( "JPA-compliance tests");
- suite.addTest( EJB3LockTest.suite() );
+ suite.addTest( CascadeTest.suite() );
+ suite.addTest( FetchingTest.suite() );
+ suite.addTest( JPALockTest.suite() );
suite.addTest( RepeatableReadTest.suite() );
suite.addTest( JPAProxyTest.suite() );
- suite.addTest( FetchingTest.suite() );
suite.addTest( JPAQLComplianceTest.suite() );
suite.addTest( NativeQueryTest.suite() );
suite.addTest( RemovedEntityTest.suite() );
Modified: trunk/Hibernate3/test/org/hibernate/test/jpa/cascade/CascadeTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/jpa/cascade/CascadeTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/jpa/cascade/CascadeTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -5,6 +5,7 @@
import org.hibernate.TransientObjectException;
import org.hibernate.EntityMode;
import org.hibernate.HibernateException;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.engine.Status;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.event.FlushEntityEventListener;
@@ -12,6 +13,7 @@
import org.hibernate.cfg.Configuration;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import junit.framework.Test;
/**
* According to the JPA spec, persist()ing an entity should throw an exception
@@ -34,13 +36,12 @@
super( name );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "jpa/cascade/ParentChild.hbm.xml" };
}
- protected void configure(Configuration cfg) {
- super.configure( cfg );
-
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( CascadeTest.class );
}
public void testManyToOneGeneratedIdsOnSave() {
Modified: trunk/Hibernate3/test/org/hibernate/test/jpa/fetch/FetchingTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/jpa/fetch/FetchingTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/jpa/fetch/FetchingTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,20 +1,32 @@
package org.hibernate.test.jpa.fetch;
-import org.hibernate.test.jpa.AbstractJPATest;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.hibernate.Hibernate;
-
import java.util.Date;
import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.Hibernate;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.test.jpa.AbstractJPATest;
+
/**
* @author Emmanuel Bernard
*/
public class FetchingTest extends AbstractJPATest {
+ public FetchingTest(String x) {
+ super( x );
+ }
+
+ public String[] getMappings() {
+ return new String[] { "jpa/fetch/Person.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( FetchingTest.class );
+ }
+
public void testLazy() throws Exception {
Session s;
Transaction tx;
@@ -69,16 +81,4 @@
tx.commit();
s.close();
}
-
- public FetchingTest(String x) {
- super( x );
- }
-
- protected String[] getMappings() {
- return new String[] { "jpa/fetch/Person.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite( FetchingTest.class );
- }
}
Deleted: trunk/Hibernate3/test/org/hibernate/test/jpa/lock/EJB3LockTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/jpa/lock/EJB3LockTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/jpa/lock/EJB3LockTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,179 +0,0 @@
-package org.hibernate.test.jpa.lock;
-
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.hibernate.LockMode;
-import org.hibernate.test.jpa.AbstractJPATest;
-import org.hibernate.test.jpa.Item;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * Tests specifically relating to section 3.3.5.3 [Lock Modes] of the
- * JPA persistence specification (as of the <i>Proposed Final Draft</i>).
- *
- * @author Steve Ebersole
- */
-public class EJB3LockTest extends AbstractJPATest {
- public EJB3LockTest(String name) {
- super( name );
- }
-
- public static Test suite() {
- return new TestSuite( EJB3LockTest.class );
- }
-
- /**
- * Test the equivalent of EJB3 LockModeType.READ
- * <p/>
- * From the spec:
- * <p/>
- * If transaction T1 calls lock(entity, LockModeType.READ) on a versioned object, the entity
- * manager must ensure that neither of the following phenomena can occur:<ul>
- * <li>P1 (Dirty read): Transaction T1 modifies a row. Another transaction T2 then reads that row and
- * obtains the modified value, before T1 has committed or rolled back. Transaction T2 eventually
- * commits successfully; it does not matter whether T1 commits or rolls back and whether it does
- * so before or after T2 commits.
- * <li>P2 (Non-repeatable read): Transaction T1 reads a row. Another transaction T2 then modifies or
- * deletes that row, before T1 has committed. Both transactions eventually commit successfully.
- * <p/>
- * This will generally be achieved by the entity manager acquiring a lock on the underlying database row.
- * Any such lock may be obtained immediately (so long as it is retained until commit completes), or the
- * lock may be deferred until commit time (although even then it must be retained until the commit completes).
- * Any implementation that supports repeatable reads in a way that prevents the above phenomena
- * is permissible.
- * <p/>
- * The persistence implementation is not required to support calling lock(entity, LockMode-Type.READ)
- * on a non-versioned object. When it cannot support such a lock call, it must throw the
- * PersistenceException. When supported, whether for versioned or non-versioned objects, LockMode-Type.READ
- * must always prevent the phenomena P1 and P2. Applications that call lock(entity, LockModeType.READ)
- * on non-versioned objects will not be portable.
- * <p/>
- * Odd as it may sound, EJB3 LockModeType.READ actually maps to the Hibernate LockMode.UPGRADE
- */
- public void testLockModeTypeRead() {
- if ( ! readCommittedIsolationMaintained( "ejb3 lock tests" ) ) {
- return;
- }
-
- final String initialName = "lock test";
- // set up some test data
- Session s1 = getSessions().openSession();
- Transaction t1 = s1.beginTransaction();
- Item item = new Item();
- item.setName( initialName );
- s1.save( item );
- t1.commit();
- s1.close();
-
- Long itemId = item.getId();
-
- // perform the isolated update
- s1 = getSessions().openSession();
- t1 = s1.beginTransaction();
- item = ( Item ) s1.get( Item.class, itemId );
- s1.lock( item, LockMode.UPGRADE );
- item.setName( "updated" );
- s1.flush();
-
- Session s2 = getSessions().openSession();
- Transaction t2 = s2.beginTransaction();
- Item item2 = ( Item ) s2.get( Item.class, itemId );
- assertEquals( "isolation not maintained", initialName, item2.getName() );
-
- t1.commit();
- s1.close();
-
- item2 = ( Item ) s2.get( Item.class, itemId );
- assertEquals( "repeatable read not maintained", initialName, item2.getName() );
- t2.commit();
- s2.close();
-
- s1 = getSessions().openSession();
- t1 = s1.beginTransaction();
- s1.delete( item );
- t1.commit();
- s1.close();
- }
-
- /**
- * Test the equivalent of EJB3 LockModeType.WRITE
- * <p/>
- * From the spec:
- * <p/>
- * If transaction T1 calls lock(entity, LockModeType.WRITE) on a versioned object, the entity
- * manager must avoid the phenomena P1 and P2 (as with LockModeType.READ) and must also force
- * an update (increment) to the entity's version column. A forced version update may be performed immediately,
- * or may be deferred until a flush or commit. If an entity is removed before a deferred version
- * update was to have been applied, the forced version update is omitted, since the underlying database
- * row no longer exists.
- * <p/>
- * The persistence implementation is not required to support calling lock(entity, LockMode-Type.WRITE)
- * on a non-versioned object. When it cannot support a such lock call, it must throw the
- * PersistenceException. When supported, whether for versioned or non-versioned objects, LockMode-Type.WRITE
- * must always prevent the phenomena P1 and P2. For non-versioned objects, whether or
- * not LockModeType.WRITE has any additional behaviour is vendor-specific. Applications that call
- * lock(entity, LockModeType.WRITE) on non-versioned objects will not be portable.
- * <p/>
- * Due to the requirement that LockModeType.WRITE needs to force a version increment,
- * a new Hibernate LockMode was added to support this behavior: {@link org.hibernate.LockMode#FORCE}.
- */
- public void testLockModeTypeWrite() {
- if ( ! readCommittedIsolationMaintained( "ejb3 lock tests" ) ) {
- return;
- }
- final String initialName = "lock test";
- // set up some test data
- Session s1 = getSessions().openSession();
- Transaction t1 = s1.beginTransaction();
- Item item = new Item();
- item.setName( initialName );
- s1.save( item );
- t1.commit();
- s1.close();
-
- Long itemId = item.getId();
- long initialVersion = item.getVersion();
-
- s1 = getSessions().openSession();
- t1 = s1.beginTransaction();
- item = ( Item ) s1.get( Item.class, itemId );
- s1.lock( item, LockMode.FORCE );
- assertEquals( "no forced version increment", initialVersion + 1, item.getVersion() );
-
- s1.lock( item, LockMode.FORCE );
- assertEquals( "subsequent LockMode.FORCE did not no-op", initialVersion + 1, item.getVersion() );
-
- Session s2 = getSessions().openSession();
- Transaction t2 = s2.beginTransaction();
- Item item2 = ( Item ) s2.get( Item.class, itemId );
- assertEquals( "isolation not maintained", initialName, item2.getName() );
-
- item.setName( "updated-1" );
- s1.flush();
- // currently an unfortunate side effect...
- assertEquals( initialVersion + 2, item.getVersion() );
-
- t1.commit();
- s1.close();
-
- item2.setName( "updated" );
- try {
- t2.commit();
- fail( "optimisitc lock should have failed" );
- }
- catch( Throwable ignore ) {
- // expected behavior
- t2.rollback();
- }
- finally {
- s2.close();
- }
-
- s1 = getSessions().openSession();
- t1 = s1.beginTransaction();
- s1.delete( item );
- t1.commit();
- s1.close();
- }
-}
Copied: trunk/Hibernate3/test/org/hibernate/test/jpa/lock/JPALockTest.java (from rev 10964, trunk/Hibernate3/test/org/hibernate/test/jpa/lock/EJB3LockTest.java)
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/jpa/lock/EJB3LockTest.java 2006-12-08 16:06:49 UTC (rev 10964)
+++ trunk/Hibernate3/test/org/hibernate/test/jpa/lock/JPALockTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,180 @@
+package org.hibernate.test.jpa.lock;
+
+import junit.framework.Test;
+
+import org.hibernate.LockMode;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.test.jpa.AbstractJPATest;
+import org.hibernate.test.jpa.Item;
+
+/**
+ * Tests specifically relating to section 3.3.5.3 [Lock Modes] of the
+ * JPA persistence specification (as of the <i>Proposed Final Draft</i>).
+ *
+ * @author Steve Ebersole
+ */
+public class JPALockTest extends AbstractJPATest {
+ public JPALockTest(String name) {
+ super( name );
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( JPALockTest.class );
+ }
+
+ /**
+ * Test the equivalent of EJB3 LockModeType.READ
+ * <p/>
+ * From the spec:
+ * <p/>
+ * If transaction T1 calls lock(entity, LockModeType.READ) on a versioned object, the entity
+ * manager must ensure that neither of the following phenomena can occur:<ul>
+ * <li>P1 (Dirty read): Transaction T1 modifies a row. Another transaction T2 then reads that row and
+ * obtains the modified value, before T1 has committed or rolled back. Transaction T2 eventually
+ * commits successfully; it does not matter whether T1 commits or rolls back and whether it does
+ * so before or after T2 commits.
+ * <li>P2 (Non-repeatable read): Transaction T1 reads a row. Another transaction T2 then modifies or
+ * deletes that row, before T1 has committed. Both transactions eventually commit successfully.
+ * <p/>
+ * This will generally be achieved by the entity manager acquiring a lock on the underlying database row.
+ * Any such lock may be obtained immediately (so long as it is retained until commit completes), or the
+ * lock may be deferred until commit time (although even then it must be retained until the commit completes).
+ * Any implementation that supports repeatable reads in a way that prevents the above phenomena
+ * is permissible.
+ * <p/>
+ * The persistence implementation is not required to support calling lock(entity, LockMode-Type.READ)
+ * on a non-versioned object. When it cannot support such a lock call, it must throw the
+ * PersistenceException. When supported, whether for versioned or non-versioned objects, LockMode-Type.READ
+ * must always prevent the phenomena P1 and P2. Applications that call lock(entity, LockModeType.READ)
+ * on non-versioned objects will not be portable.
+ * <p/>
+ * Odd as it may sound, EJB3 LockModeType.READ actually maps to the Hibernate LockMode.UPGRADE
+ */
+ public void testLockModeTypeRead() {
+ if ( ! readCommittedIsolationMaintained( "ejb3 lock tests" ) ) {
+ return;
+ }
+
+ final String initialName = "lock test";
+ // set up some test data
+ Session s1 = getSessions().openSession();
+ Transaction t1 = s1.beginTransaction();
+ Item item = new Item();
+ item.setName( initialName );
+ s1.save( item );
+ t1.commit();
+ s1.close();
+
+ Long itemId = item.getId();
+
+ // perform the isolated update
+ s1 = getSessions().openSession();
+ t1 = s1.beginTransaction();
+ item = ( Item ) s1.get( Item.class, itemId );
+ s1.lock( item, LockMode.UPGRADE );
+ item.setName( "updated" );
+ s1.flush();
+
+ Session s2 = getSessions().openSession();
+ Transaction t2 = s2.beginTransaction();
+ Item item2 = ( Item ) s2.get( Item.class, itemId );
+ assertEquals( "isolation not maintained", initialName, item2.getName() );
+
+ t1.commit();
+ s1.close();
+
+ item2 = ( Item ) s2.get( Item.class, itemId );
+ assertEquals( "repeatable read not maintained", initialName, item2.getName() );
+ t2.commit();
+ s2.close();
+
+ s1 = getSessions().openSession();
+ t1 = s1.beginTransaction();
+ s1.delete( item );
+ t1.commit();
+ s1.close();
+ }
+
+ /**
+ * Test the equivalent of EJB3 LockModeType.WRITE
+ * <p/>
+ * From the spec:
+ * <p/>
+ * If transaction T1 calls lock(entity, LockModeType.WRITE) on a versioned object, the entity
+ * manager must avoid the phenomena P1 and P2 (as with LockModeType.READ) and must also force
+ * an update (increment) to the entity's version column. A forced version update may be performed immediately,
+ * or may be deferred until a flush or commit. If an entity is removed before a deferred version
+ * update was to have been applied, the forced version update is omitted, since the underlying database
+ * row no longer exists.
+ * <p/>
+ * The persistence implementation is not required to support calling lock(entity, LockMode-Type.WRITE)
+ * on a non-versioned object. When it cannot support a such lock call, it must throw the
+ * PersistenceException. When supported, whether for versioned or non-versioned objects, LockMode-Type.WRITE
+ * must always prevent the phenomena P1 and P2. For non-versioned objects, whether or
+ * not LockModeType.WRITE has any additional behaviour is vendor-specific. Applications that call
+ * lock(entity, LockModeType.WRITE) on non-versioned objects will not be portable.
+ * <p/>
+ * Due to the requirement that LockModeType.WRITE needs to force a version increment,
+ * a new Hibernate LockMode was added to support this behavior: {@link org.hibernate.LockMode#FORCE}.
+ */
+ public void testLockModeTypeWrite() {
+ if ( ! readCommittedIsolationMaintained( "ejb3 lock tests" ) ) {
+ return;
+ }
+ final String initialName = "lock test";
+ // set up some test data
+ Session s1 = getSessions().openSession();
+ Transaction t1 = s1.beginTransaction();
+ Item item = new Item();
+ item.setName( initialName );
+ s1.save( item );
+ t1.commit();
+ s1.close();
+
+ Long itemId = item.getId();
+ long initialVersion = item.getVersion();
+
+ s1 = getSessions().openSession();
+ t1 = s1.beginTransaction();
+ item = ( Item ) s1.get( Item.class, itemId );
+ s1.lock( item, LockMode.FORCE );
+ assertEquals( "no forced version increment", initialVersion + 1, item.getVersion() );
+
+ s1.lock( item, LockMode.FORCE );
+ assertEquals( "subsequent LockMode.FORCE did not no-op", initialVersion + 1, item.getVersion() );
+
+ Session s2 = getSessions().openSession();
+ Transaction t2 = s2.beginTransaction();
+ Item item2 = ( Item ) s2.get( Item.class, itemId );
+ assertEquals( "isolation not maintained", initialName, item2.getName() );
+
+ item.setName( "updated-1" );
+ s1.flush();
+ // currently an unfortunate side effect...
+ assertEquals( initialVersion + 2, item.getVersion() );
+
+ t1.commit();
+ s1.close();
+
+ item2.setName( "updated" );
+ try {
+ t2.commit();
+ fail( "optimisitc lock should have failed" );
+ }
+ catch( Throwable ignore ) {
+ // expected behavior
+ t2.rollback();
+ }
+ finally {
+ s2.close();
+ }
+
+ s1 = getSessions().openSession();
+ t1 = s1.beginTransaction();
+ s1.delete( item );
+ t1.commit();
+ s1.close();
+ }
+}
Modified: trunk/Hibernate3/test/org/hibernate/test/jpa/lock/RepeatableReadTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/jpa/lock/RepeatableReadTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/jpa/lock/RepeatableReadTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,19 +1,20 @@
package org.hibernate.test.jpa.lock;
+import java.math.BigDecimal;
+
+import junit.framework.Test;
+
+import org.hibernate.LockMode;
import org.hibernate.Session;
+import org.hibernate.StaleObjectStateException;
import org.hibernate.Transaction;
-import org.hibernate.LockMode;
-import org.hibernate.StaleObjectStateException;
+import org.hibernate.dialect.SQLServerDialect;
import org.hibernate.exception.SQLGrammarException;
-import org.hibernate.dialect.SQLServerDialect;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.test.jpa.AbstractJPATest;
import org.hibernate.test.jpa.Item;
import org.hibernate.test.jpa.Part;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import java.math.BigDecimal;
-
/**
* Test that the Hibernate Session complies with REPEATABLE_READ isolation
* semantics.
@@ -27,7 +28,7 @@
}
public static Test suite() {
- return new TestSuite( org.hibernate.test.jpa.lock.RepeatableReadTest.class );
+ return new FunctionalTestClassTestSuite( RepeatableReadTest.class );
}
Modified: trunk/Hibernate3/test/org/hibernate/test/jpa/proxy/JPAProxyTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/jpa/proxy/JPAProxyTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/jpa/proxy/JPAProxyTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,13 +1,14 @@
package org.hibernate.test.jpa.proxy;
+import junit.framework.AssertionFailedError;
+import junit.framework.Test;
+
+import org.hibernate.Hibernate;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.test.jpa.AbstractJPATest;
import org.hibernate.test.jpa.Item;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.hibernate.Hibernate;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.framework.AssertionFailedError;
/**
* Test relation between proxies and get()/load() processing
@@ -21,7 +22,7 @@
}
public static Test suite() {
- return new TestSuite( JPAProxyTest.class );
+ return new FunctionalTestClassTestSuite( JPAProxyTest.class );
}
public void testEjb3ProxyUsage() {
Modified: trunk/Hibernate3/test/org/hibernate/test/jpa/ql/JPAQLComplianceTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/jpa/ql/JPAQLComplianceTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/jpa/ql/JPAQLComplianceTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,11 +1,11 @@
package org.hibernate.test.jpa.ql;
-import org.hibernate.test.jpa.AbstractJPATest;
-import org.hibernate.Session;
-import org.hibernate.hql.ast.QuerySyntaxException;
import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.Session;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.test.jpa.AbstractJPATest;
+
/**
* Tests for various JPAQL compliance issues
*
@@ -17,7 +17,7 @@
}
public static Test suite() {
- return new TestSuite( JPAQLComplianceTest.class );
+ return new FunctionalTestClassTestSuite( JPAQLComplianceTest.class );
}
public void testAliasNameSameAsUnqualifiedEntityName() {
Modified: trunk/Hibernate3/test/org/hibernate/test/jpa/ql/NativeQueryTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/jpa/ql/NativeQueryTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/jpa/ql/NativeQueryTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,10 +1,11 @@
package org.hibernate.test.jpa.ql;
-import org.hibernate.test.jpa.AbstractJPATest;
-import org.hibernate.Session;
import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.Session;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.test.jpa.AbstractJPATest;
+
/**
* todo: describe NativeQueryTest
*
@@ -16,7 +17,7 @@
}
public static Test suite() {
- return new TestSuite( NativeQueryTest.class );
+ return new FunctionalTestClassTestSuite( NativeQueryTest.class );
}
public void testJpaStylePositionalParametersInNativeSql() {
Modified: trunk/Hibernate3/test/org/hibernate/test/jpa/removed/RemovedEntityTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/jpa/removed/RemovedEntityTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/jpa/removed/RemovedEntityTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,10 +1,11 @@
package org.hibernate.test.jpa.removed;
+import junit.framework.Test;
+
+import org.hibernate.Session;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.test.jpa.AbstractJPATest;
import org.hibernate.test.jpa.Item;
-import org.hibernate.Session;
-import junit.framework.Test;
-import junit.framework.TestSuite;
/**
*
@@ -16,7 +17,7 @@
}
public static Test suite() {
- return new TestSuite( RemovedEntityTest.class );
+ return new FunctionalTestClassTestSuite( RemovedEntityTest.class );
}
public void testRemoveThenContains() {
Modified: trunk/Hibernate3/test/org/hibernate/test/lazycache/InstrumentCacheTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/lazycache/InstrumentCacheTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/lazycache/InstrumentCacheTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -2,29 +2,46 @@
package org.hibernate.test.lazycache;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.intercept.FieldInterceptionHelper;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
-import org.hibernate.test.TestCase;
+import org.hibernate.intercept.FieldInterceptionHelper;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class InstrumentCacheTest extends TestCase {
+public class InstrumentCacheTest extends FunctionalTestCase {
public InstrumentCacheTest(String str) {
super(str);
}
- protected boolean overrideCacheStrategy() {
+ public String[] getMappings() {
+ return new String[] { "lazycache/Documents.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
+ }
+
+ public boolean overrideCacheStrategy() {
return false;
}
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( InstrumentCacheTest.class );
+ }
+
+ public static boolean isRunnable() {
+ // TODO : this could be handled via appliesTo()...
+ return FieldInterceptionHelper.isInstrumented( new Document() );
+ }
+
public void testInitFromCache() {
Session s;
Transaction tx;
@@ -65,21 +82,5 @@
s.close();
}
- protected String[] getMappings() {
- return new String[] { "lazycache/Documents.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(InstrumentCacheTest.class);
- }
-
- public static boolean isRunnable() {
- return FieldInterceptionHelper.isInstrumented( new Document() );
- }
-
- protected void configure(Configuration cfg) {
- cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/lazycache/InstrumentCacheTest2.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/lazycache/InstrumentCacheTest2.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/lazycache/InstrumentCacheTest2.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -2,25 +2,41 @@
package org.hibernate.test.lazycache;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.intercept.FieldInterceptionHelper;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
-import org.hibernate.test.TestCase;
+import org.hibernate.intercept.FieldInterceptionHelper;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class InstrumentCacheTest2 extends TestCase {
+public class InstrumentCacheTest2 extends FunctionalTestCase {
public InstrumentCacheTest2(String str) {
super(str);
}
+ public String[] getMappings() {
+ return new String[] { "lazycache/Documents.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( InstrumentCacheTest2.class );
+ }
+
+ public static boolean isRunnable() {
+ return FieldInterceptionHelper.isInstrumented( new Document() );
+ }
+
public void testInitFromCache() {
Session s;
Transaction tx;
@@ -60,22 +76,6 @@
tx.commit();
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "lazycache/Documents.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(InstrumentCacheTest2.class);
- }
-
- public static boolean isRunnable() {
- return FieldInterceptionHelper.isInstrumented( new Document() );
- }
-
- protected void configure(Configuration cfg) {
- cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/lazyonetoone/LazyOneToOneTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/lazyonetoone/LazyOneToOneTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/lazyonetoone/LazyOneToOneTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -4,25 +4,42 @@
import java.util.Date;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.intercept.FieldInterceptionHelper;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
-import org.hibernate.test.TestCase;
+import org.hibernate.intercept.FieldInterceptionHelper;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class LazyOneToOneTest extends TestCase {
+public class LazyOneToOneTest extends FunctionalTestCase {
public LazyOneToOneTest(String str) {
super(str);
}
+ public String[] getMappings() {
+ return new String[] { "lazyonetoone/Person.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty(Environment.MAX_FETCH_DEPTH, "2");
+ cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "false");
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( LazyOneToOneTest.class );
+ }
+
+ public static boolean isRunnable() {
+ return FieldInterceptionHelper.isInstrumented( new Person() );
+ }
+
public void testLazy() throws Exception {
Session s = openSession();
Transaction t = s.beginTransaction();
@@ -64,21 +81,5 @@
t.commit();
s.close();
}
-
- protected void configure(Configuration cfg) {
- cfg.setProperty(Environment.MAX_FETCH_DEPTH, "2");
- cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "false");
- }
- protected String[] getMappings() {
- return new String[] { "lazyonetoone/Person.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(LazyOneToOneTest.class);
- }
-
- public static boolean isRunnable() {
- return FieldInterceptionHelper.isInstrumented( new Person() );
- }
}
Modified: trunk/Hibernate3/test/org/hibernate/test/legacy/ABCProxyTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/legacy/ABCProxyTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/legacy/ABCProxyTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -7,13 +7,14 @@
import java.util.Map;
import junit.framework.Test;
-import junit.framework.TestSuite;
import junit.textui.TestRunner;
+
import org.hibernate.Hibernate;
import org.hibernate.LockMode;
+import org.hibernate.Transaction;
import org.hibernate.classic.Session;
import org.hibernate.dialect.HSQLDialect;
-import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
public class ABCProxyTest extends LegacyTestCase {
@@ -293,7 +294,7 @@
}
public static Test suite() {
- return new TestSuite(ABCProxyTest.class);
+ return new FunctionalTestClassTestSuite( ABCProxyTest.class );
}
public static void main(String[] args) throws Exception {
Modified: trunk/Hibernate3/test/org/hibernate/test/legacy/ABCTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/legacy/ABCTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/legacy/ABCTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -8,6 +8,7 @@
import junit.textui.TestRunner;
import org.hibernate.classic.Session;
import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
public class ABCTest extends LegacyTestCase {
@@ -153,7 +154,7 @@
}
public static Test suite() {
- return new TestSuite(ABCTest.class);
+ return new FunctionalTestClassTestSuite( ABCTest.class );
}
public static void main(String[] args) throws Exception {
@@ -162,6 +163,3 @@
}
-
-
-
Modified: trunk/Hibernate3/test/org/hibernate/test/legacy/CacheTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/legacy/CacheTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/legacy/CacheTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -2,29 +2,28 @@
package org.hibernate.test.legacy;
import junit.framework.Test;
-import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.hibernate.cache.Cache;
import org.hibernate.cache.CacheConcurrencyStrategy;
import org.hibernate.cache.CacheProvider;
import org.hibernate.cache.ReadWriteCache;
+import org.hibernate.cache.HashtableCacheProvider;
import org.hibernate.cache.CacheConcurrencyStrategy.SoftLock;
+import org.hibernate.junit.UnitTestCase;
-public class CacheTest extends TestCase {
+public class CacheTest extends UnitTestCase {
- public CacheTest(String arg0) {
- super(arg0);
+ public CacheTest(String name) {
+ super( name );
}
public static Test suite() {
- return new TestSuite(CacheTest.class);
+ return new TestSuite( CacheTest.class );
}
public void testCaches() throws Exception {
- //doTestCache( new CoherenceCacheProvider() );
-// steve - commented this out becuase it is breaking the build after the package rename
- //doTestCache( new Provider() );
+ doTestCache( new HashtableCacheProvider() );
}
public void doTestCache(CacheProvider cacheProvider) throws Exception {
Modified: trunk/Hibernate3/test/org/hibernate/test/legacy/ComponentNotNullTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/legacy/ComponentNotNullTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/legacy/ComponentNotNullTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -4,11 +4,12 @@
import java.util.ArrayList;
import junit.framework.Test;
-import junit.framework.TestSuite;
import junit.textui.TestRunner;
+
import org.hibernate.PropertyValueException;
import org.hibernate.Session;
import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* Test some cases of not-null properties inside components.
@@ -21,10 +22,7 @@
super(x);
}
- /**
- * @see org.hibernate.test.TestCase#getMappings()
- */
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] {
"legacy/ComponentNotNullMaster.hbm.xml",
"legacy/One.hbm.xml",
@@ -33,7 +31,7 @@
}
public static Test suite() {
- return new TestSuite(ComponentNotNullTest.class);
+ return new FunctionalTestClassTestSuite( ComponentNotNullTest.class );
}
public static void main(String[] args) throws Exception {
Modified: trunk/Hibernate3/test/org/hibernate/test/legacy/ConfigurationPerformanceTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/legacy/ConfigurationPerformanceTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/legacy/ConfigurationPerformanceTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -16,12 +16,12 @@
import java.io.PrintWriter;
import junit.framework.Test;
-import junit.framework.TestCase;
import junit.framework.TestSuite;
import junit.textui.TestRunner;
import org.hibernate.HibernateException;
import org.hibernate.SessionFactory;
+import org.hibernate.junit.UnitTestCase;
import org.hibernate.cfg.Configuration;
import org.hibernate.classic.Session;
@@ -29,7 +29,7 @@
* @author MAX
*
*/
-public class ConfigurationPerformanceTest extends TestCase /** purposely not extending hibernate test case to manage the configuration loading 100% on it's own */ {
+public class ConfigurationPerformanceTest extends UnitTestCase {
String[] files = new String[] {
"legacy/ABC.hbm.xml",
@@ -76,7 +76,11 @@
};
boolean keepFilesAround = false ; // set to true to be able to "coldstart" start.
-
+
+ public ConfigurationPerformanceTest(String string) {
+ super( string );
+ }
+
public void testLoadingAndSerializationOfConfiguration() throws HibernateException, FileNotFoundException, IOException, ClassNotFoundException {
String prefix = "./test/org/hibernate/test/";
Modified: trunk/Hibernate3/test/org/hibernate/test/legacy/CustomSQLTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/legacy/CustomSQLTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/legacy/CustomSQLTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -5,7 +5,10 @@
import java.util.ArrayList;
import java.util.List;
+import junit.framework.Test;
+
import org.hibernate.HibernateException;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.classic.Session;
import org.hibernate.dialect.HSQLDialect;
import org.hibernate.dialect.MySQLDialect;
@@ -24,6 +27,10 @@
return new String[] { "legacy/CustomSQL.hbm.xml" };
}
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( CustomSQLTest.class );
+ }
+
public void testInsert() throws HibernateException, SQLException {
if ( getDialect() instanceof HSQLDialect ) return;
Modified: trunk/Hibernate3/test/org/hibernate/test/legacy/FooBarTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/legacy/FooBarTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/legacy/FooBarTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -20,7 +20,6 @@
import java.util.TreeSet;
import junit.framework.Test;
-import junit.framework.TestSuite;
import junit.textui.TestRunner;
import org.hibernate.Criteria;
@@ -30,7 +29,6 @@
import org.hibernate.HibernateException;
import org.hibernate.LazyInitializationException;
import org.hibernate.LockMode;
-import org.hibernate.ObjectDeletedException;
import org.hibernate.ObjectNotFoundException;
import org.hibernate.Query;
import org.hibernate.QueryException;
@@ -56,14 +54,14 @@
import org.hibernate.dialect.PointbaseDialect;
import org.hibernate.dialect.PostgreSQLDialect;
import org.hibernate.dialect.SAPDBDialect;
-import org.hibernate.dialect.SQLServerDialect;
import org.hibernate.dialect.SybaseDialect;
import org.hibernate.dialect.TimesTenDialect;
+import org.hibernate.dialect.Dialect;
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.jmx.HibernateService;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.mapping.RootClass;
import org.hibernate.proxy.HibernateProxy;
-import org.hibernate.test.TestCase;
import org.hibernate.type.Type;
import org.hibernate.util.JoinedIterator;
import org.hibernate.util.SerializationHelper;
@@ -75,6 +73,44 @@
super(arg);
}
+ public String[] getMappings() {
+ return new String[] {
+ "legacy/FooBar.hbm.xml",
+ "legacy/Baz.hbm.xml",
+ "legacy/Qux.hbm.xml",
+ "legacy/Glarch.hbm.xml",
+ "legacy/Fum.hbm.xml",
+ "legacy/Fumm.hbm.xml",
+ "legacy/Fo.hbm.xml",
+ "legacy/One.hbm.xml",
+ "legacy/Many.hbm.xml",
+ "legacy/Immutable.hbm.xml",
+ "legacy/Fee.hbm.xml",
+ "legacy/Vetoer.hbm.xml",
+ "legacy/Holder.hbm.xml",
+ "legacy/Location.hbm.xml",
+ "legacy/Stuff.hbm.xml",
+ "legacy/Container.hbm.xml",
+ "legacy/Simple.hbm.xml",
+ "legacy/XY.hbm.xml"
+ };
+ }
+
+ public void configure(Configuration cfg) {
+ super.configure( cfg );
+ if ( Dialect.getDialect() instanceof OracleDialect ) {
+ ( (RootClass) cfg.getClassMapping("org.hibernate.test.legacy.Foo") ).setForceDiscriminator(false);
+ }
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( FooBarTest.class );
+ }
+
+ public static void main(String[] args) throws Exception {
+ TestRunner.run( suite() );
+ }
+
public void testSaveOrUpdateCopyAny() throws Exception {
Session s = openSession();
Bar bar = new Bar();
@@ -4742,42 +4778,4 @@
s.close();
}
- public static Test suite() {
- return new TestSuite(FooBarTest.class);
- }
-
- public static void main(String[] args) throws Exception {
- TestRunner.run( suite() );
- }
-
- protected void configure(Configuration cfg) {
- super.configure( cfg );
- if ( getDialect() instanceof OracleDialect ) {
- ( (RootClass) cfg.getClassMapping("org.hibernate.test.legacy.Foo") ).setForceDiscriminator(false);
- }
- }
-
- protected String[] getMappings() {
- return new String[] {
- "legacy/FooBar.hbm.xml",
- "legacy/Baz.hbm.xml",
- "legacy/Qux.hbm.xml",
- "legacy/Glarch.hbm.xml",
- "legacy/Fum.hbm.xml",
- "legacy/Fumm.hbm.xml",
- "legacy/Fo.hbm.xml",
- "legacy/One.hbm.xml",
- "legacy/Many.hbm.xml",
- "legacy/Immutable.hbm.xml",
- "legacy/Fee.hbm.xml",
- "legacy/Vetoer.hbm.xml",
- "legacy/Holder.hbm.xml",
- "legacy/Location.hbm.xml",
- "legacy/Stuff.hbm.xml",
- "legacy/Container.hbm.xml",
- "legacy/Simple.hbm.xml",
- "legacy/XY.hbm.xml"
- };
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/legacy/FumTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/legacy/FumTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/legacy/FumTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -20,7 +20,6 @@
import java.util.Set;
import junit.framework.Test;
-import junit.framework.TestSuite;
import junit.textui.TestRunner;
import org.hibernate.Criteria;
@@ -39,7 +38,8 @@
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.dialect.PointbaseDialect;
import org.hibernate.dialect.TimesTenDialect;
-import org.hibernate.transform.AliasToBeanResultTransformer;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.transform.Transformers;
import org.hibernate.type.DateType;
import org.hibernate.type.EntityType;
@@ -53,6 +53,37 @@
public FumTest(String arg) {
super(arg);
}
+
+ public String[] getMappings() {
+ return new String[] {
+ "legacy/FooBar.hbm.xml",
+ "legacy/Baz.hbm.xml",
+ "legacy/Qux.hbm.xml",
+ "legacy/Glarch.hbm.xml",
+ "legacy/Fum.hbm.xml",
+ "legacy/Fumm.hbm.xml",
+ "legacy/Fo.hbm.xml",
+ "legacy/One.hbm.xml",
+ "legacy/Many.hbm.xml",
+ "legacy/Immutable.hbm.xml",
+ "legacy/Fee.hbm.xml",
+ "legacy/Vetoer.hbm.xml",
+ "legacy/Holder.hbm.xml",
+ "legacy/Location.hbm.xml",
+ "legacy/Stuff.hbm.xml",
+ "legacy/Container.hbm.xml",
+ "legacy/Simple.hbm.xml",
+ "legacy/Middle.hbm.xml"
+ };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( FumTest.class );
+ }
+
+ public static void main(String[] args) throws Exception {
+ TestRunner.run( suite() );
+ }
public void testQuery() {
Session s = openSession();
@@ -278,7 +309,7 @@
private FumCompositeID fumKey(String str, boolean aCompositeQueryTest) {
FumCompositeID id = new FumCompositeID();
- if ( getDialect() instanceof MckoiDialect ) {
+ if ( Dialect.getDialect() instanceof MckoiDialect ) {
GregorianCalendar now = new GregorianCalendar();
GregorianCalendar cal = new GregorianCalendar(
now.get(java.util.Calendar.YEAR),
@@ -841,36 +872,6 @@
}
}
- public String[] getMappings() {
- return new String[] {
- "legacy/FooBar.hbm.xml",
- "legacy/Baz.hbm.xml",
- "legacy/Qux.hbm.xml",
- "legacy/Glarch.hbm.xml",
- "legacy/Fum.hbm.xml",
- "legacy/Fumm.hbm.xml",
- "legacy/Fo.hbm.xml",
- "legacy/One.hbm.xml",
- "legacy/Many.hbm.xml",
- "legacy/Immutable.hbm.xml",
- "legacy/Fee.hbm.xml",
- "legacy/Vetoer.hbm.xml",
- "legacy/Holder.hbm.xml",
- "legacy/Location.hbm.xml",
- "legacy/Stuff.hbm.xml",
- "legacy/Container.hbm.xml",
- "legacy/Simple.hbm.xml",
- "legacy/Middle.hbm.xml"
- };
- }
-
- public static Test suite() {
- return new TestSuite(FumTest.class);
- }
- public static void main(String[] args) throws Exception {
- TestRunner.run( suite() );
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/legacy/IJ2Test.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/legacy/IJ2Test.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/legacy/IJ2Test.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -3,27 +3,30 @@
import java.io.Serializable;
-
-
import junit.framework.Test;
-import junit.framework.TestSuite;
-
-
-
import org.hibernate.LockMode;
-
import org.hibernate.classic.Session;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
public class IJ2Test extends LegacyTestCase {
- public void testUnionSubclass() throws Exception {
+ public IJ2Test(String x) {
+ super(x);
+ }
- //if ( getDialect() instanceof MySQLDialect ) return;
+ public String[] getMappings() {
+ return new String[] { "legacy/IJ2.hbm.xml" };
+ }
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( IJ2Test.class );
+ }
+
+ public void testUnionSubclass() throws Exception {
Session s = getSessions().openSession();
I i = new I();
i.setName( "i" );
@@ -123,16 +126,4 @@
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "legacy/IJ2.hbm.xml" };
- }
-
- public IJ2Test(String x) {
- super(x);
- }
-
- public static Test suite() {
- return new TestSuite(IJ2Test.class);
- }
}
Modified: trunk/Hibernate3/test/org/hibernate/test/legacy/IJTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/legacy/IJTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/legacy/IJTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -4,18 +4,30 @@
import java.io.Serializable;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.LockMode;
import org.hibernate.classic.Session;
import org.hibernate.dialect.HSQLDialect;
import org.hibernate.dialect.OracleDialect;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
public class IJTest extends LegacyTestCase {
+ public IJTest(String x) {
+ super(x);
+ }
+
+ public String[] getMappings() {
+ return new String[] { "legacy/IJ.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( IJTest.class );
+ }
+
public void testFormulaDiscriminator() throws Exception {
if ( ( getDialect() instanceof OracleDialect ) || ( getDialect() instanceof HSQLDialect ) ) return;
Session s = getSessions().openSession();
@@ -69,16 +81,4 @@
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "legacy/IJ.hbm.xml" };
- }
-
- public IJTest(String x) {
- super(x);
- }
-
- public static Test suite() {
- return new TestSuite(IJTest.class);
- }
}
Modified: trunk/Hibernate3/test/org/hibernate/test/legacy/LegacyTestCase.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/legacy/LegacyTestCase.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/legacy/LegacyTestCase.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,15 +1,15 @@
package org.hibernate.test.legacy;
-import org.hibernate.test.TestCase;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.hql.classic.ClassicQueryTranslatorFactory;
import org.hibernate.util.StringHelper;
+import org.hibernate.junit.functional.FunctionalTestCase;
/**
* @author Steve Ebersole
*/
-public abstract class LegacyTestCase extends TestCase {
+public abstract class LegacyTestCase extends FunctionalTestCase {
public static final String USE_ANTLR_PARSER_PROP = "legacy.use_antlr_hql_parser";
private final boolean useAntlrParser;
@@ -28,7 +28,7 @@
}
}
- protected void configure(Configuration cfg) {
+ public void configure(Configuration cfg) {
super.configure( cfg );
if ( !useAntlrParser ) {
cfg.setProperty( Environment.QUERY_TRANSLATOR, ClassicQueryTranslatorFactory.class.getName() );
Modified: trunk/Hibernate3/test/org/hibernate/test/legacy/MapTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/legacy/MapTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/legacy/MapTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -6,24 +6,36 @@
import java.util.List;
import java.util.Map;
+import junit.framework.Test;
+
+import org.hibernate.EntityMode;
import org.hibernate.Session;
-import org.hibernate.criterion.Example;
-import org.hibernate.criterion.Expression;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
-import org.hibernate.EntityMode;
+import org.hibernate.criterion.Example;
+import org.hibernate.criterion.Expression;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
-
public class MapTest extends LegacyTestCase {
public MapTest(String x) {
super(x);
}
+ public String[] getMappings() {
+ return new String[] { "legacy/Map.hbm.xml", "legacy/Commento.hbm.xml", "legacy/Marelo.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ super.configure( cfg );
+ cfg.setProperty( Environment.DEFAULT_ENTITY_MODE, EntityMode.MAP.toString() );
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( MapTest.class );
+ }
+
public void testMap() throws Exception {
Session s = openSession().getSession(EntityMode.MAP);
@@ -148,28 +160,5 @@
s.close();
}
- public String[] getMappings() {
- return new String[] { "legacy/Map.hbm.xml", "legacy/Commento.hbm.xml", "legacy/Marelo.hbm.xml" };
- }
-
- protected void configure(Configuration cfg) {
- super.configure( cfg );
- cfg.setProperty(Environment.DEFAULT_ENTITY_MODE, EntityMode.MAP.toString());
- }
-
- public static Test suite() {
- return new TestSuite(MapTest.class);
- }
-
- public static void main(String[] args) throws Exception {
- TestRunner.run( suite() );
- }
-
}
-
-
-
-
-
-
Modified: trunk/Hibernate3/test/org/hibernate/test/legacy/MasterDetailTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/legacy/MasterDetailTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/legacy/MasterDetailTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,10 +1,6 @@
//$Id$
package org.hibernate.test.legacy;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.sql.Connection;
import java.util.ArrayList;
@@ -14,8 +10,6 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
import org.hibernate.Hibernate;
import org.hibernate.LockMode;
@@ -25,13 +19,12 @@
import org.hibernate.classic.Session;
import org.hibernate.criterion.Example;
import org.hibernate.criterion.Expression;
-import org.hibernate.dialect.DerbyDialect;
import org.hibernate.dialect.HSQLDialect;
import org.hibernate.dialect.MckoiDialect;
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.dialect.Oracle9Dialect;
import org.hibernate.dialect.SAPDBDialect;
-import org.hibernate.dialect.SybaseDialect;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.mapping.MetaAttribute;
import org.hibernate.mapping.PersistentClass;
@@ -42,6 +35,23 @@
super(arg);
}
+ public String[] getMappings() {
+ return new String[] {
+ "legacy/MasterDetail.hbm.xml",
+ "legacy/Custom.hbm.xml",
+ "legacy/Category.hbm.xml",
+ "legacy/Nameable.hbm.xml",
+ "legacy/SingleSeveral.hbm.xml",
+ "legacy/WZ.hbm.xml",
+ "legacy/UpDown.hbm.xml",
+ "legacy/Eye.hbm.xml"
+ };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( MasterDetailTest.class );
+ }
+
public void testOuterJoin() throws Exception {
Session s = openSession();
Eye e = new Eye();
@@ -1023,31 +1033,4 @@
s.close();
}
- public String[] getMappings() {
- return new String[] {
- "legacy/MasterDetail.hbm.xml",
- "legacy/Custom.hbm.xml",
- "legacy/Category.hbm.xml",
- "legacy/Nameable.hbm.xml",
- "legacy/SingleSeveral.hbm.xml",
- "legacy/WZ.hbm.xml",
- "legacy/UpDown.hbm.xml",
- "legacy/Eye.hbm.xml"
- };
- }
-
- public static Test suite() {
- return new TestSuite(MasterDetailTest.class);
- }
-
- public static void main(String[] args) throws Exception {
- TestRunner.run( suite() );
- }
-
}
-
-
-
-
-
-
Modified: trunk/Hibernate3/test/org/hibernate/test/legacy/MultiTableTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/legacy/MultiTableTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/legacy/MultiTableTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -10,8 +10,6 @@
import java.util.Set;
import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
import org.hibernate.Criteria;
import org.hibernate.FetchMode;
@@ -20,6 +18,7 @@
import org.hibernate.classic.Session;
import org.hibernate.criterion.Expression;
import org.hibernate.dialect.MySQLDialect;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
public class MultiTableTest extends LegacyTestCase {
@@ -28,6 +27,14 @@
super(arg0);
}
+ public String[] getMappings() {
+ return new String[] { "legacy/Multi.hbm.xml", "legacy/MultiExtends.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( MultiTableTest.class );
+ }
+
public void testCriteria() throws Exception {
Session s = openSession();
Transaction t = s.beginTransaction();
@@ -612,15 +619,4 @@
sess.close();
}
- public String[] getMappings() {
- return new String[] { "legacy/Multi.hbm.xml", "legacy/MultiExtends.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(MultiTableTest.class);
- }
-
- public static void main(String[] args) throws Exception {
- TestRunner.run( suite() );
- }
}
Modified: trunk/Hibernate3/test/org/hibernate/test/legacy/NonReflectiveBinderTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/legacy/NonReflectiveBinderTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/legacy/NonReflectiveBinderTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -5,10 +5,8 @@
import java.util.Map;
import junit.framework.Test;
-import junit.framework.TestCase;
import junit.framework.TestSuite;
-import org.hibernate.MappingException;
import org.hibernate.cfg.Configuration;
import org.hibernate.mapping.Bag;
import org.hibernate.mapping.Collection;
@@ -16,57 +14,38 @@
import org.hibernate.mapping.MetaAttribute;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
+import org.hibernate.junit.UnitTestCase;
-public class NonReflectiveBinderTest extends TestCase {
+public class NonReflectiveBinderTest extends UnitTestCase {
- Configuration cfg;
- private Class lastTestClass;
+ private Configuration cfg;
- public static Test suite() {
- return new TestSuite(NonReflectiveBinderTest.class);
+ public NonReflectiveBinderTest(String x) {
+ super( x );
}
- Configuration getCfg() {
- return cfg;
- }
-
public String[] getMappings() {
return new String[] { "legacy/Wicked.hbm.xml"};
}
- void buildConfiguration(String[] files) throws MappingException {
-
- try {
- setCfg( new Configuration() );
-
- for (int i=0; i<files.length; i++) {
- if ( !files[i].startsWith("net/") ) files[i] = "org/hibernate/test/" + files[i];
- getCfg().addResource( files[i], TestCase.class.getClassLoader() );
- }
- } catch (MappingException e) {
- throw e;
- }
-
+ public static Test suite() {
+ return new TestSuite( NonReflectiveBinderTest.class );
}
protected void setUp() throws Exception {
- if ( getCfg()==null || lastTestClass!=getClass() ) {
- buildConfiguration( getMappings() );
- lastTestClass = getClass();
- }
+ super.setUp();
+ cfg = new Configuration()
+ .addResource( "org/hibernate/test/legacy/Wicked.hbm.xml" );
+ cfg.buildMappings();
}
- /**
- * @param configuration
- */
- private void setCfg(Configuration configuration) {
- cfg = configuration;
+ protected void tearDown() throws Exception {
+ cfg = null;
+ super.tearDown();
}
public void testMetaInheritance() {
- Configuration cfg = getCfg();
- cfg.buildMappings();
PersistentClass cm = cfg.getClassMapping("org.hibernate.test.legacy.Wicked");
Map m = cm.getMetaAttributes();
assertNotNull(m);
@@ -120,9 +99,6 @@
// HBX-718
public void testNonMutatedInheritance() {
- Configuration cfg = getCfg();
- cfg.buildMappings();
-
PersistentClass cm = cfg.getClassMapping("org.hibernate.test.legacy.Wicked");
MetaAttribute metaAttribute = cm.getMetaAttribute( "globalmutated" );
@@ -204,8 +180,6 @@
}
public void testComparator() {
- Configuration cfg = getCfg();
- cfg.buildMappings();
PersistentClass cm = cfg.getClassMapping("org.hibernate.test.legacy.Wicked");
Property property = cm.getProperty("sortedEmployee");
Modified: trunk/Hibernate3/test/org/hibernate/test/legacy/OneToOneCacheTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/legacy/OneToOneCacheTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/legacy/OneToOneCacheTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -4,11 +4,11 @@
import java.io.Serializable;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* Simple testcase to illustrate HB-992
@@ -17,44 +17,48 @@
*/
public class OneToOneCacheTest extends LegacyTestCase {
+ private Serializable generatedId;
+
public OneToOneCacheTest(String x) {
- super(x);
+ super( x );
}
+ public String[] getMappings() {
+ return new String[] { "legacy/Object2.hbm.xml", "legacy/MainObject.hbm.xml" };
+ }
+
public static Test suite() {
- return new TestSuite(OneToOneCacheTest.class);
+ return new FunctionalTestClassTestSuite( OneToOneCacheTest.class );
}
- private Serializable generatedId;
-
public void testOneToOneCache() throws HibernateException {
- //create a new MainObject
- createMainObject();
- // load the MainObject
- readMainObject();
+ //create a new MainObject
+ createMainObject();
+ // load the MainObject
+ readMainObject();
- //create and add Ojbect2
- addObject2();
+ //create and add Ojbect2
+ addObject2();
- //here the newly created Object2 is written to the database
- //but the MainObject does not know it yet
- MainObject mainObject = readMainObject();
+ //here the newly created Object2 is written to the database
+ //but the MainObject does not know it yet
+ MainObject mainObject = readMainObject();
- assertNotNull(mainObject.getObj2());
+ assertNotNull( mainObject.getObj2() );
- // after evicting, it works.
- getSessions().evict(MainObject.class);
+ // after evicting, it works.
+ getSessions().evict( MainObject.class );
- mainObject = readMainObject();
+ mainObject = readMainObject();
- assertNotNull(mainObject.getObj2());
+ assertNotNull( mainObject.getObj2() );
}
/**
* creates a new MainObject
- *
+ * <p/>
* one hibernate transaction !
*/
private void createMainObject() throws HibernateException {
@@ -62,9 +66,9 @@
Transaction tx = session.beginTransaction();
MainObject mo = new MainObject();
- mo.setDescription("Main Test");
+ mo.setDescription( "Main Test" );
- generatedId = session.save(mo);
+ generatedId = session.save( mo );
tx.commit();
session.close();
@@ -73,7 +77,7 @@
/**
* loads the newly created MainObject
* and adds a new Object2 to it
- *
+ * <p/>
* one hibernate transaction
*/
private void addObject2() throws HibernateException {
@@ -81,13 +85,13 @@
Transaction tx = session.beginTransaction();
MainObject mo =
- (MainObject) session.load(MainObject.class, generatedId);
+ ( MainObject ) session.load( MainObject.class, generatedId );
Object2 toAdd = new Object2();
- toAdd.setDummy("test");
+ toAdd.setDummy( "test" );
//toAdd should now be saved by cascade
- mo.setObj2(toAdd);
+ mo.setObj2( toAdd );
tx.commit();
session.close();
@@ -96,7 +100,7 @@
/**
* reads the newly created MainObject
* and its Object2 if it exists
- *
+ * <p/>
* one hibernate transaction
*/
private MainObject readMainObject() throws HibernateException {
@@ -106,19 +110,11 @@
Serializable id = generatedId;
- MainObject mo = (MainObject) session.load(MainObject.class, id);
+ MainObject mo = ( MainObject ) session.load( MainObject.class, id );
tx.commit();
session.close();
return mo;
}
-
-
- /* (non-Javadoc)
- * @see org.hibernate.test.TestCase#getMappings()
- */
- protected String[] getMappings() {
- return new String[] { "legacy/Object2.hbm.xml", "legacy/MainObject.hbm.xml" };
- }
}
Modified: trunk/Hibernate3/test/org/hibernate/test/legacy/ParentChildTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/legacy/ParentChildTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/legacy/ParentChildTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -13,8 +13,6 @@
import java.util.Map;
import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
import org.hibernate.Criteria;
import org.hibernate.FetchMode;
@@ -29,6 +27,7 @@
import org.hibernate.dialect.DB2Dialect;
import org.hibernate.dialect.HSQLDialect;
import org.hibernate.dialect.MySQLDialect;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
public class ParentChildTest extends LegacyTestCase {
@@ -37,6 +36,33 @@
super(x);
}
+ public String[] getMappings() {
+ return new String[] {
+ "legacy/ParentChild.hbm.xml",
+ "legacy/FooBar.hbm.xml",
+ "legacy/Baz.hbm.xml",
+ "legacy/Qux.hbm.xml",
+ "legacy/Glarch.hbm.xml",
+ "legacy/Fum.hbm.xml",
+ "legacy/Fumm.hbm.xml",
+ "legacy/Fo.hbm.xml",
+ "legacy/One.hbm.xml",
+ "legacy/Many.hbm.xml",
+ "legacy/Immutable.hbm.xml",
+ "legacy/Fee.hbm.xml",
+ "legacy/Vetoer.hbm.xml",
+ "legacy/Holder.hbm.xml",
+ "legacy/Simple.hbm.xml",
+ "legacy/Container.hbm.xml",
+ "legacy/Circular.hbm.xml",
+ "legacy/Stuff.hbm.xml"
+ };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( ParentChildTest.class );
+ }
+
public void testReplicate() throws Exception {
Session s = openSession();
Container baz = new Container();
@@ -1046,35 +1072,4 @@
session.close();
}
- public static Test suite() {
- return new TestSuite(ParentChildTest.class);
- }
-
- public String[] getMappings() {
- return new String[] {
- "legacy/ParentChild.hbm.xml",
- "legacy/FooBar.hbm.xml",
- "legacy/Baz.hbm.xml",
- "legacy/Qux.hbm.xml",
- "legacy/Glarch.hbm.xml",
- "legacy/Fum.hbm.xml",
- "legacy/Fumm.hbm.xml",
- "legacy/Fo.hbm.xml",
- "legacy/One.hbm.xml",
- "legacy/Many.hbm.xml",
- "legacy/Immutable.hbm.xml",
- "legacy/Fee.hbm.xml",
- "legacy/Vetoer.hbm.xml",
- "legacy/Holder.hbm.xml",
- "legacy/Simple.hbm.xml",
- "legacy/Container.hbm.xml",
- "legacy/Circular.hbm.xml",
- "legacy/Stuff.hbm.xml"
- };
- }
-
- public static void main(String[] args) throws Exception {
- TestRunner.run( suite() );
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/legacy/QueryByExampleTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/legacy/QueryByExampleTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/legacy/QueryByExampleTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -4,13 +4,13 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
+
import org.hibernate.Criteria;
+import org.hibernate.Transaction;
import org.hibernate.classic.Session;
import org.hibernate.criterion.Example;
import org.hibernate.criterion.Expression;
-import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* Query by example test to allow nested components
@@ -19,28 +19,18 @@
*/
public class QueryByExampleTest extends LegacyTestCase {
- /**
- * @param name test name
- */
public QueryByExampleTest(String name) {
super(name);
}
- public void setUp() throws Exception {
- super.setUp();
- }
-
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
- /**
- * @see org.hibernate.test.TestCase#getMappings()
- */
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "legacy/Componentizable.hbm.xml" };
}
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( QueryByExampleTest.class );
+ }
+
public void testSimpleQBE() throws Exception {
deleteData();
initData();
@@ -143,12 +133,4 @@
}
return master;
}
-
- public static Test suite() {
- return new TestSuite(QueryByExampleTest.class);
- }
-
- public static void main(String[] args) throws Exception {
- TestRunner.run( suite() );
- }
}
Modified: trunk/Hibernate3/test/org/hibernate/test/legacy/SQLFunctionsTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/legacy/SQLFunctionsTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/legacy/SQLFunctionsTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -10,11 +10,9 @@
import java.util.Map;
import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.hibernate.Hibernate;
import org.hibernate.Query;
import org.hibernate.ScrollableResults;
@@ -30,6 +28,7 @@
import org.hibernate.dialect.SybaseDialect;
import org.hibernate.dialect.TimesTenDialect;
import org.hibernate.dialect.function.SQLFunction;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
public class SQLFunctionsTest extends LegacyTestCase {
@@ -40,6 +39,18 @@
super(name);
}
+ public String[] getMappings() {
+ return new String[] {
+ "legacy/AltSimple.hbm.xml",
+ "legacy/Broken.hbm.xml",
+ "legacy/Blobber.hbm.xml"
+ };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( SQLFunctionsTest.class );
+ }
+
public void testDialectSQLFunctions() throws Exception {
Session s = openSession();
@@ -645,28 +656,4 @@
}
-
- public String[] getMappings() {
- return new String[] {
- "legacy/AltSimple.hbm.xml",
- "legacy/Broken.hbm.xml",
- "legacy/Blobber.hbm.xml"
- };
- }
-
- public static Test suite() {
- return new TestSuite(SQLFunctionsTest.class);
- }
-
- public static void main(String[] args) throws Exception {
- TestRunner.run( suite() );
- }
-
}
-
-
-
-
-
-
-
Modified: trunk/Hibernate3/test/org/hibernate/test/legacy/SQLLoaderTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/legacy/SQLLoaderTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/legacy/SQLLoaderTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -7,8 +7,6 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
import org.hibernate.HibernateException;
import org.hibernate.Query;
@@ -17,20 +15,37 @@
import org.hibernate.dialect.HSQLDialect;
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.dialect.Oracle9Dialect;
+import org.hibernate.dialect.OracleDialect;
import org.hibernate.dialect.PostgreSQLDialect;
-import org.hibernate.dialect.SQLServerDialect;
import org.hibernate.dialect.TimesTenDialect;
-import org.hibernate.dialect.OracleDialect;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
public class SQLLoaderTest extends LegacyTestCase {
static int nextInt = 1;
static long nextLong = 1;
+
public SQLLoaderTest(String arg) {
super(arg);
}
+ public String[] getMappings() {
+ return new String[] {
+ "legacy/ABC.hbm.xml",
+ "legacy/Category.hbm.xml",
+ "legacy/Simple.hbm.xml",
+ "legacy/Fo.hbm.xml",
+ "legacy/SingleSeveral.hbm.xml",
+ "legacy/Componentizable.hbm.xml",
+ "legacy/CompositeIdId.hbm.xml"
+ };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( SQLLoaderTest.class );
+ }
+
public void testTS() throws Exception {
if (getDialect() instanceof Oracle9Dialect) return;
Session session = openSession();
@@ -604,23 +619,23 @@
public void testCompositeIdId() throws HibernateException, SQLException {
// issue HHH-21
Session s = openSession();
-
+
CompositeIdId id = new CompositeIdId();
id.setName("Max");
id.setSystem("c64");
id.setId("games");
-
+
s.save(id);
s.flush();
s.connection().commit();
s.close();
-
+
s = openSession();
// having a composite id with one property named id works since the map used by sqlloader to map names to properties handles it.
Query query = s.createSQLQuery("select system as {c.system}, id as {c.id}, name as {c.name}, foo as {c.composite.foo}, bar as {c.composite.bar} from CompositeIdId where system=? and id=?", "c", CompositeIdId.class);
query.setString(0, "c64");
query.setString(1, "games");
-
+
CompositeIdId id2 = (CompositeIdId) query.uniqueResult();
check(id, id2);
@@ -629,25 +644,20 @@
s.close();
s = openSession();
-
+
CompositeIdId useForGet = new CompositeIdId();
useForGet.setSystem("c64");
useForGet.setId("games");
// this doesn't work since the verification does not take column span into respect!
CompositeIdId getted = (CompositeIdId) s.get(CompositeIdId.class, useForGet);
check(id,getted);
-
-
+
+
s.connection().commit();
s.close();
-
+
}
-
-
- /**
- * @param id
- * @param id2
- */
+
private void check(CompositeIdId id, CompositeIdId id2) {
assertEquals(id,id2);
assertEquals(id.getName(), id2.getName());
@@ -655,24 +665,4 @@
assertEquals(id.getSystem(), id2.getSystem());
}
- public String[] getMappings() {
- return new String[] {
- "legacy/ABC.hbm.xml",
- "legacy/Category.hbm.xml",
- "legacy/Simple.hbm.xml",
- "legacy/Fo.hbm.xml",
- "legacy/SingleSeveral.hbm.xml",
- "legacy/Componentizable.hbm.xml",
- "legacy/CompositeIdId.hbm.xml"
- };
- }
-
- public static Test suite() {
- return new TestSuite(SQLLoaderTest.class);
- }
-
- public static void main(String[] args) throws Exception {
- TestRunner.run( suite() );
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/legacy/StatisticsTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/legacy/StatisticsTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/legacy/StatisticsTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,15 +1,13 @@
//$Id$
package org.hibernate.test.legacy;
-
import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.stat.Statistics;
/**
@@ -20,6 +18,14 @@
public StatisticsTest(String x) {
super(x);
}
+
+ public String[] getMappings() {
+ return new String[] { "legacy/ABC.hbm.xml", "legacy/ABCExtends.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( StatisticsTest.class );
+ }
public void testSessionStats() throws Exception {
@@ -53,20 +59,5 @@
stats.setStatisticsEnabled(isStats);
}
-
- public String[] getMappings() {
- return new String[] { "legacy/ABC.hbm.xml", "legacy/ABCExtends.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(StatisticsTest.class);
- }
-
- /**
- * @see org.hibernate.test.TestCase#getMappings()
- */
- public static void main(String[] args) throws Exception {
- TestRunner.run( suite() );
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/lob/BlobTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/lob/BlobTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/lob/BlobTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -2,15 +2,15 @@
import java.sql.Blob;
+import junit.framework.AssertionFailedError;
import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.framework.AssertionFailedError;
-import org.hibernate.test.DatabaseSpecificTestCase;
-import org.hibernate.Session;
import org.hibernate.Hibernate;
import org.hibernate.LockMode;
+import org.hibernate.Session;
import org.hibernate.dialect.Dialect;
+import org.hibernate.junit.functional.DatabaseSpecificFunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.util.ArrayHelper;
/**
@@ -18,23 +18,27 @@
*
* @author Steve Ebersole
*/
-public class BlobTest extends DatabaseSpecificTestCase {
+public class BlobTest extends DatabaseSpecificFunctionalTestCase {
private static final int BLOB_SIZE = 10000;
public BlobTest(String name) {
super( name );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "lob/LobMappings.hbm.xml" };
}
public static Test suite() {
- return new TestSuite( BlobTest.class );
+ return new FunctionalTestClassTestSuite( BlobTest.class );
}
public boolean appliesTo(Dialect dialect) {
- return supportsExpectedLobUsagePattern();
+ if ( ! dialect.supportsExpectedLobUsagePattern() ) {
+ reportSkip( "database/driver does not support expected LOB usage pattern", "LOB support" );
+ return false;
+ }
+ return true;
}
public void testBoundedMaterializedBlobAccess() {
Modified: trunk/Hibernate3/test/org/hibernate/test/lob/ClobTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/lob/ClobTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/lob/ClobTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -3,14 +3,14 @@
import java.sql.Clob;
import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.hibernate.test.DatabaseSpecificTestCase;
-import org.hibernate.Session;
import org.hibernate.Hibernate;
import org.hibernate.LockMode;
+import org.hibernate.Session;
+import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.H2Dialect;
-import org.hibernate.dialect.Dialect;
+import org.hibernate.junit.functional.DatabaseSpecificFunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* Test various access scenarios for eager and lazy materialization
@@ -19,23 +19,27 @@
*
* @author Steve Ebersole
*/
-public class ClobTest extends DatabaseSpecificTestCase {
+public class ClobTest extends DatabaseSpecificFunctionalTestCase {
private static final int CLOB_SIZE = 10000;
public ClobTest(String name) {
super( name );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "lob/LobMappings.hbm.xml" };
}
public static Test suite() {
- return new TestSuite( ClobTest.class );
+ return new FunctionalTestClassTestSuite( ClobTest.class );
}
public boolean appliesTo(Dialect dialect) {
- return supportsExpectedLobUsagePattern();
+ if ( ! dialect.supportsExpectedLobUsagePattern() ) {
+ reportSkip( "database/driver does not support expected LOB usage pattern", "LOB support" );
+ return false;
+ }
+ return true;
}
public void testBoundedMaterializedClobAccess() {
Modified: trunk/Hibernate3/test/org/hibernate/test/lob/LobMappings.hbm.xml
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/lob/LobMappings.hbm.xml 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/lob/LobMappings.hbm.xml 2006-12-12 23:28:04 UTC (rev 10977)
@@ -12,10 +12,10 @@
<property name="serialData" column="SER_DATA" type="serializable"/>
- <property name="materializedClob" column="MAT_CLOB_DATA" type="text"/>
+ <property name="materializedClob" column="MAT_CLOB_DATA" type="text" length="15000"/>
<property name="clobLocator" column="CLOB_DATA" type="clob" />
- <property name="materializedBlob" column="MAT_BLOB_DATA" type="org.hibernate.test.lob.MaterializedBlobType"/>
+ <property name="materializedBlob" column="MAT_BLOB_DATA" type="org.hibernate.test.lob.MaterializedBlobType" length="15000"/>
<property name="blobLocator" column="BLOB_DATA" type="blob" />
</class>
Modified: trunk/Hibernate3/test/org/hibernate/test/lob/SerializableTypeTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/lob/SerializableTypeTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/lob/SerializableTypeTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -2,28 +2,28 @@
package org.hibernate.test.lob;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Session;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* Tests of {@link org.hibernate.type.SerializableType}
*
* @author Steve Ebersole
*/
-public class SerializableTypeTest extends TestCase {
+public class SerializableTypeTest extends FunctionalTestCase {
public SerializableTypeTest(String testName) {
super( testName );
}
- public static Test suite() {
- return new TestSuite( SerializableTypeTest.class );
+ public String[] getMappings() {
+ return new String[] { "lob/LobMappings.hbm.xml" };
}
- protected String[] getMappings() {
- return new String[] { "lob/LobMappings.hbm.xml" };
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( SerializableTypeTest.class );
}
public String getCacheConcurrencyStrategy() {
Modified: trunk/Hibernate3/test/org/hibernate/test/manytomany/ManyToManyTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/manytomany/ManyToManyTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/manytomany/ManyToManyTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -2,7 +2,6 @@
package org.hibernate.test.manytomany;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.FetchMode;
import org.hibernate.Hibernate;
@@ -10,16 +9,29 @@
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class ManyToManyTest extends TestCase {
+public class ManyToManyTest extends FunctionalTestCase {
public ManyToManyTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "manytomany/UserGroup.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "false");
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( ManyToManyTest.class );
+ }
public void testManyToManyWithFormula() {
Session s = openSession();
@@ -111,18 +123,5 @@
t.commit();
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "manytomany/UserGroup.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(ManyToManyTest.class);
- }
-
- protected void configure(Configuration cfg) {
- cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "false");
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/manytomany/ordered/OrderedManyToManyTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/manytomany/ordered/OrderedManyToManyTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/manytomany/ordered/OrderedManyToManyTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,27 +1,40 @@
package org.hibernate.test.manytomany.ordered;
-import org.hibernate.test.TestCase;
+import java.util.List;
+
+import junit.framework.Test;
+
+import org.hibernate.Criteria;
+import org.hibernate.FetchMode;
+import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.Hibernate;
-import org.hibernate.FetchMode;
-import org.hibernate.Criteria;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
-import java.util.List;
-
/**
* @author Gavin King
*/
-public class OrderedManyToManyTest extends TestCase {
+public class OrderedManyToManyTest extends FunctionalTestCase {
public OrderedManyToManyTest(String str) {
super(str);
}
+ public String[] getMappings() {
+ return new String[] { "manytomany/ordered/UserGroup.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty( Environment.USE_SECOND_LEVEL_CACHE, "false");
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( OrderedManyToManyTest.class );
+ }
+
public void testManyToManyOrdering() {
Session s = openSession();
Transaction t = s.beginTransaction();
@@ -122,16 +135,5 @@
private User extractUser(List users, int position) {
return ( User ) users.get( position );
}
- protected String[] getMappings() {
- return new String[] { "manytomany/ordered/UserGroup.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite( OrderedManyToManyTest.class);
- }
-
- protected void configure(Configuration cfg) {
- cfg.setProperty( Environment.USE_SECOND_LEVEL_CACHE, "false");
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/map/MapIndexFormulaTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/map/MapIndexFormulaTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/map/MapIndexFormulaTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -5,20 +5,28 @@
import java.util.Map;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class MapIndexFormulaTest extends TestCase {
+public class MapIndexFormulaTest extends FunctionalTestCase {
public MapIndexFormulaTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "map/UserGroup.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( MapIndexFormulaTest.class );
+ }
public void testIndexFormulaMap() {
Session s = openSession();
@@ -94,14 +102,6 @@
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "map/UserGroup.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(MapIndexFormulaTest.class);
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/mapcompelem/MapCompositeElementTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/mapcompelem/MapCompositeElementTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/mapcompelem/MapCompositeElementTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -4,20 +4,28 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class MapCompositeElementTest extends TestCase {
+public class MapCompositeElementTest extends FunctionalTestCase {
public MapCompositeElementTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "mapcompelem/ProductPart.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( MapCompositeElementTest.class );
+ }
public void testMapCompositeElementWithFormula() {
Session s = openSession();
@@ -103,14 +111,6 @@
t.commit();
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "mapcompelem/ProductPart.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(MapCompositeElementTest.class);
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/mapelemformula/MapElementFormulaTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/mapelemformula/MapElementFormulaTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/mapelemformula/MapElementFormulaTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -2,21 +2,29 @@
package org.hibernate.test.mapelemformula;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class MapElementFormulaTest extends TestCase {
+public class MapElementFormulaTest extends FunctionalTestCase {
public MapElementFormulaTest(String str) {
super(str);
}
-
+
+ public String[] getMappings() {
+ return new String[] { "mapelemformula/UserGroup.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( MapElementFormulaTest.class );
+ }
+
public void testManyToManyFormula() {
Session s = openSession();
Transaction t = s.beginTransaction();
@@ -47,14 +55,6 @@
t.commit();
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "mapelemformula/UserGroup.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(MapElementFormulaTest.class);
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/mapping/PersistentClassVisitorTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/mapping/PersistentClassVisitorTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/mapping/PersistentClassVisitorTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -5,7 +5,6 @@
package org.hibernate.test.mapping;
import junit.framework.Test;
-import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.hibernate.mapping.JoinedSubclass;
@@ -14,13 +13,18 @@
import org.hibernate.mapping.SingleTableSubclass;
import org.hibernate.mapping.Subclass;
import org.hibernate.mapping.UnionSubclass;
+import org.hibernate.junit.UnitTestCase;
/**
* @author max
*
*/
-public class PersistentClassVisitorTest extends TestCase {
+public class PersistentClassVisitorTest extends UnitTestCase {
+ public PersistentClassVisitorTest(String string) {
+ super( string );
+ }
+
static public class PersistentClassVisitorValidator implements PersistentClassVisitor {
private Object validate(Class expectedClass, Object visitee) {
Modified: trunk/Hibernate3/test/org/hibernate/test/mapping/ValueVisitorTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/mapping/ValueVisitorTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/mapping/ValueVisitorTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -5,7 +5,6 @@
package org.hibernate.test.mapping;
import junit.framework.Test;
-import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.hibernate.mapping.Any;
@@ -25,13 +24,18 @@
import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Table;
import org.hibernate.mapping.ValueVisitor;
+import org.hibernate.junit.UnitTestCase;
/**
* @author max
*
*/
-public class ValueVisitorTest extends TestCase {
+public class ValueVisitorTest extends UnitTestCase {
+ public ValueVisitorTest(String string) {
+ super( string );
+ }
+
static public class ValueVisitorValidator implements ValueVisitor {
/* (non-Javadoc)
Modified: trunk/Hibernate3/test/org/hibernate/test/mappingexception/MappingExceptionTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/mappingexception/MappingExceptionTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/mappingexception/MappingExceptionTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -18,7 +18,8 @@
import org.hibernate.InvalidMappingException;
import org.hibernate.MappingException;
import org.hibernate.MappingNotFoundException;
-import org.hibernate.test.TestCase;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.junit.UnitTestCase;
import org.hibernate.util.ConfigHelper;
/**
@@ -26,20 +27,21 @@
*
* @author Max Rydahl Andersen
*/
-public class MappingExceptionTest extends TestCase {
+public class MappingExceptionTest extends UnitTestCase {
public MappingExceptionTest(String name) {
super( name );
}
- protected String[] getMappings() {
- return new String[] { "mappingexception/User.hbm.xml" };
+ public static Test suite() {
+ return new TestSuite( MappingExceptionTest.class );
}
public void testNotFound() throws MappingException, MalformedURLException {
+ Configuration cfg = new Configuration();
try {
- getCfg().addCacheableFile( "completelybogus.hbm.xml" );
+ cfg.addCacheableFile( "completelybogus.hbm.xml" );
fail();
}
catch ( MappingNotFoundException e ) {
@@ -48,7 +50,7 @@
}
try {
- getCfg().addCacheableFile( new File( "completelybogus.hbm.xml" ) );
+ cfg.addCacheableFile( new File( "completelybogus.hbm.xml" ) );
fail();
}
catch ( MappingNotFoundException e ) {
@@ -57,7 +59,7 @@
}
try {
- getCfg().addClass( Hibernate.class ); // TODO: String.class result in npe, because no classloader exists for it
+ cfg.addClass( Hibernate.class ); // TODO: String.class result in npe, because no classloader exists for it
fail();
}
catch ( MappingNotFoundException inv ) {
@@ -66,7 +68,7 @@
}
try {
- getCfg().addFile( "completelybogus.hbm.xml" );
+ cfg.addFile( "completelybogus.hbm.xml" );
fail();
}
catch ( MappingNotFoundException e ) {
@@ -75,7 +77,7 @@
}
try {
- getCfg().addFile( new File( "completelybogus.hbm.xml" ) );
+ cfg.addFile( new File( "completelybogus.hbm.xml" ) );
fail();
}
catch ( MappingNotFoundException inv ) {
@@ -84,7 +86,7 @@
}
try {
- getCfg().addInputStream( new ByteArrayInputStream( new byte[0] ) );
+ cfg.addInputStream( new ByteArrayInputStream( new byte[0] ) );
fail();
}
catch ( InvalidMappingException inv ) {
@@ -93,7 +95,7 @@
}
try {
- getCfg().addResource( "nothere" );
+ cfg.addResource( "nothere" );
fail();
}
catch ( MappingNotFoundException inv ) {
@@ -102,7 +104,7 @@
}
try {
- getCfg().addResource( "nothere", getClass().getClassLoader() );
+ cfg.addResource( "nothere", getClass().getClassLoader() );
fail();
}
catch ( MappingNotFoundException inv ) {
@@ -111,7 +113,7 @@
}
try {
- getCfg().addURL( new URL( "file://nothere" ) );
+ cfg.addURL( new URL( "file://nothere" ) );
fail();
}
catch ( InvalidMappingException inv ) {
@@ -121,39 +123,29 @@
}
public void testDuplicateMapping() {
+ String resourceName = "org/hibernate/test/mappingexception/User.hbm.xml";
+ Configuration cfg = new Configuration();
+ cfg.addResource( resourceName );
try {
- getCfg().addResource( getBaseForMappings() + "mappingexception/User.hbm.xml" );
+ cfg.addResource( resourceName );
fail();
}
catch ( InvalidMappingException inv ) {
assertEquals( inv.getType(), "resource" );
- assertEquals( inv.getPath(), getBaseForMappings() + "mappingexception/User.hbm.xml" );
+ assertEquals( inv.getPath(), resourceName );
assertClassAssignability( inv.getCause().getClass(), DuplicateMappingException.class );
}
}
- void copy(InputStream in, File dst) throws IOException {
- OutputStream out = new FileOutputStream( dst );
-
- // Transfer bytes from in to out
- byte[] buf = new byte[1024];
- int len;
- while ( ( len = in.read( buf ) ) > 0 ) {
- out.write( buf, 0, len );
- }
- in.close();
- out.close();
- }
-
public void testInvalidMapping() throws MappingException, IOException {
- String resourceName = getBaseForMappings() + "mappingexception/InvalidMapping.hbm.xml";
-
+ String resourceName = "org/hibernate/test/mappingexception/InvalidMapping.hbm.xml";
File file = File.createTempFile( "TempInvalidMapping", ".hbm.xml" );
file.deleteOnExit();
copy( ConfigHelper.getConfigStream( resourceName ), file );
+ Configuration cfg = new Configuration();
try {
- getCfg().addCacheableFile( file.getAbsolutePath() );
+ cfg.addCacheableFile( file.getAbsolutePath() );
fail();
}
catch ( InvalidMappingException inv ) {
@@ -164,7 +156,7 @@
}
try {
- getCfg().addCacheableFile( file );
+ cfg.addCacheableFile( file );
fail();
}
catch ( InvalidMappingException inv ) {
@@ -175,7 +167,7 @@
}
try {
- getCfg().addClass( InvalidMapping.class );
+ cfg.addClass( InvalidMapping.class );
fail();
}
catch ( InvalidMappingException inv ) {
@@ -185,7 +177,7 @@
}
try {
- getCfg().addFile( file.getAbsolutePath() );
+ cfg.addFile( file.getAbsolutePath() );
fail();
}
catch ( InvalidMappingException inv ) {
@@ -195,7 +187,7 @@
}
try {
- getCfg().addFile( file );
+ cfg.addFile( file );
fail();
}
catch ( InvalidMappingException inv ) {
@@ -206,7 +198,7 @@
try {
- getCfg().addInputStream( ConfigHelper.getResourceAsStream( resourceName ) );
+ cfg.addInputStream( ConfigHelper.getResourceAsStream( resourceName ) );
fail();
}
catch ( InvalidMappingException inv ) {
@@ -216,7 +208,7 @@
}
try {
- getCfg().addResource( resourceName );
+ cfg.addResource( resourceName );
fail();
}
catch ( InvalidMappingException inv ) {
@@ -226,7 +218,7 @@
}
try {
- getCfg().addResource( resourceName, getClass().getClassLoader() );
+ cfg.addResource( resourceName, getClass().getClassLoader() );
fail();
}
catch ( InvalidMappingException inv ) {
@@ -236,7 +228,7 @@
}
try {
- getCfg().addURL( ConfigHelper.findAsResource( resourceName ) );
+ cfg.addURL( ConfigHelper.findAsResource( resourceName ) );
fail();
}
catch ( InvalidMappingException inv ) {
@@ -246,7 +238,16 @@
}
}
- public static Test suite() {
- return new TestSuite( MappingExceptionTest.class );
+ void copy(InputStream in, File dst) throws IOException {
+ OutputStream out = new FileOutputStream( dst );
+
+ // Transfer bytes from in to out
+ byte[] buf = new byte[1024];
+ int len;
+ while ( ( len = in.read( buf ) ) > 0 ) {
+ out.write( buf, 0, len );
+ }
+ in.close();
+ out.close();
}
}
Modified: trunk/Hibernate3/test/org/hibernate/test/mixed/MixedTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/mixed/MixedTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/mixed/MixedTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -2,22 +2,35 @@
package org.hibernate.test.mixed;
import junit.framework.Test;
-import junit.framework.TestSuite;
+
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.dialect.PostgreSQLDialect;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class MixedTest extends TestCase {
+public class MixedTest extends FunctionalTestCase {
public MixedTest(String str) {
super( str );
}
+ public String[] getMappings() {
+ return new String[]{"mixed/Item.hbm.xml"};
+ }
+
+ public String getCacheConcurrencyStrategy() {
+ return null;
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( MixedTest.class );
+ }
+
public void testMixedInheritance() {
Session s = openSession( new DocumentInterceptor() );
Transaction t = s.beginTransaction();
@@ -90,18 +103,5 @@
t.commit();
s.close();
}
-
-
- protected String[] getMappings() {
- return new String[]{"mixed/Item.hbm.xml"};
- }
-
- public static Test suite() {
- return new TestSuite( MixedTest.class );
- }
-
- public String getCacheConcurrencyStrategy() {
- return null;
- }
}
Modified: trunk/Hibernate3/test/org/hibernate/test/naturalid/NaturalIdTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/naturalid/NaturalIdTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/naturalid/NaturalIdTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -4,7 +4,6 @@
import java.lang.reflect.Field;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.HibernateException;
import org.hibernate.Session;
@@ -12,16 +11,31 @@
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.criterion.Restrictions;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class NaturalIdTest extends TestCase {
+public class NaturalIdTest extends FunctionalTestCase {
public NaturalIdTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "naturalid/User.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "true");
+ cfg.setProperty(Environment.USE_QUERY_CACHE, "true");
+ cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( NaturalIdTest.class );
+ }
public void testNaturalIdCheck() throws Exception {
Session s = openSession();
@@ -230,21 +244,5 @@
t.commit();
s.close();
}
-
-
- protected void configure(Configuration cfg) {
- cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "true");
- cfg.setProperty(Environment.USE_QUERY_CACHE, "true");
- cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
- }
-
- protected String[] getMappings() {
- return new String[] { "naturalid/User.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(NaturalIdTest.class);
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/ondelete/OnDeleteTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/ondelete/OnDeleteTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/ondelete/OnDeleteTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -4,7 +4,6 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Session;
import org.hibernate.Transaction;
@@ -12,17 +11,30 @@
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.dialect.MySQLInnoDBDialect;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.stat.Statistics;
-import org.hibernate.test.TestCase;
/**
* @author Gavin King
*/
-public class OnDeleteTest extends TestCase {
+public class OnDeleteTest extends FunctionalTestCase {
public OnDeleteTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "ondelete/Person.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( OnDeleteTest.class );
+ }
public void testJoinedSubclass() {
if ( ! supportsCircularCascadeDelete() ) {
@@ -78,17 +90,5 @@
s.close();
}
- protected void configure(Configuration cfg) {
- cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
- }
-
- protected String[] getMappings() {
- return new String[] { "ondelete/Person.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(OnDeleteTest.class);
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/onetomany/OneToManyTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/onetomany/OneToManyTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/onetomany/OneToManyTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -2,20 +2,28 @@
package org.hibernate.test.onetomany;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class OneToManyTest extends TestCase {
+public class OneToManyTest extends FunctionalTestCase {
public OneToManyTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "onetomany/Parent.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( OneToManyTest.class );
+ }
public void testOneToManyLinkTable() {
Session s = openSession();
@@ -82,14 +90,5 @@
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "onetomany/Parent.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(OneToManyTest.class);
- }
-
}
Added: trunk/Hibernate3/test/org/hibernate/test/onetoone/OneToOneSuite.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/onetoone/OneToOneSuite.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/onetoone/OneToOneSuite.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,27 @@
+package org.hibernate.test.onetoone;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.hibernate.test.onetoone.formula.OneToOneFormulaTest;
+import org.hibernate.test.onetoone.joined.JoinedSubclassOneToOneTest;
+import org.hibernate.test.onetoone.link.OneToOneLinkTest;
+import org.hibernate.test.onetoone.nopojo.DynamicMapOneToOneTest;
+import org.hibernate.test.onetoone.singletable.DiscrimSubclassOneToOneTest;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class OneToOneSuite {
+ public static Test suite() {
+ TestSuite suite = new TestSuite( "one-to-one suite" );
+ suite.addTest( OneToOneFormulaTest.suite() );
+ suite.addTest( JoinedSubclassOneToOneTest.suite() );
+ suite.addTest( OneToOneLinkTest.suite() );
+ suite.addTest( DynamicMapOneToOneTest.suite() );
+ suite.addTest( DiscrimSubclassOneToOneTest.suite() );
+ return suite;
+ }
+}
Copied: trunk/Hibernate3/test/org/hibernate/test/onetoone/formula/Address.java (from rev 10964, trunk/Hibernate3/test/org/hibernate/test/onetooneformula/Address.java)
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/onetooneformula/Address.java 2006-12-08 16:06:49 UTC (rev 10964)
+++ trunk/Hibernate3/test/org/hibernate/test/onetoone/formula/Address.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,57 @@
+//$Id$
+package org.hibernate.test.onetoone.formula;
+
+import java.io.Serializable;
+
+/**
+ * @author Gavin King
+ */
+public class Address implements Serializable {
+ private Person person;
+ private String type;
+ private String street;
+ private String state;
+ private String zip;
+
+ public Person getPerson() {
+ return person;
+ }
+ public void setPerson(Person person) {
+ this.person = person;
+ }
+ public String getState() {
+ return state;
+ }
+ public void setState(String state) {
+ this.state = state;
+ }
+ public String getStreet() {
+ return street;
+ }
+ public void setStreet(String street) {
+ this.street = street;
+ }
+ public String getType() {
+ return type;
+ }
+ public void setType(String type) {
+ this.type = type;
+ }
+ public String getZip() {
+ return zip;
+ }
+ public void setZip(String zip) {
+ this.zip = zip;
+ }
+
+ public boolean equals(Object that) {
+ if ( !(that instanceof Address) ) return false;
+ Address address = (Address) that;
+ return address.getType().equals(type) &&
+ address.getPerson().getName().equals( person.getName() );
+ }
+
+ public int hashCode() {
+ return person.getName().hashCode() + type.hashCode();
+ }
+}
Property changes on: trunk/Hibernate3/test/org/hibernate/test/onetoone/formula/Address.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/Hibernate3/test/org/hibernate/test/onetoone/formula/OneToOneFormulaTest.java (from rev 10964, trunk/Hibernate3/test/org/hibernate/test/onetooneformula/OneToOneFormulaTest.java)
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/onetooneformula/OneToOneFormulaTest.java 2006-12-08 16:06:49 UTC (rev 10964)
+++ trunk/Hibernate3/test/org/hibernate/test/onetoone/formula/OneToOneFormulaTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,164 @@
+//$Id$
+package org.hibernate.test.onetoone.formula;
+
+import junit.framework.Test;
+
+import org.hibernate.FetchMode;
+import org.hibernate.Hibernate;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
+import org.hibernate.criterion.Property;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+
+/**
+ * @author Gavin King
+ */
+public class OneToOneFormulaTest extends FunctionalTestCase {
+
+ public OneToOneFormulaTest(String str) {
+ super(str);
+ }
+
+ public String[] getMappings() {
+ return new String[] { "onetoone/formula/Person.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "false");
+ cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
+ cfg.setProperty(Environment.DEFAULT_BATCH_FETCH_SIZE, "2");
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( OneToOneFormulaTest.class );
+ }
+
+ public void testOneToOneFormula() {
+ Person p = new Person();
+ p.setName("Gavin King");
+ Address a = new Address();
+ a.setPerson(p);
+ a.setType("HOME");
+ a.setZip("3181");
+ a.setState("VIC");
+ a.setStreet("Karbarook Ave");
+ p.setAddress(a);
+
+ Session s = openSession();
+ Transaction t = s.beginTransaction();
+ s.persist(p);
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ p = (Person) s.createQuery("from Person").uniqueResult();
+
+ assertNotNull( p.getAddress() );
+ assertTrue( Hibernate.isInitialized( p.getAddress() ) );
+ assertNull( p.getMailingAddress() );
+
+ s.clear();
+
+ p = (Person) s.createQuery("from Person p left join fetch p.mailingAddress left join fetch p.address").uniqueResult();
+
+ assertNotNull( p.getAddress() );
+ assertTrue( Hibernate.isInitialized( p.getAddress() ) );
+ assertNull( p.getMailingAddress() );
+
+ s.clear();
+
+ p = (Person) s.createQuery("from Person p left join fetch p.address").uniqueResult();
+
+ assertNotNull( p.getAddress() );
+ assertTrue( Hibernate.isInitialized( p.getAddress() ) );
+ assertNull( p.getMailingAddress() );
+
+ s.clear();
+
+ p = (Person) s.createCriteria(Person.class)
+ .createCriteria("address")
+ .add( Property.forName("zip").eq("3181") )
+ .uniqueResult();
+ assertNotNull(p);
+
+ s.clear();
+
+ p = (Person) s.createCriteria(Person.class)
+ .setFetchMode("address", FetchMode.JOIN)
+ .uniqueResult();
+
+ assertNotNull( p.getAddress() );
+ assertTrue( Hibernate.isInitialized( p.getAddress() ) );
+ assertNull( p.getMailingAddress() );
+
+ s.clear();
+
+ p = (Person) s.createCriteria(Person.class)
+ .setFetchMode("mailingAddress", FetchMode.JOIN)
+ .uniqueResult();
+
+ assertNotNull( p.getAddress() );
+ assertTrue( Hibernate.isInitialized( p.getAddress() ) );
+ assertNull( p.getMailingAddress() );
+
+ s.delete(p);
+
+ t.commit();
+ s.close();
+
+ }
+
+ public void testOneToOneEmbeddedCompositeKey() {
+ Person p = new Person();
+ p.setName("Gavin King");
+ Address a = new Address();
+ a.setPerson(p);
+ a.setType("HOME");
+ a.setZip("3181");
+ a.setState("VIC");
+ a.setStreet("Karbarook Ave");
+ p.setAddress(a);
+
+ Session s = openSession();
+ Transaction t = s.beginTransaction();
+ s.persist(p);
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+
+ a = new Address();
+ a.setType("HOME");
+ a.setPerson(p);
+ a = (Address) s.load(Address.class, a);
+ assertFalse( Hibernate.isInitialized(a) );
+ a.getPerson();
+ a.getType();
+ assertFalse( Hibernate.isInitialized(a) );
+ assertEquals(a.getZip(), "3181");
+
+ s.clear();
+
+ a = new Address();
+ a.setType("HOME");
+ a.setPerson(p);
+ Address a2 = (Address) s.get(Address.class, a);
+ assertTrue( Hibernate.isInitialized(a) );
+ assertSame(a2, a);
+ assertSame(a2.getPerson(), p); //this is a little bit desirable
+ assertEquals(a.getZip(), "3181");
+
+ s.delete(a2);
+ s.delete( s.get( Person.class, p.getName() ) ); //this is certainly undesirable! oh well...
+
+ t.commit();
+ s.close();
+
+ }
+
+}
Property changes on: trunk/Hibernate3/test/org/hibernate/test/onetoone/formula/OneToOneFormulaTest.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/Hibernate3/test/org/hibernate/test/onetoone/formula/Person.hbm.xml (from rev 10964, trunk/Hibernate3/test/org/hibernate/test/onetooneformula/Person.hbm.xml)
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/onetooneformula/Person.hbm.xml 2006-12-08 16:06:49 UTC (rev 10964)
+++ trunk/Hibernate3/test/org/hibernate/test/onetoone/formula/Person.hbm.xml 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="org.hibernate.test.onetoone.formula">
+
+ <class name="Person">
+ <id name="name"/>
+ <one-to-one name="address" cascade="all" constrained="false">
+ <formula>name</formula>
+ <formula>'HOME'</formula>
+ </one-to-one>
+ <one-to-one name="mailingAddress" constrained="false">
+ <formula>name</formula>
+ <formula>'MAILING'</formula>
+ </one-to-one>
+ </class>
+
+ <class name="Address" batch-size="2"
+ check="addressType in ('MAILING', 'HOME', 'BUSINESS')">
+ <composite-id>
+ <key-many-to-one name="person"
+ column="personName"/>
+ <key-property name="type"
+ column="addressType"/>
+ </composite-id>
+ <property name="street" type="text"/>
+ <property name="state"/>
+ <property name="zip"/>
+ </class>
+
+</hibernate-mapping>
Property changes on: trunk/Hibernate3/test/org/hibernate/test/onetoone/formula/Person.hbm.xml
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/Hibernate3/test/org/hibernate/test/onetoone/formula/Person.java (from rev 10964, trunk/Hibernate3/test/org/hibernate/test/onetooneformula/Person.java)
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/onetooneformula/Person.java 2006-12-08 16:06:49 UTC (rev 10964)
+++ trunk/Hibernate3/test/org/hibernate/test/onetoone/formula/Person.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,42 @@
+//$Id$
+package org.hibernate.test.onetoone.formula;
+
+import java.io.Serializable;
+
+/**
+ * @author Gavin King
+ */
+public class Person implements Serializable {
+ private String name;
+ private Address address;
+ private Address mailingAddress;
+
+ public Address getAddress() {
+ return address;
+ }
+ public void setAddress(Address address) {
+ this.address = address;
+ }
+ public Address getMailingAddress() {
+ return mailingAddress;
+ }
+ public void setMailingAddress(Address mailingAddress) {
+ this.mailingAddress = mailingAddress;
+ }
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public boolean equals(Object that) {
+ if ( !(that instanceof Person) ) return false;
+ Person person = (Person) that;
+ return person.getName().equals(name);
+ }
+
+ public int hashCode() {
+ return name.hashCode();
+ }
+}
Property changes on: trunk/Hibernate3/test/org/hibernate/test/onetoone/formula/Person.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/Hibernate3/test/org/hibernate/test/onetoone/joined/JoinedSubclassOneToOneTest.java (from rev 10964, trunk/Hibernate3/test/org/hibernate/test/onetoone/joined/OneToOneTest.java)
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/onetoone/joined/OneToOneTest.java 2006-12-08 16:06:49 UTC (rev 10964)
+++ trunk/Hibernate3/test/org/hibernate/test/onetoone/joined/JoinedSubclassOneToOneTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,159 @@
+//$Id$
+package org.hibernate.test.onetoone.joined;
+
+import java.util.List;
+
+import junit.framework.Test;
+
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.stat.EntityStatistics;
+
+/**
+ * @author Gavin King
+ */
+public class JoinedSubclassOneToOneTest extends FunctionalTestCase {
+
+ public JoinedSubclassOneToOneTest(String str) {
+ super(str);
+ }
+
+ public String[] getMappings() {
+ return new String[] { "onetoone/joined/Person.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "false");
+ cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( JoinedSubclassOneToOneTest.class );
+ }
+
+ public void testOneToOneOnSubclass() {
+ Person p = new Person();
+ p.name = "Gavin";
+ Address a = new Address();
+ a.entityName = "Gavin";
+ a.zip = "3181";
+ a.state = "VIC";
+ a.street = "Karbarook Ave";
+ p.address = a;
+
+ Session s = openSession();
+ Transaction t = s.beginTransaction();
+ s.persist(p);
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+
+ EntityStatistics addressStats = getSessions().getStatistics().getEntityStatistics( Address.class.getName() );
+ EntityStatistics mailingAddressStats = getSessions().getStatistics().getEntityStatistics("MailingAddress");
+
+ p = (Person) s.createQuery("from Person p join fetch p.address left join fetch p.mailingAddress").uniqueResult();
+ assertNotNull(p.address); assertNull(p.mailingAddress);
+ s.clear();
+
+ p = (Person) s.createQuery("select p from Person p join fetch p.address left join fetch p.mailingAddress").uniqueResult();
+ assertNotNull(p.address); assertNull(p.mailingAddress);
+ s.clear();
+
+ Object[] stuff = (Object[]) s.createQuery("select p.name, p from Person p join fetch p.address left join fetch p.mailingAddress").uniqueResult();
+ assertEquals(stuff.length, 2);
+ p = (Person) stuff[1];
+ assertNotNull(p.address); assertNull(p.mailingAddress);
+ s.clear();
+
+ assertEquals( addressStats.getFetchCount(), 0 );
+ assertEquals( mailingAddressStats.getFetchCount(), 0 );
+
+ p = (Person) s.createQuery("from Person p join fetch p.address").uniqueResult();
+ assertNotNull(p.address); assertNull(p.mailingAddress);
+ s.clear();
+
+ assertEquals( addressStats.getFetchCount(), 0 );
+ assertEquals( mailingAddressStats.getFetchCount(), 1 );
+
+ p = (Person) s.createQuery("from Person").uniqueResult();
+ assertNotNull(p.address); assertNull(p.mailingAddress);
+ s.clear();
+
+ assertEquals( addressStats.getFetchCount(), 0 );
+ assertEquals( mailingAddressStats.getFetchCount(), 2 );
+
+ p = (Person) s.createQuery("from Entity").uniqueResult();
+ assertNotNull(p.address); assertNull(p.mailingAddress);
+ s.clear();
+
+ assertEquals( addressStats.getFetchCount(), 0 );
+ assertEquals( mailingAddressStats.getFetchCount(), 3 );
+
+ //note that in here join fetch is used for the nullable
+ //one-to-one, due to a very special case of default
+ p = (Person) s.get(Person.class, "Gavin");
+ assertNotNull(p.address); assertNull(p.mailingAddress);
+ s.clear();
+
+ assertEquals( addressStats.getFetchCount(), 0 );
+ assertEquals( mailingAddressStats.getFetchCount(), 3 );
+
+ p = (Person) s.get(Entity.class, "Gavin");
+ assertNotNull(p.address); assertNull(p.mailingAddress);
+ s.clear();
+
+ assertEquals( addressStats.getFetchCount(), 0 );
+ assertEquals( mailingAddressStats.getFetchCount(), 3 );
+
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ Org org = new Org();
+ org.name = "IFA";
+ Address a2 = new Address();
+ a2.entityName = "IFA";
+ a2.zip = "3181";
+ a2.state = "VIC";
+ a2.street = "Orrong Rd";
+ s.persist(org);
+ s.persist(a2);
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ org = (Org) s.get(Entity.class, "IFA");
+ s.clear();
+
+ List list = s.createQuery("from Entity e order by e.name").list();
+ p = (Person) list.get(0);
+ assertNotNull(p.address); assertNull(p.mailingAddress);
+ org = (Org) list.get(1);
+ s.clear();
+
+ list = s.createQuery("from Entity e left join fetch e.address left join fetch e.mailingAddress order by e.name").list();
+ p = (Person) list.get(0);
+ org = (Org) list.get(1);
+ assertNotNull(p.address); assertNull(p.mailingAddress);
+
+ s.clear();
+ s.delete(p);
+ s.delete( p.address );
+ s.delete( org );
+ s.delete( a2 );
+ s.flush();
+ t.commit();
+ s.close();
+
+ }
+
+}
+
Property changes on: trunk/Hibernate3/test/org/hibernate/test/onetoone/joined/JoinedSubclassOneToOneTest.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Deleted: trunk/Hibernate3/test/org/hibernate/test/onetoone/joined/OneToOneTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/onetoone/joined/OneToOneTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/onetoone/joined/OneToOneTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,159 +0,0 @@
-//$Id$
-package org.hibernate.test.onetoone.joined;
-
-import java.util.List;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.cfg.Environment;
-import org.hibernate.stat.EntityStatistics;
-import org.hibernate.test.TestCase;
-
-/**
- * @author Gavin King
- */
-public class OneToOneTest extends TestCase {
-
- public OneToOneTest(String str) {
- super(str);
- }
-
- public void testOneToOneOnSubclass() {
- Person p = new Person();
- p.name = "Gavin";
- Address a = new Address();
- a.entityName = "Gavin";
- a.zip = "3181";
- a.state = "VIC";
- a.street = "Karbarook Ave";
- p.address = a;
-
- Session s = openSession();
- Transaction t = s.beginTransaction();
- s.persist(p);
- t.commit();
- s.close();
-
- s = openSession();
- t = s.beginTransaction();
-
- EntityStatistics addressStats = getSessions().getStatistics().getEntityStatistics( Address.class.getName() );
- EntityStatistics mailingAddressStats = getSessions().getStatistics().getEntityStatistics("MailingAddress");
-
- p = (Person) s.createQuery("from Person p join fetch p.address left join fetch p.mailingAddress").uniqueResult();
- assertNotNull(p.address); assertNull(p.mailingAddress);
- s.clear();
-
- p = (Person) s.createQuery("select p from Person p join fetch p.address left join fetch p.mailingAddress").uniqueResult();
- assertNotNull(p.address); assertNull(p.mailingAddress);
- s.clear();
-
- Object[] stuff = (Object[]) s.createQuery("select p.name, p from Person p join fetch p.address left join fetch p.mailingAddress").uniqueResult();
- assertEquals(stuff.length, 2);
- p = (Person) stuff[1];
- assertNotNull(p.address); assertNull(p.mailingAddress);
- s.clear();
-
- assertEquals( addressStats.getFetchCount(), 0 );
- assertEquals( mailingAddressStats.getFetchCount(), 0 );
-
- p = (Person) s.createQuery("from Person p join fetch p.address").uniqueResult();
- assertNotNull(p.address); assertNull(p.mailingAddress);
- s.clear();
-
- assertEquals( addressStats.getFetchCount(), 0 );
- assertEquals( mailingAddressStats.getFetchCount(), 1 );
-
- p = (Person) s.createQuery("from Person").uniqueResult();
- assertNotNull(p.address); assertNull(p.mailingAddress);
- s.clear();
-
- assertEquals( addressStats.getFetchCount(), 0 );
- assertEquals( mailingAddressStats.getFetchCount(), 2 );
-
- p = (Person) s.createQuery("from Entity").uniqueResult();
- assertNotNull(p.address); assertNull(p.mailingAddress);
- s.clear();
-
- assertEquals( addressStats.getFetchCount(), 0 );
- assertEquals( mailingAddressStats.getFetchCount(), 3 );
-
- //note that in here join fetch is used for the nullable
- //one-to-one, due to a very special case of default
- p = (Person) s.get(Person.class, "Gavin");
- assertNotNull(p.address); assertNull(p.mailingAddress);
- s.clear();
-
- assertEquals( addressStats.getFetchCount(), 0 );
- assertEquals( mailingAddressStats.getFetchCount(), 3 );
-
- p = (Person) s.get(Entity.class, "Gavin");
- assertNotNull(p.address); assertNull(p.mailingAddress);
- s.clear();
-
- assertEquals( addressStats.getFetchCount(), 0 );
- assertEquals( mailingAddressStats.getFetchCount(), 3 );
-
- t.commit();
- s.close();
-
- s = openSession();
- t = s.beginTransaction();
- Org org = new Org();
- org.name = "IFA";
- Address a2 = new Address();
- a2.entityName = "IFA";
- a2.zip = "3181";
- a2.state = "VIC";
- a2.street = "Orrong Rd";
- s.persist(org);
- s.persist(a2);
- t.commit();
- s.close();
-
- s = openSession();
- t = s.beginTransaction();
- org = (Org) s.get(Entity.class, "IFA");
- s.clear();
-
- List list = s.createQuery("from Entity e order by e.name").list();
- p = (Person) list.get(0);
- assertNotNull(p.address); assertNull(p.mailingAddress);
- org = (Org) list.get(1);
- s.clear();
-
- list = s.createQuery("from Entity e left join fetch e.address left join fetch e.mailingAddress order by e.name").list();
- p = (Person) list.get(0);
- org = (Org) list.get(1);
- assertNotNull(p.address); assertNull(p.mailingAddress);
-
- s.clear();
- s.delete(p);
- s.delete( p.address );
- s.delete( org );
- s.delete( a2 );
- s.flush();
- t.commit();
- s.close();
-
- }
-
- protected String[] getMappings() {
- return new String[] { "onetoone/joined/Person.hbm.xml" };
- }
-
- protected void configure(Configuration cfg) {
- cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "false");
- cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
- }
-
- public static Test suite() {
- return new TestSuite(OneToOneTest.class);
- }
-
-}
-
Copied: trunk/Hibernate3/test/org/hibernate/test/onetoone/link/Customer.java (from rev 10964, trunk/Hibernate3/test/org/hibernate/test/onetoonelink/Customer.java)
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/onetoonelink/Customer.java 2006-12-08 16:06:49 UTC (rev 10964)
+++ trunk/Hibernate3/test/org/hibernate/test/onetoone/link/Customer.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,22 @@
+//$Id$
+package org.hibernate.test.onetoone.link;
+
+/**
+ * @author Gavin King
+ */
+public class Customer {
+ private Long id;
+ private Person person;
+ public Person getPerson() {
+ return person;
+ }
+ public void setPerson(Person person) {
+ this.person = person;
+ }
+ public Long getId() {
+ return id;
+ }
+ public void setId(Long id) {
+ this.id = id;
+ }
+}
Property changes on: trunk/Hibernate3/test/org/hibernate/test/onetoone/link/Customer.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/Hibernate3/test/org/hibernate/test/onetoone/link/Employee.java (from rev 10964, trunk/Hibernate3/test/org/hibernate/test/onetoonelink/Employee.java)
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/onetoonelink/Employee.java 2006-12-08 16:06:49 UTC (rev 10964)
+++ trunk/Hibernate3/test/org/hibernate/test/onetoone/link/Employee.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,22 @@
+//$Id$
+package org.hibernate.test.onetoone.link;
+
+/**
+ * @author Gavin King
+ */
+public class Employee {
+ private Long id;
+ private Person person;
+ public Person getPerson() {
+ return person;
+ }
+ public void setPerson(Person person) {
+ this.person = person;
+ }
+ public Long getId() {
+ return id;
+ }
+ public void setId(Long id) {
+ this.id = id;
+ }
+}
Property changes on: trunk/Hibernate3/test/org/hibernate/test/onetoone/link/Employee.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/Hibernate3/test/org/hibernate/test/onetoone/link/OneToOneLinkTest.java (from rev 10964, trunk/Hibernate3/test/org/hibernate/test/onetoonelink/OneToOneTest.java)
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/onetoonelink/OneToOneTest.java 2006-12-08 16:06:49 UTC (rev 10964)
+++ trunk/Hibernate3/test/org/hibernate/test/onetoone/link/OneToOneLinkTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,91 @@
+//$Id$
+package org.hibernate.test.onetoone.link;
+
+import java.util.Date;
+
+import junit.framework.Test;
+
+import org.hibernate.Hibernate;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+
+/**
+ * @author Gavin King
+ */
+public class OneToOneLinkTest extends FunctionalTestCase {
+
+ public OneToOneLinkTest(String str) {
+ super(str);
+ }
+
+ public String[] getMappings() {
+ return new String[] { "onetoone/link/Person.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( OneToOneLinkTest.class );
+ }
+
+ public void testOneToOneViaAssociationTable() {
+ Person p = new Person();
+ p.setName("Gavin King");
+ p.setDob( new Date() );
+ Employee e = new Employee();
+ p.setEmployee(e);
+ e.setPerson(p);
+
+ Session s = openSession();
+ Transaction t = s.beginTransaction();
+ s.persist(p);
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ e = (Employee) s.createQuery("from Employee e where e.person.name like 'Gavin%'").uniqueResult();
+ assertEquals( e.getPerson().getName(), "Gavin King" );
+ assertFalse( Hibernate.isInitialized( e.getPerson() ) );
+ assertNull( e.getPerson().getCustomer() );
+ s.clear();
+
+ e = (Employee) s.createQuery("from Employee e where e.person.dob = :date")
+ .setDate("date", new Date() )
+ .uniqueResult();
+ assertEquals( e.getPerson().getName(), "Gavin King" );
+ assertFalse( Hibernate.isInitialized( e.getPerson() ) );
+ assertNull( e.getPerson().getCustomer() );
+ s.clear();
+
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+
+ e = (Employee) s.createQuery("from Employee e join fetch e.person p left join fetch p.customer").uniqueResult();
+ assertTrue( Hibernate.isInitialized( e.getPerson() ) );
+ assertNull( e.getPerson().getCustomer() );
+ Customer c = new Customer();
+ e.getPerson().setCustomer(c);
+ c.setPerson( e.getPerson() );
+
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+
+ e = (Employee) s.createQuery("from Employee e join fetch e.person p left join fetch p.customer").uniqueResult();
+ assertTrue( Hibernate.isInitialized( e.getPerson() ) );
+ assertTrue( Hibernate.isInitialized( e.getPerson().getCustomer() ) );
+ assertNotNull( e.getPerson().getCustomer() );
+ s.delete(e);
+ t.commit();
+ s.close();
+
+ }
+
+}
+
Property changes on: trunk/Hibernate3/test/org/hibernate/test/onetoone/link/OneToOneLinkTest.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/Hibernate3/test/org/hibernate/test/onetoone/link/Person.hbm.xml (from rev 10964, trunk/Hibernate3/test/org/hibernate/test/onetoonelink/Person.hbm.xml)
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/onetoonelink/Person.hbm.xml 2006-12-08 16:06:49 UTC (rev 10964)
+++ trunk/Hibernate3/test/org/hibernate/test/onetoone/link/Person.hbm.xml 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,69 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+ <!--
+
+ Demonstrates the mapping of two subtyping one-to-one relationships
+ to association tables using <many-to-one> nested inside <join>.
+ Note that the <join> elements specify optional="true", and that
+ there is an inverse="true" side of both joins.
+
+ -->
+
+<hibernate-mapping package="org.hibernate.test.onetoone.link">
+
+ <class name="Person">
+ <id name="name"/>
+ <property name="dob" type="date"/>
+ <join table="employeePerson"
+ inverse="true"
+ optional="true">
+ <key column="personId" unique="true"/>
+ <many-to-one name="employee"
+ column="employeeId"
+ cascade="all"
+ not-null="true"/>
+ </join>
+ <join table="customerPerson"
+ inverse="true"
+ optional="true">
+ <key column="personId" unique="true"/>
+ <many-to-one name="customer"
+ column="customerId"
+ cascade="all"
+ not-null="true"/>
+ </join>
+ </class>
+
+ <class name="Employee">
+ <id name="id" column="employeeId">
+ <generator class="native"/>
+ </id>
+ <join table="employeePerson"
+ optional="true">
+ <key column="employeeId"/>
+ <many-to-one name="person"
+ column="personId"
+ cascade="all"
+ not-null="true"
+ unique="true"/>
+ </join>
+ </class>
+
+ <class name="Customer">
+ <id name="id" column="customerId">
+ <generator class="native"/>
+ </id>
+ <join table="customerPerson" optional="true">
+ <key column="customerId"/>
+ <many-to-one name="person"
+ column="personId"
+ cascade="all"
+ not-null="true"
+ unique="true"/>
+ </join>
+ </class>
+
+</hibernate-mapping>
Property changes on: trunk/Hibernate3/test/org/hibernate/test/onetoone/link/Person.hbm.xml
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/Hibernate3/test/org/hibernate/test/onetoone/link/Person.java (from rev 10964, trunk/Hibernate3/test/org/hibernate/test/onetoonelink/Person.java)
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/onetoonelink/Person.java 2006-12-08 16:06:49 UTC (rev 10964)
+++ trunk/Hibernate3/test/org/hibernate/test/onetoone/link/Person.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,38 @@
+//$Id$
+package org.hibernate.test.onetoone.link;
+
+import java.util.Date;
+
+/**
+ * @author Gavin King
+ */
+public class Person {
+ private String name;
+ private Date dob;
+ private Employee employee;
+ private Customer customer;
+ public Customer getCustomer() {
+ return customer;
+ }
+ public void setCustomer(Customer customer) {
+ this.customer = customer;
+ }
+ public Employee getEmployee() {
+ return employee;
+ }
+ public void setEmployee(Employee employee) {
+ this.employee = employee;
+ }
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public Date getDob() {
+ return dob;
+ }
+ public void setDob(Date dob) {
+ this.dob = dob;
+ }
+}
Property changes on: trunk/Hibernate3/test/org/hibernate/test/onetoone/link/Person.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/Hibernate3/test/org/hibernate/test/onetoone/nopojo/DynamicMapOneToOneTest.java (from rev 10964, trunk/Hibernate3/test/org/hibernate/test/onetoone/nopojo/OneToOneTest.java)
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/onetoone/nopojo/OneToOneTest.java 2006-12-08 16:06:49 UTC (rev 10964)
+++ trunk/Hibernate3/test/org/hibernate/test/onetoone/nopojo/DynamicMapOneToOneTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,82 @@
+//$Id$
+package org.hibernate.test.onetoone.nopojo;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.Test;
+
+import org.hibernate.EntityMode;
+import org.hibernate.Session;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.stat.EntityStatistics;
+
+/**
+ * @author Gavin King
+ */
+public class DynamicMapOneToOneTest extends FunctionalTestCase {
+
+ public DynamicMapOneToOneTest(String str) {
+ super(str);
+ }
+
+ public String[] getMappings() {
+ return new String[] { "onetoone/nopojo/Person.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "false");
+ cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
+ cfg.setProperty( Environment.DEFAULT_ENTITY_MODE, EntityMode.MAP.toString() );
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( DynamicMapOneToOneTest.class );
+ }
+
+ public void testOneToOneOnSubclass() {
+ Map person = new HashMap();
+ person.put( "name", "Steve" );
+ Map address = new HashMap();
+ address.put( "zip", "12345" );
+ address.put( "state", "TX" );
+ address.put( "street", "123 Main St" );
+
+ person.put( "address", address );
+ address.put( "owner", person );
+
+ Session s = openSession();
+ s.beginTransaction();
+ s.persist( "Person", person );
+ s.getTransaction().commit();
+ s.close();
+
+ s = openSession();
+ s.beginTransaction();
+
+ EntityStatistics addressStats = getSessions().getStatistics().getEntityStatistics( "Address" );
+
+ person = ( Map ) s.createQuery( "from Person p join fetch p.address" ).uniqueResult();
+ assertNotNull( "could not locate person", person );
+ assertNotNull( "could not locate persons address", person.get( "address" ) );
+ s.clear();
+
+ Object[] tuple = ( Object[] ) s.createQuery( "select p.name, p from Person p join fetch p.address" ).uniqueResult();
+ assertEquals( tuple.length, 2 );
+ person = ( Map ) tuple[1];
+ assertNotNull( "could not locate person", person );
+ assertNotNull( "could not locate persons address", person.get( "address" ) );
+
+ s.delete( "Person", person );
+
+ s.getTransaction().commit();
+ s.close();
+
+ assertEquals( addressStats.getFetchCount(), 0 );
+ }
+
+}
+
Property changes on: trunk/Hibernate3/test/org/hibernate/test/onetoone/nopojo/DynamicMapOneToOneTest.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Deleted: trunk/Hibernate3/test/org/hibernate/test/onetoone/nopojo/OneToOneTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/onetoone/nopojo/OneToOneTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/onetoone/nopojo/OneToOneTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,84 +0,0 @@
-//$Id$
-package org.hibernate.test.onetoone.nopojo;
-
-import java.util.List;
-import java.util.Map;
-import java.util.HashMap;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.hibernate.EntityMode;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.cfg.Environment;
-import org.hibernate.stat.EntityStatistics;
-import org.hibernate.test.TestCase;
-
-/**
- * @author Gavin King
- */
-public class OneToOneTest extends TestCase {
-
- public OneToOneTest(String str) {
- super(str);
- }
-
- public void testOneToOneOnSubclass() {
- Map person = new HashMap();
- person.put( "name", "Steve" );
- Map address = new HashMap();
- address.put( "zip", "12345" );
- address.put( "state", "TX" );
- address.put( "street", "123 Main St" );
-
- person.put( "address", address );
- address.put( "owner", person );
-
- Session s = openSession();
- s.beginTransaction();
- s.persist( "Person", person );
- s.getTransaction().commit();
- s.close();
-
- s = openSession();
- s.beginTransaction();
-
- EntityStatistics addressStats = getSessions().getStatistics().getEntityStatistics( "Address" );
-
- person = ( Map ) s.createQuery( "from Person p join fetch p.address" ).uniqueResult();
- assertNotNull( "could not locate person", person );
- assertNotNull( "could not locate persons address", person.get( "address" ) );
- s.clear();
-
- Object[] tuple = ( Object[] ) s.createQuery( "select p.name, p from Person p join fetch p.address" ).uniqueResult();
- assertEquals( tuple.length, 2 );
- person = ( Map ) tuple[1];
- assertNotNull( "could not locate person", person );
- assertNotNull( "could not locate persons address", person.get( "address" ) );
-
- s.delete( "Person", person );
-
- s.getTransaction().commit();
- s.close();
-
- assertEquals( addressStats.getFetchCount(), 0 );
- }
-
- protected String[] getMappings() {
- return new String[] { "onetoone/nopojo/Person.hbm.xml" };
- }
-
- protected void configure(Configuration cfg) {
- cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "false");
- cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
- cfg.setProperty( Environment.DEFAULT_ENTITY_MODE, EntityMode.MAP.toString() );
- }
-
- public static Test suite() {
- return new TestSuite(OneToOneTest.class);
- }
-
-}
-
Copied: trunk/Hibernate3/test/org/hibernate/test/onetoone/singletable/DiscrimSubclassOneToOneTest.java (from rev 10964, trunk/Hibernate3/test/org/hibernate/test/onetoone/singletable/OneToOneTest.java)
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/onetoone/singletable/OneToOneTest.java 2006-12-08 16:06:49 UTC (rev 10964)
+++ trunk/Hibernate3/test/org/hibernate/test/onetoone/singletable/DiscrimSubclassOneToOneTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,148 @@
+//$Id$
+package org.hibernate.test.onetoone.singletable;
+
+import java.util.List;
+
+import junit.framework.Test;
+
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.stat.EntityStatistics;
+
+/**
+ * @author Gavin King
+ */
+public class DiscrimSubclassOneToOneTest extends FunctionalTestCase {
+
+ public DiscrimSubclassOneToOneTest(String str) {
+ super(str);
+ }
+
+ public String[] getMappings() {
+ return new String[] { "onetoone/singletable/Person.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "false");
+ cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( DiscrimSubclassOneToOneTest.class );
+ }
+
+ public void testOneToOneOnSubclass() {
+ Person p = new Person();
+ p.name = "Gavin";
+ Address a = new Address();
+ a.entityName = "Gavin";
+ a.zip = "3181";
+ a.state = "VIC";
+ a.street = "Karbarook Ave";
+ p.address = a;
+
+ Session s = openSession();
+ Transaction t = s.beginTransaction();
+ s.persist(p);
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+
+ EntityStatistics addressStats = getSessions().getStatistics().getEntityStatistics( Address.class.getName() );
+ EntityStatistics mailingAddressStats = getSessions().getStatistics().getEntityStatistics("MailingAddress");
+
+ p = (Person) s.createQuery("from Person p join fetch p.address left join fetch p.mailingAddress").uniqueResult();
+ assertNotNull(p.address); assertNull(p.mailingAddress);
+ s.clear();
+
+ assertEquals( addressStats.getFetchCount(), 0 );
+ assertEquals( mailingAddressStats.getFetchCount(), 0 );
+
+ p = (Person) s.createQuery("from Person p join fetch p.address").uniqueResult();
+ assertNotNull(p.address); assertNull(p.mailingAddress);
+ s.clear();
+
+ assertEquals( addressStats.getFetchCount(), 0 );
+ assertEquals( mailingAddressStats.getFetchCount(), 1 );
+
+ p = (Person) s.createQuery("from Person").uniqueResult();
+ assertNotNull(p.address); assertNull(p.mailingAddress);
+ s.clear();
+
+ assertEquals( addressStats.getFetchCount(), 1 );
+ assertEquals( mailingAddressStats.getFetchCount(), 2 );
+
+ p = (Person) s.createQuery("from Entity").uniqueResult();
+ assertNotNull(p.address); assertNull(p.mailingAddress);
+ s.clear();
+
+ assertEquals( addressStats.getFetchCount(), 2 );
+ assertEquals( mailingAddressStats.getFetchCount(), 3 );
+
+ //note that in here join fetch is used for the nullable
+ //one-to-one, due to a very special case of default
+ p = (Person) s.get(Person.class, "Gavin");
+ assertNotNull(p.address); assertNull(p.mailingAddress);
+ s.clear();
+
+ assertEquals( addressStats.getFetchCount(), 2 );
+ assertEquals( mailingAddressStats.getFetchCount(), 3 );
+
+ p = (Person) s.get(Entity.class, "Gavin");
+ assertNotNull(p.address); assertNull(p.mailingAddress);
+ s.clear();
+
+ assertEquals( addressStats.getFetchCount(), 2 );
+ assertEquals( mailingAddressStats.getFetchCount(), 3 );
+
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ Org org = new Org();
+ org.name = "IFA";
+ Address a2 = new Address();
+ a2.entityName = "IFA";
+ a2.zip = "3181";
+ a2.state = "VIC";
+ a2.street = "Orrong Rd";
+ org.addresses.add(a2);
+ s.persist(org);
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ org = (Org) s.get(Entity.class, "IFA");
+ s.clear();
+
+ List list = s.createQuery("from Entity e order by e.name").list();
+ p = (Person) list.get(0);
+ assertNotNull(p.address); assertNull(p.mailingAddress);
+ org = (Org) list.get(1);
+ assertEquals( org.addresses.size(), 1 );
+ s.clear();
+
+ list = s.createQuery("from Entity e left join fetch e.address left join fetch e.mailingAddress order by e.name").list();
+ p = (Person) list.get(0);
+ org = (Org) list.get(1);
+ assertNotNull(p.address); assertNull(p.mailingAddress);
+ assertEquals( org.addresses.size(), 1 );
+
+ s.delete(p);
+ s.delete(org);
+
+ t.commit();
+ s.close();
+
+ }
+
+}
+
Property changes on: trunk/Hibernate3/test/org/hibernate/test/onetoone/singletable/DiscrimSubclassOneToOneTest.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Deleted: trunk/Hibernate3/test/org/hibernate/test/onetoone/singletable/OneToOneTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/onetoone/singletable/OneToOneTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/onetoone/singletable/OneToOneTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,148 +0,0 @@
-//$Id$
-package org.hibernate.test.onetoone.singletable;
-
-import java.util.List;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.cfg.Environment;
-import org.hibernate.stat.EntityStatistics;
-import org.hibernate.test.TestCase;
-
-/**
- * @author Gavin King
- */
-public class OneToOneTest extends TestCase {
-
- public OneToOneTest(String str) {
- super(str);
- }
-
- public void testOneToOneOnSubclass() {
- Person p = new Person();
- p.name = "Gavin";
- Address a = new Address();
- a.entityName = "Gavin";
- a.zip = "3181";
- a.state = "VIC";
- a.street = "Karbarook Ave";
- p.address = a;
-
- Session s = openSession();
- Transaction t = s.beginTransaction();
- s.persist(p);
- t.commit();
- s.close();
-
- s = openSession();
- t = s.beginTransaction();
-
- EntityStatistics addressStats = getSessions().getStatistics().getEntityStatistics( Address.class.getName() );
- EntityStatistics mailingAddressStats = getSessions().getStatistics().getEntityStatistics("MailingAddress");
-
- p = (Person) s.createQuery("from Person p join fetch p.address left join fetch p.mailingAddress").uniqueResult();
- assertNotNull(p.address); assertNull(p.mailingAddress);
- s.clear();
-
- assertEquals( addressStats.getFetchCount(), 0 );
- assertEquals( mailingAddressStats.getFetchCount(), 0 );
-
- p = (Person) s.createQuery("from Person p join fetch p.address").uniqueResult();
- assertNotNull(p.address); assertNull(p.mailingAddress);
- s.clear();
-
- assertEquals( addressStats.getFetchCount(), 0 );
- assertEquals( mailingAddressStats.getFetchCount(), 1 );
-
- p = (Person) s.createQuery("from Person").uniqueResult();
- assertNotNull(p.address); assertNull(p.mailingAddress);
- s.clear();
-
- assertEquals( addressStats.getFetchCount(), 1 );
- assertEquals( mailingAddressStats.getFetchCount(), 2 );
-
- p = (Person) s.createQuery("from Entity").uniqueResult();
- assertNotNull(p.address); assertNull(p.mailingAddress);
- s.clear();
-
- assertEquals( addressStats.getFetchCount(), 2 );
- assertEquals( mailingAddressStats.getFetchCount(), 3 );
-
- //note that in here join fetch is used for the nullable
- //one-to-one, due to a very special case of default
- p = (Person) s.get(Person.class, "Gavin");
- assertNotNull(p.address); assertNull(p.mailingAddress);
- s.clear();
-
- assertEquals( addressStats.getFetchCount(), 2 );
- assertEquals( mailingAddressStats.getFetchCount(), 3 );
-
- p = (Person) s.get(Entity.class, "Gavin");
- assertNotNull(p.address); assertNull(p.mailingAddress);
- s.clear();
-
- assertEquals( addressStats.getFetchCount(), 2 );
- assertEquals( mailingAddressStats.getFetchCount(), 3 );
-
- t.commit();
- s.close();
-
- s = openSession();
- t = s.beginTransaction();
- Org org = new Org();
- org.name = "IFA";
- Address a2 = new Address();
- a2.entityName = "IFA";
- a2.zip = "3181";
- a2.state = "VIC";
- a2.street = "Orrong Rd";
- org.addresses.add(a2);
- s.persist(org);
- t.commit();
- s.close();
-
- s = openSession();
- t = s.beginTransaction();
- org = (Org) s.get(Entity.class, "IFA");
- s.clear();
-
- List list = s.createQuery("from Entity e order by e.name").list();
- p = (Person) list.get(0);
- assertNotNull(p.address); assertNull(p.mailingAddress);
- org = (Org) list.get(1);
- assertEquals( org.addresses.size(), 1 );
- s.clear();
-
- list = s.createQuery("from Entity e left join fetch e.address left join fetch e.mailingAddress order by e.name").list();
- p = (Person) list.get(0);
- org = (Org) list.get(1);
- assertNotNull(p.address); assertNull(p.mailingAddress);
- assertEquals( org.addresses.size(), 1 );
-
- s.delete(p);
- s.delete(org);
-
- t.commit();
- s.close();
-
- }
-
- protected String[] getMappings() {
- return new String[] { "onetoone/singletable/Person.hbm.xml" };
- }
-
- protected void configure(Configuration cfg) {
- cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "false");
- cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
- }
-
- public static Test suite() {
- return new TestSuite(OneToOneTest.class);
- }
-
-}
-
Modified: trunk/Hibernate3/test/org/hibernate/test/ops/AbstractOperationTestCase.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/ops/AbstractOperationTestCase.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/ops/AbstractOperationTestCase.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,25 +1,25 @@
package org.hibernate.test.ops;
-import org.hibernate.test.TestCase;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
+import org.hibernate.junit.functional.FunctionalTestCase;
/**
* {@inheritDoc}
*
* @author Steve Ebersole
*/
-public abstract class AbstractOperationTestCase extends TestCase {
+public abstract class AbstractOperationTestCase extends FunctionalTestCase {
public AbstractOperationTestCase(String name) {
super( name );
}
- protected void configure(Configuration cfg) {
+ public void configure(Configuration cfg) {
cfg.setProperty( Environment.GENERATE_STATISTICS, "true");
cfg.setProperty( Environment.STATEMENT_BATCH_SIZE, "0" );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "ops/Node.hbm.xml", "ops/Employer.hbm.xml", "ops/OptLockEntity.hbm.xml", "ops/OneToOne.hbm.xml" };
}
Modified: trunk/Hibernate3/test/org/hibernate/test/ops/CreateTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/ops/CreateTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/ops/CreateTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -5,11 +5,11 @@
import java.util.Collection;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.PersistentObjectException;
import org.hibernate.Session;
import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.exception.ConstraintViolationException;
/**
@@ -22,7 +22,7 @@
}
public static Test suite() {
- return new TestSuite( CreateTest.class );
+ return new FunctionalTestClassTestSuite( CreateTest.class );
}
public void testNoUpdatesOnCreateVersionedWithCollection() {
Modified: trunk/Hibernate3/test/org/hibernate/test/ops/DeleteTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/ops/DeleteTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/ops/DeleteTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,9 +1,9 @@
package org.hibernate.test.ops;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Session;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* {@inheritDoc}
@@ -16,7 +16,7 @@
}
public static Test suite() {
- return new TestSuite( DeleteTest.class );
+ return new FunctionalTestClassTestSuite( DeleteTest.class );
}
public void testDeleteVersionedWithCollectionNoUpdate() {
Modified: trunk/Hibernate3/test/org/hibernate/test/ops/GetLoadTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/ops/GetLoadTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/ops/GetLoadTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -7,14 +7,16 @@
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
-import org.hibernate.test.TestCase;
+
/**
* @author Gavin King
*/
-public class GetLoadTest extends TestCase {
+public class GetLoadTest extends FunctionalTestCase {
public GetLoadTest(String str) {
super(str);
@@ -90,20 +92,17 @@
assertEquals(count, fetches);
}
- protected void configure(Configuration cfg) {
+ public void configure(Configuration cfg) {
cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
cfg.setProperty(Environment.STATEMENT_BATCH_SIZE, "0");
}
- protected String[] getMappings() {
- return new String[] {
- "ops/Node.hbm.xml",
- "ops/Employer.hbm.xml"
- };
+ public String[] getMappings() {
+ return new String[] { "ops/Node.hbm.xml", "ops/Employer.hbm.xml" };
}
public static Test suite() {
- return new TestSuite(GetLoadTest.class);
+ return new FunctionalTestClassTestSuite(GetLoadTest.class);
}
public String getCacheConcurrencyStrategy() {
Modified: trunk/Hibernate3/test/org/hibernate/test/ops/MergeTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/ops/MergeTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/ops/MergeTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -5,12 +5,12 @@
import java.util.Iterator;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.NonUniqueObjectException;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.criterion.Projections;
/**
@@ -23,7 +23,7 @@
}
public static Test suite() {
- return new TestSuite( MergeTest.class );
+ return new FunctionalTestClassTestSuite( MergeTest.class );
}
public void testMergeBidiPrimayKeyOneToOne() throws Exception {
@@ -521,6 +521,8 @@
new Integer(2)
);
+ s.close();
+
cleanup();
}
Modified: trunk/Hibernate3/test/org/hibernate/test/ops/SaveOrUpdateTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/ops/SaveOrUpdateTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/ops/SaveOrUpdateTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -2,21 +2,21 @@
package org.hibernate.test.ops;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.intercept.FieldInterceptionHelper;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.criterion.Projections;
-import org.hibernate.test.TestCase;
/**
* @author Gavin King
*/
-public class SaveOrUpdateTest extends TestCase {
+public class SaveOrUpdateTest extends FunctionalTestCase {
public SaveOrUpdateTest(String str) {
super( str );
@@ -431,17 +431,17 @@
assertEquals( count, updates );
}
- protected void configure(Configuration cfg) {
+ public void configure(Configuration cfg) {
cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
cfg.setProperty( Environment.STATEMENT_BATCH_SIZE, "0" );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] {"ops/Node.hbm.xml"};
}
public static Test suite() {
- return new TestSuite( SaveOrUpdateTest.class );
+ return new FunctionalTestClassTestSuite( SaveOrUpdateTest.class );
}
}
Modified: trunk/Hibernate3/test/org/hibernate/test/optlock/Document.hbm.xml
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/optlock/Document.hbm.xml 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/optlock/Document.hbm.xml 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,23 +1,19 @@
<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
+<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
-
+
Demonstrates the use of dirty-property optimistic locking.
We do not recommend this approach, since it does not work
for detached entities. Use version-based optimistic locking.
-
+
-->
<hibernate-mapping package="org.hibernate.test.optlock">
-
- <class name="Document"
- entity-name="LockDirty"
- table="Document"
- optimistic-lock="dirty"
- dynamic-update="true">
+
+ <class name="Document" entity-name="LockDirty" table="Document" optimistic-lock="dirty" dynamic-update="true">
<id name="id">
<generator class="native"/>
</id>
@@ -31,12 +27,8 @@
<property name="totalSales" optimistic-lock="false"/>
<property name="text" column="`text`"/>
</class>
-
- <class name="Document"
- entity-name="LockAll"
- table="Document"
- optimistic-lock="all"
- dynamic-update="true">
+
+ <class name="Document" entity-name="LockAll" table="Document" optimistic-lock="all" dynamic-update="true">
<id name="id">
<generator class="native"/>
</id>
@@ -50,6 +42,6 @@
<property name="totalSales" optimistic-lock="false"/>
<property name="text" column="`text`"/>
</class>
-
+
</hibernate-mapping>
Modified: trunk/Hibernate3/test/org/hibernate/test/optlock/OptimisticLockTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/optlock/OptimisticLockTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/optlock/OptimisticLockTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -2,14 +2,14 @@
package org.hibernate.test.optlock;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.JDBCException;
import org.hibernate.Session;
import org.hibernate.StaleObjectStateException;
import org.hibernate.StaleStateException;
import org.hibernate.dialect.SQLServerDialect;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* Tests relating to the optimisitc-lock mapping option.
@@ -17,18 +17,18 @@
* @author Gavin King
* @author Steve Ebersole
*/
-public class OptimisticLockTest extends TestCase {
+public class OptimisticLockTest extends FunctionalTestCase {
public OptimisticLockTest(String str) {
super(str);
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "optlock/Document.hbm.xml" };
}
public static Test suite() {
- return new TestSuite(OptimisticLockTest.class);
+ return new FunctionalTestClassTestSuite( OptimisticLockTest.class );
}
public void testOptimisticLockDirty() {
Modified: trunk/Hibernate3/test/org/hibernate/test/ordered/OrderByTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/ordered/OrderByTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/ordered/OrderByTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -4,22 +4,30 @@
import java.util.Iterator;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.FetchMode;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class OrderByTest extends TestCase {
+public class OrderByTest extends FunctionalTestCase {
public OrderByTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "ordered/Search.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( OrderByTest.class );
+ }
public void testOrderBy() {
Search s = new Search("Hibernate");
@@ -75,14 +83,6 @@
tx.commit();
sess.close();
}
-
- protected String[] getMappings() {
- return new String[] { "ordered/Search.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(OrderByTest.class);
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/orphan/OrphanIdRollbackTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/orphan/OrphanIdRollbackTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/orphan/OrphanIdRollbackTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -2,27 +2,36 @@
package org.hibernate.test.orphan;
import junit.framework.Test;
-import junit.framework.TestSuite;
+
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Emmanuel Bernard
*/
-public class OrphanIdRollbackTest extends TestCase {
+public class OrphanIdRollbackTest extends FunctionalTestCase {
public OrphanIdRollbackTest(String str) {
super(str);
}
- protected void configure(Configuration cfg) {
+ public String[] getMappings() {
+ return new String[] { "orphan/ProductAndIdRollback.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
cfg.setProperty( Environment.USE_IDENTIFIER_ROLLBACK, "true");
super.configure( cfg );
}
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( OrphanIdRollbackTest.class );
+ }
+
public void testOrphanDeleteOnDelete() {
Session session = openSession();
Transaction t = session.beginTransaction();
@@ -39,13 +48,5 @@
session.close();
}
- protected String[] getMappings() {
- return new String[] { "orphan/ProductAndIdRollback.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite( OrphanIdRollbackTest.class);
- }
-
}
Added: trunk/Hibernate3/test/org/hibernate/test/orphan/OrphanSuite.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/orphan/OrphanSuite.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/orphan/OrphanSuite.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -0,0 +1,19 @@
+package org.hibernate.test.orphan;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class OrphanSuite {
+ public static Test suite() {
+ TestSuite suite = new TestSuite( "orphan delete suite" );
+ suite.addTest( OrphanIdRollbackTest.suite() );
+ suite.addTest( OrphanTest.suite() );
+ suite.addTest( PropertyRefTest.suite() );
+ return suite;
+ }
+}
Modified: trunk/Hibernate3/test/org/hibernate/test/orphan/OrphanTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/orphan/OrphanTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/orphan/OrphanTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -2,23 +2,31 @@
package org.hibernate.test.orphan;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.LockMode;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.util.SerializationHelper;
/**
* @author Gavin King
*/
-public class OrphanTest extends TestCase {
+public class OrphanTest extends FunctionalTestCase {
public OrphanTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "orphan/Product.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( OrphanTest.class );
+ }
public void testOrphanDeleteOnDelete() {
Session session = openSession();
@@ -286,15 +294,6 @@
t.commit();
session.close();
}
-
-
- protected String[] getMappings() {
- return new String[] { "orphan/Product.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(OrphanTest.class);
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/orphan/PropertyRefTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/orphan/PropertyRefTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/orphan/PropertyRefTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -2,11 +2,11 @@
package org.hibernate.test.orphan;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
@@ -14,19 +14,20 @@
*
* @author Steve Ebersole
*/
-public class PropertyRefTest extends TestCase {
+public class PropertyRefTest extends FunctionalTestCase {
public PropertyRefTest(String name) {
super( name );
}
- protected String[] getMappings() {
- return new String[] {
- "orphan/User.hbm.xml",
- "orphan/Mail.hbm.xml"
- };
+ public String[] getMappings() {
+ return new String[] { "orphan/User.hbm.xml", "orphan/Mail.hbm.xml" };
}
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( PropertyRefTest.class );
+ }
+
public void testDeleteParentWithBidirOrphanDeleteCollectionBasedOnPropertyRef() {
Session session = openSession();
Transaction txn = session.beginTransaction();
@@ -51,9 +52,5 @@
txn.commit();
session.close();
}
-
- public static Test suite() {
- return new TestSuite(PropertyRefTest.class);
- }
}
Modified: trunk/Hibernate3/test/org/hibernate/test/pagination/PaginationTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/pagination/PaginationTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/pagination/PaginationTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -4,26 +4,41 @@
import java.math.BigDecimal;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.criterion.Order;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class PaginationTest extends TestCase {
+public class PaginationTest extends FunctionalTestCase {
public PaginationTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "pagination/DataPoint.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty(Environment.STATEMENT_BATCH_SIZE, "20");
+ }
+
+ public String getCacheConcurrencyStrategy() {
+ return null;
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( PaginationTest.class );
+ }
public void testPagination() {
-
Session s = openSession();
Transaction t = s.beginTransaction();
for ( int i=0; i<10; i++ ) {
@@ -57,22 +72,5 @@
s.close();
}
-
- protected void configure(Configuration cfg) {
- cfg.setProperty(Environment.STATEMENT_BATCH_SIZE, "20");
- }
-
- protected String[] getMappings() {
- return new String[] { "pagination/DataPoint.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(PaginationTest.class);
- }
-
- public String getCacheConcurrencyStrategy() {
- return null;
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/pretty/SQLFormatterTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/pretty/SQLFormatterTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/pretty/SQLFormatterTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -2,12 +2,15 @@
import java.util.StringTokenizer;
-import junit.framework.TestCase;
-
import org.hibernate.pretty.Formatter;
+import org.hibernate.junit.UnitTestCase;
-public class SQLFormatterTest extends TestCase {
+public class SQLFormatterTest extends UnitTestCase {
+ public SQLFormatterTest(String string) {
+ super( string );
+ }
+
public void testNoLoss() {
assertNoLoss("insert into Address (city, state, zip, \"from\") values (?, ?, ?, 'insert value')");
assertNoLoss("delete from Address where id = ? and version = ?");
Modified: trunk/Hibernate3/test/org/hibernate/test/propertyref/basic/PropertyRefTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/propertyref/basic/PropertyRefTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/propertyref/basic/PropertyRefTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -5,7 +5,6 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.FetchMode;
import org.hibernate.Hibernate;
@@ -13,29 +12,26 @@
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.ForeignKey;
import org.hibernate.mapping.PersistentClass;
-import org.hibernate.test.TestCase;
/**
* @author Gavin King
*/
-public class PropertyRefTest extends TestCase {
+public class PropertyRefTest extends FunctionalTestCase {
- public PropertyRefTest(String str) {
- super(str);
+ public PropertyRefTest(String name) {
+ super( name );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "propertyref/basic/Person.hbm.xml" };
}
- public static Test suite() {
- return new TestSuite(PropertyRefTest.class);
- }
-
- protected void configure(Configuration cfg) {
+ public void configure(Configuration cfg) {
cfg.setProperty(Environment.DEFAULT_BATCH_FETCH_SIZE, "1");
cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
}
@@ -44,6 +40,10 @@
return null;
}
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( PropertyRefTest.class );
+ }
+
public void testNonLazyBagKeyPropertyRef() {
Session s = openSession();
Transaction t = s.beginTransaction();
Modified: trunk/Hibernate3/test/org/hibernate/test/propertyref/component/complete/CompleteComponentPropertyRefTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/propertyref/component/complete/CompleteComponentPropertyRefTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/propertyref/component/complete/CompleteComponentPropertyRefTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,28 +1,28 @@
package org.hibernate.test.propertyref.component.complete;
import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.hibernate.test.TestCase;
+import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.Hibernate;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class CompleteComponentPropertyRefTest extends TestCase {
+public class CompleteComponentPropertyRefTest extends FunctionalTestCase {
- public CompleteComponentPropertyRefTest(String str) {
- super(str);
+ public CompleteComponentPropertyRefTest(String name) {
+ super( name );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "propertyref/component/complete/Mapping.hbm.xml" };
}
public static Test suite() {
- return new TestSuite( CompleteComponentPropertyRefTest.class);
+ return new FunctionalTestClassTestSuite( CompleteComponentPropertyRefTest.class );
}
public void testComponentPropertyRef() {
Modified: trunk/Hibernate3/test/org/hibernate/test/propertyref/component/partial/PartialComponentPropertyRefTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/propertyref/component/partial/PartialComponentPropertyRefTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/propertyref/component/partial/PartialComponentPropertyRefTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -2,28 +2,28 @@
package org.hibernate.test.propertyref.component.partial;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class PartialComponentPropertyRefTest extends TestCase {
+public class PartialComponentPropertyRefTest extends FunctionalTestCase {
- public PartialComponentPropertyRefTest(String str) {
- super(str);
+ public PartialComponentPropertyRefTest(String name) {
+ super( name );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "propertyref/component/partial/Mapping.hbm.xml" };
}
public static Test suite() {
- return new TestSuite( PartialComponentPropertyRefTest.class);
+ return new FunctionalTestClassTestSuite( PartialComponentPropertyRefTest.class );
}
public void testComponentPropertyRef() {
Modified: trunk/Hibernate3/test/org/hibernate/test/propertyref/inheritence/discrim/SubclassPropertyRefTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/propertyref/inheritence/discrim/SubclassPropertyRefTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/propertyref/inheritence/discrim/SubclassPropertyRefTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -2,28 +2,28 @@
package org.hibernate.test.propertyref.inheritence.discrim;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class SubclassPropertyRefTest extends TestCase {
+public class SubclassPropertyRefTest extends FunctionalTestCase {
- public SubclassPropertyRefTest(String str) {
- super( str );
+ public SubclassPropertyRefTest(String name) {
+ super( name );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "propertyref/inheritence/discrim/Person.hbm.xml" };
}
public static Test suite() {
- return new TestSuite( SubclassPropertyRefTest.class );
+ return new FunctionalTestClassTestSuite( SubclassPropertyRefTest.class );
}
public void testOneToOnePropertyRef() {
Modified: trunk/Hibernate3/test/org/hibernate/test/propertyref/inheritence/joined/JoinedSubclassPropertyRefTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/propertyref/inheritence/joined/JoinedSubclassPropertyRefTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/propertyref/inheritence/joined/JoinedSubclassPropertyRefTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -2,29 +2,29 @@
package org.hibernate.test.propertyref.inheritence.joined;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.FetchMode;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class JoinedSubclassPropertyRefTest extends TestCase {
+public class JoinedSubclassPropertyRefTest extends FunctionalTestCase {
- public JoinedSubclassPropertyRefTest(String str) {
- super(str);
+ public JoinedSubclassPropertyRefTest(String name) {
+ super( name );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "propertyref/inheritence/joined/Person.hbm.xml" };
}
public static Test suite() {
- return new TestSuite( JoinedSubclassPropertyRefTest.class);
+ return new FunctionalTestClassTestSuite( JoinedSubclassPropertyRefTest.class );
}
public void testPropertyRefToJoinedSubclass() {
Modified: trunk/Hibernate3/test/org/hibernate/test/propertyref/inheritence/union/UnionSubclassPropertyRefTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/propertyref/inheritence/union/UnionSubclassPropertyRefTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/propertyref/inheritence/union/UnionSubclassPropertyRefTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,28 +1,28 @@
package org.hibernate.test.propertyref.inheritence.union;
import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.hibernate.test.TestCase;
+import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.Hibernate;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class UnionSubclassPropertyRefTest extends TestCase {
+public class UnionSubclassPropertyRefTest extends FunctionalTestCase {
- public UnionSubclassPropertyRefTest(String str) {
- super( str );
+ public UnionSubclassPropertyRefTest(String name) {
+ super( name );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "propertyref/inheritence/union/Person.hbm.xml" };
}
public static Test suite() {
- return new TestSuite( UnionSubclassPropertyRefTest.class );
+ return new FunctionalTestClassTestSuite( UnionSubclassPropertyRefTest.class );
}
public void testOneToOnePropertyRef() {
Modified: trunk/Hibernate3/test/org/hibernate/test/proxy/ProxyTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/proxy/ProxyTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/proxy/ProxyTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -5,33 +5,49 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.FlushMode;
import org.hibernate.Hibernate;
+import org.hibernate.LazyInitializationException;
import org.hibernate.LockMode;
+import org.hibernate.ObjectNotFoundException;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.FlushMode;
-import org.hibernate.ObjectNotFoundException;
-import org.hibernate.LazyInitializationException;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.impl.SessionImpl;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.proxy.HibernateProxy;
-import org.hibernate.test.TestCase;
import org.hibernate.util.SerializationHelper;
/**
* @author Gavin King
*/
-public class ProxyTest extends TestCase {
+public class ProxyTest extends FunctionalTestCase {
- public ProxyTest(String str) {
- super(str);
+ public ProxyTest(String name) {
+ super( name );
}
-
+
+ public String[] getMappings() {
+ return new String[] { "proxy/DataPoint.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ super.configure( cfg );
+ cfg.setProperty( Environment.STATEMENT_BATCH_SIZE, "0" ); // problem on HSQLDB (go figure)
+ }
+
+ public String getCacheConcurrencyStrategy() {
+ return null;
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( ProxyTest.class );
+ }
+
public void testFinalizeFiltered() {
-
Session s = openSession();
Transaction t = s.beginTransaction();
DataPoint dp = new DataPoint();
@@ -283,23 +299,6 @@
s.close();
}
- protected String[] getMappings() {
- return new String[] { "proxy/DataPoint.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(ProxyTest.class);
- }
-
- public String getCacheConcurrencyStrategy() {
- return null;
- }
-
- protected void configure(Configuration cfg) {
- super.configure( cfg );
- cfg.setProperty( Environment.STATEMENT_BATCH_SIZE, "0" ); // problem on HSQLDB (go figure)
- }
-
public void testFullyLoadedPCSerialization() {
Session s = openSession();
Transaction t = s.beginTransaction();
Modified: trunk/Hibernate3/test/org/hibernate/test/querycache/QueryCacheTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/querycache/QueryCacheTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/querycache/QueryCacheTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -5,27 +5,42 @@
import java.util.Map;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.stat.EntityStatistics;
import org.hibernate.stat.QueryStatistics;
-import org.hibernate.stat.CollectionStatistics;
-import org.hibernate.test.TestCase;
import org.hibernate.transform.Transformers;
/**
* @author Gavin King
*/
-public class QueryCacheTest extends TestCase {
+public class QueryCacheTest extends FunctionalTestCase {
public QueryCacheTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "querycache/Item.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ super.configure( cfg );
+ cfg.setProperty( Environment.USE_QUERY_CACHE, "true" );
+ cfg.setProperty( Environment.CACHE_REGION_PREFIX, "foo" );
+ cfg.setProperty( Environment.USE_SECOND_LEVEL_CACHE, "true" );
+ cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( QueryCacheTest.class );
+ }
public void testQueryCacheInvalidation() throws Exception {
@@ -258,20 +273,5 @@
}
- protected String[] getMappings() {
- return new String[] { "querycache/Item.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(QueryCacheTest.class);
- }
-
- protected void configure(Configuration cfg) {
- super.configure( cfg );
- cfg.setProperty( Environment.USE_QUERY_CACHE, "true" );
- cfg.setProperty( Environment.CACHE_REGION_PREFIX, "foo" );
- cfg.setProperty( Environment.USE_SECOND_LEVEL_CACHE, "true" );
- cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
- }
}
Modified: trunk/Hibernate3/test/org/hibernate/test/readonly/ReadOnlyTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/readonly/ReadOnlyTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/readonly/ReadOnlyTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -5,31 +5,44 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.CacheMode;
+import org.hibernate.Hibernate;
import org.hibernate.ScrollMode;
import org.hibernate.ScrollableResults;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.Hibernate;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
- * This is how to do batch processing in Hibernate.
- * Remember to enable JDBC batch updates, or this
- * test will take a Very Long Time!
*
* @author Gavin King
*/
-public class ReadOnlyTest extends TestCase {
+public class ReadOnlyTest extends FunctionalTestCase {
public ReadOnlyTest(String str) {
super(str);
}
+ public String[] getMappings() {
+ return new String[] { "readonly/DataPoint.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty(Environment.STATEMENT_BATCH_SIZE, "20");
+ }
+
+ public String getCacheConcurrencyStrategy() {
+ return null;
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( ReadOnlyTest.class );
+ }
+
public void testReadOnlyOnProxiesFailureExpected() {
Session s = openSession();
s.setCacheMode( CacheMode.IGNORE );
@@ -103,22 +116,6 @@
s.close();
}
-
- protected void configure(Configuration cfg) {
- cfg.setProperty(Environment.STATEMENT_BATCH_SIZE, "20");
- }
- protected String[] getMappings() {
- return new String[] { "readonly/DataPoint.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(ReadOnlyTest.class);
- }
-
- public String getCacheConcurrencyStrategy() {
- return null;
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/rowid/Point.hbm.xml
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/rowid/Point.hbm.xml 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/rowid/Point.hbm.xml 2006-12-12 23:28:04 UTC (rev 10977)
@@ -17,11 +17,7 @@
<key-property name="y" column="`y`"/>
</composite-id>
<property name="description"/>
- <property name="row"
- type="rowid"
- column="rowid"
- insert="false"
- update="false"/>
+ <property name="row" type="rowid" column="rowid" insert="false" update="false"/>
</class>
</hibernate-mapping>
Modified: trunk/Hibernate3/test/org/hibernate/test/rowid/RowIdTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/rowid/RowIdTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/rowid/RowIdTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -2,56 +2,67 @@
package org.hibernate.test.rowid;
import java.math.BigDecimal;
-import java.sql.DatabaseMetaData;
-import java.sql.ResultSet;
import java.sql.Statement;
+import java.sql.SQLException;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.dialect.Oracle9Dialect;
-import org.hibernate.test.TestCase;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.junit.functional.DatabaseSpecificFunctionalTestCase;
/**
* @author Gavin King
*/
-public class RowIdTest extends TestCase {
+public class RowIdTest extends DatabaseSpecificFunctionalTestCase {
public RowIdTest(String str) {
super(str);
}
-
- protected boolean recreateSchema() {
+
+ public String[] getMappings() {
+ return new String[] { "rowid/Point.hbm.xml" };
+ }
+
+ public String getCacheConcurrencyStrategy() {
+ return null;
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( RowIdTest.class );
+ }
+
+ public boolean appliesTo(Dialect dialect) {
+ return dialect instanceof Oracle9Dialect;
+ }
+
+ public boolean createSchema() {
return false;
}
-
- public void setUp() throws Exception {
- super.setUp();
- if ( !( getDialect() instanceof Oracle9Dialect ) ) return;
- Session s = openSession();
- Statement st = s.connection().createStatement();
+
+ public void afterSessionFactoryBuilt() {
+ super.afterSessionFactoryBuilt();
try {
- st.execute( "drop table Point");
+ Session s = openSession();
+ Statement st = s.connection().createStatement();
+ try {
+ st.execute( "drop table Point");
+ }
+ catch( Throwable t ) {
+ // ignore
+ }
+ st.execute("create table Point (\"x\" number(19,2) not null, \"y\" number(19,2) not null, description varchar2(255) )");
+ s.close();
}
- catch( Throwable t ) {
- // ignore
+ catch ( SQLException e ) {
+ throw new RuntimeException( "Unable to build actual schema : " + e.getMessage() );
}
- st.execute("create table Point (\"x\" number(19,2) not null, \"y\" number(19,2) not null, description varchar2(255) )");
- s.close();
}
- public void tearDown() throws Exception {
- /*Session s = openSession();
- Statement st = s.connection().createStatement();
- st.execute("drop table Point");
- s.close();*/
- }
-
public void testRowId() {
- if ( !( getDialect() instanceof Oracle9Dialect ) ) return;
-
Session s = openSession();
Transaction t = s.beginTransaction();
Point p = new Point( new BigDecimal(1.0), new BigDecimal(1.0) );
@@ -78,18 +89,6 @@
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "rowid/Point.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(RowIdTest.class);
- }
-
- public String getCacheConcurrencyStrategy() {
- return null;
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/schemaupdate/MigrationTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/schemaupdate/MigrationTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/schemaupdate/MigrationTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -4,45 +4,43 @@
import junit.framework.TestSuite;
import org.hibernate.cfg.Configuration;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.UnitTestCase;
import org.hibernate.tool.hbm2ddl.SchemaExport;
import org.hibernate.tool.hbm2ddl.SchemaUpdate;
/**
* @author Max Rydahl Andersen
*/
-public class MigrationTest extends TestCase {
-
+public class MigrationTest extends UnitTestCase {
+
public MigrationTest(String str) {
- super(str);
+ super( str );
}
+ public static Test suite() {
+ return new TestSuite( MigrationTest.class );
+ }
+
public void testSimpleColumnAddition() {
+ String resource1 = "org/hibernate/test/schemaupdate/1_Version.hbm.xml";
+ String resource2 = "org/hibernate/test/schemaupdate/2_Version.hbm.xml";
+
Configuration v1cfg = new Configuration();
- v1cfg.addResource(getBaseForMappings() + "/schemaupdate/1_Version.hbm.xml");
-
- new SchemaExport(v1cfg).execute(false, true, true, false);
-
- SchemaUpdate v1schemaUpdate = new SchemaUpdate(v1cfg);
- v1schemaUpdate.execute(true, true);
-
- assertEquals(0, v1schemaUpdate.getExceptions().size());
-
+ v1cfg.addResource( resource1 );
+ new SchemaExport( v1cfg ).execute( false, true, true, false );
+
+ SchemaUpdate v1schemaUpdate = new SchemaUpdate( v1cfg );
+ v1schemaUpdate.execute( true, true );
+
+ assertEquals( 0, v1schemaUpdate.getExceptions().size() );
+
Configuration v2cfg = new Configuration();
- v2cfg.addResource(getBaseForMappings() + "/schemaupdate/2_Version.hbm.xml");
-
- SchemaUpdate v2schemaUpdate = new SchemaUpdate(v2cfg);
- v2schemaUpdate.execute(true, true);
- assertEquals(0, v2schemaUpdate.getExceptions().size());
-
- }
-
- protected String[] getMappings() {
- return new String[] { };
- }
+ v2cfg.addResource( resource2 );
- public static Test suite() {
- return new TestSuite(MigrationTest.class);
+ SchemaUpdate v2schemaUpdate = new SchemaUpdate( v2cfg );
+ v2schemaUpdate.execute( true, true );
+ assertEquals( 0, v2schemaUpdate.getExceptions().size() );
+
}
}
Modified: trunk/Hibernate3/test/org/hibernate/test/sorted/SortTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/sorted/SortTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/sorted/SortTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -4,22 +4,30 @@
import java.util.Iterator;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.FetchMode;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class SortTest extends TestCase {
+public class SortTest extends FunctionalTestCase {
public SortTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "sorted/Search.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( SortTest.class );
+ }
public void testOrderBy() {
Search s = new Search("Hibernate");
@@ -66,14 +74,6 @@
tx.commit();
sess.close();
}
-
- protected String[] getMappings() {
- return new String[] { "sorted/Search.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(SortTest.class);
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/sql/DataDirectOracleSQLTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/sql/DataDirectOracleSQLTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/sql/DataDirectOracleSQLTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -2,10 +2,10 @@
package org.hibernate.test.sql;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.dialect.DataDirectOracle9Dialect;
import org.hibernate.dialect.Dialect;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Max Rydahl Andersen
@@ -16,12 +16,12 @@
super(str);
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "sql/OracleEmployment.hbm.xml", "sql/OracleDataDirectDriverStoredProcedures.hbm.xml" };
}
public static Test suite() {
- return new TestSuite(DataDirectOracleSQLTest.class);
+ return new FunctionalTestClassTestSuite( DataDirectOracleSQLTest.class );
}
public boolean appliesTo(Dialect dialect) {
Modified: trunk/Hibernate3/test/org/hibernate/test/sql/Db2SQLTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/sql/Db2SQLTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/sql/Db2SQLTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -2,11 +2,10 @@
package org.hibernate.test.sql;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.dialect.DB2Dialect;
import org.hibernate.dialect.Dialect;
-import org.hibernate.dialect.Oracle9Dialect;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Max Rydahl Andersen
@@ -17,12 +16,12 @@
super(str);
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "sql/Db2Employment.hbm.xml" };
}
public static Test suite() {
- return new TestSuite(Db2SQLTest.class);
+ return new FunctionalTestClassTestSuite( Db2SQLTest.class );
}
public boolean appliesTo(Dialect dialect) {
Modified: trunk/Hibernate3/test/org/hibernate/test/sql/GeneralTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/sql/GeneralTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/sql/GeneralTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,14 +1,13 @@
package org.hibernate.test.sql;
import java.io.Serializable;
+import java.math.BigDecimal;
+import java.math.BigInteger;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.math.BigInteger;
-import java.math.BigDecimal;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.HibernateException;
@@ -17,32 +16,33 @@
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.transform.DistinctRootEntityResultTransformer;
import org.hibernate.transform.Transformers;
/**
* @author Steve Ebersole
*/
-public class GeneralTest extends TestCase {
+public class GeneralTest extends FunctionalTestCase {
public GeneralTest(String x) {
super( x );
}
- public static Test suite() {
- return new TestSuite(GeneralTest.class);
- }
-
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "sql/General.hbm.xml" };
}
- protected void configure(Configuration cfg) {
+ public void configure(Configuration cfg) {
super.configure( cfg );
cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
}
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( GeneralTest.class );
+ }
+
protected String getOrganizationFetchJoinEmploymentSQL() {
return "SELECT org.ORGID as {org.id}, " +
" org.NAME as {org.name}, " +
Modified: trunk/Hibernate3/test/org/hibernate/test/sql/HandSQLTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/sql/HandSQLTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/sql/HandSQLTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,23 +1,22 @@
package org.hibernate.test.sql;
-import org.hibernate.test.DatabaseSpecificTestCase;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.hibernate.LockMode;
-import org.hibernate.HibernateException;
-import org.hibernate.Query;
-import org.hibernate.Hibernate;
-
import java.io.Serializable;
+import java.sql.SQLException;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
-import java.sql.SQLException;
+import org.hibernate.HibernateException;
+import org.hibernate.LockMode;
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.junit.functional.DatabaseSpecificFunctionalTestCase;
+
/**
* @author Steve Ebersole
*/
-public abstract class HandSQLTest extends DatabaseSpecificTestCase {
+public abstract class HandSQLTest extends DatabaseSpecificFunctionalTestCase {
public HandSQLTest(String name) {
super( name );
@@ -35,7 +34,7 @@
Person gavin = new Person( "Gavin" );
Employment emp = new Employment( gavin, jboss, "AU" );
Serializable orgId = s.save( jboss );
- Serializable orgId2 = s.save( ifa );
+ s.save( ifa );
s.save( gavin );
s.save( emp );
t.commit();
Modified: trunk/Hibernate3/test/org/hibernate/test/sql/MSSQLTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/sql/MSSQLTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/sql/MSSQLTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -2,10 +2,10 @@
package org.hibernate.test.sql;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.SybaseDialect;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
@@ -16,12 +16,12 @@
super( str );
}
- public static Test suite() {
- return new TestSuite( MSSQLTest.class );
+ public String[] getMappings() {
+ return new String[] {"sql/MSSQLEmployment.hbm.xml"};
}
- protected String[] getMappings() {
- return new String[] {"sql/MSSQLEmployment.hbm.xml"};
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( MSSQLTest.class );
}
public boolean appliesTo(Dialect dialect) {
Modified: trunk/Hibernate3/test/org/hibernate/test/sql/MySQLTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/sql/MySQLTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/sql/MySQLTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -2,10 +2,10 @@
package org.hibernate.test.sql;
import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.MySQLDialect;
-import org.hibernate.dialect.Dialect;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
@@ -16,12 +16,12 @@
super(str);
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "sql/MySQLEmployment.hbm.xml" };
}
public static Test suite() {
- return new TestSuite(MySQLTest.class);
+ return new FunctionalTestClassTestSuite( MySQLTest.class );
}
public boolean appliesTo(Dialect dialect) {
Modified: trunk/Hibernate3/test/org/hibernate/test/sql/OracleSQLTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/sql/OracleSQLTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/sql/OracleSQLTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -2,45 +2,27 @@
package org.hibernate.test.sql;
import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.dialect.DataDirectOracle9Dialect;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.Oracle9Dialect;
-import org.hibernate.dialect.DataDirectOracle9Dialect;
-import org.hibernate.HibernateException;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
-import java.sql.SQLException;
-
/**
* @author Gavin King
*/
public class OracleSQLTest extends HandSQLTest {
- public void testHandSQL() {
- super.testHandSQL();
- }
- public void testScalarStoredProcedure() throws HibernateException, SQLException {
- super.testScalarStoredProcedure();
- }
-
- public void testParameterHandling() throws HibernateException, SQLException {
- super.testParameterHandling();
- }
-
- public void testEntityStoredProcedure() throws HibernateException, SQLException {
- super.testEntityStoredProcedure();
- }
-
public OracleSQLTest(String str) {
super(str);
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "sql/OracleEmployment.hbm.xml", "sql/OracleDriverStoredProcedures.hbm.xml" };
}
public static Test suite() {
- return new TestSuite(OracleSQLTest.class);
+ return new FunctionalTestClassTestSuite( OracleSQLTest.class );
}
public boolean appliesTo(Dialect dialect) {
Modified: trunk/Hibernate3/test/org/hibernate/test/sql/check/OracleCheckStyleTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/sql/check/OracleCheckStyleTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/sql/check/OracleCheckStyleTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,9 +1,10 @@
package org.hibernate.test.sql.check;
+import junit.framework.Test;
+
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.Oracle9Dialect;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* todo: describe OracleCheckStyleTest
@@ -15,7 +16,7 @@
super( name );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "sql/check/oracle-mappings.hbm.xml" };
}
@@ -24,6 +25,7 @@
}
public static Test suite() {
- return new TestSuite( OracleCheckStyleTest.class );
+ return new FunctionalTestClassTestSuite( OracleCheckStyleTest.class );
}
+
}
Modified: trunk/Hibernate3/test/org/hibernate/test/sql/check/ResultCheckStyleTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/sql/check/ResultCheckStyleTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/sql/check/ResultCheckStyleTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,17 +1,16 @@
package org.hibernate.test.sql.check;
-import org.hibernate.test.DatabaseSpecificTestCase;
-import org.hibernate.Session;
-import org.hibernate.JDBCException;
import org.hibernate.HibernateException;
-import org.hibernate.dialect.Dialect;
+import org.hibernate.JDBCException;
+import org.hibernate.Session;
+import org.hibernate.junit.functional.DatabaseSpecificFunctionalTestCase;
/**
* todo: describe ResultCheckStyleTest
*
* @author Steve Ebersole
*/
-public abstract class ResultCheckStyleTest extends DatabaseSpecificTestCase {
+public abstract class ResultCheckStyleTest extends DatabaseSpecificFunctionalTestCase {
public ResultCheckStyleTest(String name) {
super( name );
Modified: trunk/Hibernate3/test/org/hibernate/test/stateless/StatelessSessionTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/stateless/StatelessSessionTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/stateless/StatelessSessionTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -4,23 +4,31 @@
import java.util.Date;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.ScrollMode;
import org.hibernate.ScrollableResults;
import org.hibernate.StatelessSession;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class StatelessSessionTest extends TestCase {
+public class StatelessSessionTest extends FunctionalTestCase {
public StatelessSessionTest(String str) {
super(str);
}
+ public String[] getMappings() {
+ return new String[] { "stateless/Document.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( StatelessSessionTest.class );
+ }
+
public void testCreateUpdateReadDelete() {
StatelessSession ss = getSessions().openStatelessSession();
Transaction tx = ss.beginTransaction();
@@ -155,15 +163,6 @@
tx.commit();
ss.close();
}
-
-
- protected String[] getMappings() {
- return new String[] { "stateless/Document.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(StatelessSessionTest.class);
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/stats/SessionStatsTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/stats/SessionStatsTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/stats/SessionStatsTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -4,18 +4,32 @@
import java.util.HashSet;
import junit.framework.Test;
-import junit.framework.TestSuite;
+
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.stat.SessionStatistics;
import org.hibernate.stat.Statistics;
-import org.hibernate.test.TestCase;
/**
* @author Emmanuel Bernard
*/
-public class SessionStatsTest extends TestCase {
+public class SessionStatsTest extends FunctionalTestCase {
+
+ public SessionStatsTest(String x) {
+ super(x);
+ }
+
+ public String[] getMappings() {
+ return new String[] { "stats/Continent2.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( SessionStatsTest.class );
+ }
+
public void testSessionStatistics() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@@ -58,17 +72,4 @@
return europe;
}
- protected String[] getMappings() {
- return new String[] {
- "stats/Continent2.hbm.xml"
- };
- }
-
- public SessionStatsTest(String x) {
- super(x);
- }
-
- public static Test suite() {
- return new TestSuite(SessionStatsTest.class);
- }
}
Modified: trunk/Hibernate3/test/org/hibernate/test/stats/StatsTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/stats/StatsTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/stats/StatsTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -5,26 +5,45 @@
import java.util.Iterator;
import junit.framework.Test;
-import junit.framework.TestSuite;
+
import org.hibernate.FetchMode;
+import org.hibernate.Hibernate;
+import org.hibernate.ScrollableResults;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
-import org.hibernate.Hibernate;
-import org.hibernate.ScrollableResults;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.mapping.Collection;
+import org.hibernate.stat.QueryStatistics;
import org.hibernate.stat.Statistics;
-import org.hibernate.stat.QueryStatistics;
-import org.hibernate.test.TestCase;
/**
* Show the difference between fetch and load
*
* @author Emmanuel Bernard
*/
-public class StatsTest extends TestCase {
+public class StatsTest extends FunctionalTestCase {
+
+ public StatsTest(String x) {
+ super(x);
+ }
+
+ public String[] getMappings() {
+ return new String[] { "stats/Continent.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ super.configure( cfg );
+ cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( StatsTest.class );
+ }
+
public void testCollectionFetchVsLoad() throws Exception {
Statistics stats = getSessions().getStatistics();
stats.clear();
@@ -210,20 +229,4 @@
s.createQuery( "delete Continent" ).executeUpdate();
}
- protected void configure(Configuration cfg) {
- super.configure( cfg );
- cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
- }
-
- protected String[] getMappings() {
- return new String[] { "stats/Continent.hbm.xml" };
- }
-
- public StatsTest(String x) {
- super(x);
- }
-
- public static Test suite() {
- return new TestSuite(StatsTest.class);
- }
}
Modified: trunk/Hibernate3/test/org/hibernate/test/subclassfilter/DiscrimSubclassFilterTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/subclassfilter/DiscrimSubclassFilterTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/subclassfilter/DiscrimSubclassFilterTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,33 +1,37 @@
// $Id$
package org.hibernate.test.subclassfilter;
-import org.hibernate.test.TestCase;
-import org.hibernate.classic.Session;
-import org.hibernate.Transaction;
-
-import java.util.List;
-import java.util.Iterator;
import java.util.ArrayList;
import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.Transaction;
+import org.hibernate.classic.Session;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+
/**
* Implementation of DiscrimSubclassFilterTest.
*
* @author Steve Ebersole
*/
-public class DiscrimSubclassFilterTest extends TestCase {
+public class DiscrimSubclassFilterTest extends FunctionalTestCase {
public DiscrimSubclassFilterTest(String name) {
super( name );
}
- protected final String[] getMappings() {
+ public final String[] getMappings() {
return new String[] { "subclassfilter/discrim-subclass.hbm.xml" };
}
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( DiscrimSubclassFilterTest.class );
+ }
+
public void testFiltersWithSubclass() {
Session s = openSession();
s.enableFilter( "region" ).setParameter( "userRegion", "US" );
@@ -125,7 +129,4 @@
s.flush();
}
- public static Test suite() {
- return new TestSuite(DiscrimSubclassFilterTest.class);
- }
}
Modified: trunk/Hibernate3/test/org/hibernate/test/subclassfilter/JoinedSubclassFilterTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/subclassfilter/JoinedSubclassFilterTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/subclassfilter/JoinedSubclassFilterTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -7,27 +7,31 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Transaction;
import org.hibernate.classic.Session;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* Implementation of JoinedSubclassFilterTest.
*
* @author Steve Ebersole
*/
-public class JoinedSubclassFilterTest extends TestCase {
+public class JoinedSubclassFilterTest extends FunctionalTestCase {
public JoinedSubclassFilterTest(String name) {
super( name );
}
- protected final String[] getMappings() {
+ public final String[] getMappings() {
return new String[] { "subclassfilter/joined-subclass.hbm.xml" };
}
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( JoinedSubclassFilterTest.class );
+ }
+
public void testFiltersWithJoinedSubclass() {
Session s = openSession();
s.enableFilter( "region" ).setParameter( "userRegion", "US" );
@@ -136,7 +140,4 @@
s.flush();
}
- public static Test suite() {
- return new TestSuite(JoinedSubclassFilterTest.class);
- }
}
Modified: trunk/Hibernate3/test/org/hibernate/test/subclassfilter/UnionSubclassFilterTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/subclassfilter/UnionSubclassFilterTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/subclassfilter/UnionSubclassFilterTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,33 +1,37 @@
// $Id$
package org.hibernate.test.subclassfilter;
-import org.hibernate.test.TestCase;
-import org.hibernate.classic.Session;
-import org.hibernate.Transaction;
-
-import java.util.List;
-import java.util.Iterator;
import java.util.ArrayList;
import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.Transaction;
+import org.hibernate.classic.Session;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+
/**
* Implementation of DiscrimSubclassFilterTest.
*
* @author Steve Ebersole
*/
-public class UnionSubclassFilterTest extends TestCase {
+public class UnionSubclassFilterTest extends FunctionalTestCase {
public UnionSubclassFilterTest(String name) {
super( name );
}
- protected final String[] getMappings() {
+ public final String[] getMappings() {
return new String[] { "subclassfilter/union-subclass.hbm.xml" };
}
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( UnionSubclassFilterTest.class );
+ }
+
public void testFiltersWithUnionSubclass() {
Session s = openSession();
s.enableFilter( "region" ).setParameter( "userRegion", "US" );
@@ -73,26 +77,26 @@
break;
}
}
-
+
t.commit();
s.close();
-
+
s = openSession();
t = s.beginTransaction();
- s.delete("from Person");
+ s.delete( "from Person" );
t.commit();
s.close();
-
+
}
private void prepareTestData(Session s) {
- Employee john = new Employee("John Doe");
+ Employee john = new Employee( "John Doe" );
john.setCompany( "JBoss" );
john.setDepartment( "hr" );
john.setTitle( "hr guru" );
john.setRegion( "US" );
- Employee polli = new Employee("Polli Wog");
+ Employee polli = new Employee( "Polli Wog" );
polli.setCompany( "JBoss" );
polli.setDepartment( "hr" );
polli.setTitle( "hr novice" );
@@ -123,8 +127,4 @@
s.flush();
}
-
- public static Test suite() {
- return new TestSuite(UnionSubclassFilterTest.class);
- }
}
Modified: trunk/Hibernate3/test/org/hibernate/test/subselect/SubselectTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/subselect/SubselectTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/subselect/SubselectTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -5,20 +5,28 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class SubselectTest extends TestCase {
+public class SubselectTest extends FunctionalTestCase {
public SubselectTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "subselect/Beings.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( SubselectTest.class );
+ }
public void testEntitySubselect() {
Session s = openSession();
@@ -60,14 +68,5 @@
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "subselect/Beings.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(SubselectTest.class);
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/subselectfetch/SubselectFetchTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/subselectfetch/SubselectFetchTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/subselectfetch/SubselectFetchTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -4,7 +4,6 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.FetchMode;
import org.hibernate.Hibernate;
@@ -14,20 +13,33 @@
import org.hibernate.cfg.Environment;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Property;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class SubselectFetchTest extends TestCase {
+public class SubselectFetchTest extends FunctionalTestCase {
- protected void configure(Configuration cfg) {
+ public SubselectFetchTest(String str) {
+ super(str);
+ }
+
+ public String[] getMappings() {
+ return new String[] { "subselectfetch/ParentChild.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
}
- public SubselectFetchTest(String str) {
- super(str);
+ public String getCacheConcurrencyStrategy() {
+ return null;
}
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( SubselectFetchTest.class );
+ }
public void testSubselectFetchHql() {
Session s = openSession();
@@ -367,18 +379,6 @@
t.commit();
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "subselectfetch/ParentChild.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(SubselectFetchTest.class);
- }
-
- public String getCacheConcurrencyStrategy() {
- return null;
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/ternary/TernaryTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/ternary/TernaryTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/ternary/TernaryTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,29 +1,41 @@
//$Id$
package org.hibernate.test.ternary;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.HashMap;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class TernaryTest extends TestCase {
+public class TernaryTest extends FunctionalTestCase {
public TernaryTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "ternary/Ternary.hbm.xml" };
+ }
+
+ public String getCacheConcurrencyStrategy() {
+ return null;
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( TernaryTest.class );
+ }
public void testTernary() {
Session s = openSession();
@@ -99,18 +111,6 @@
t.commit();
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "ternary/Ternary.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(TernaryTest.class);
- }
-
- public String getCacheConcurrencyStrategy() {
- return null;
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/timestamp/TimestampTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/timestamp/TimestampTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/timestamp/TimestampTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -4,22 +4,34 @@
import java.util.Date;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class TimestampTest extends TestCase {
+public class TimestampTest extends FunctionalTestCase {
public TimestampTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "timestamp/User.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( TimestampTest.class );
+ }
public void testUpdateFalse() {
@@ -74,19 +86,6 @@
t.commit();
s.close();
}
-
-
- protected String[] getMappings() {
- return new String[] { "timestamp/User.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(TimestampTest.class);
- }
-
- protected void configure(Configuration cfg) {
- cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/tm/CMTTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/tm/CMTTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/tm/CMTTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -2,90 +2,113 @@
package org.hibernate.test.tm;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Iterator;
-
import javax.transaction.Transaction;
import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.ConnectionReleaseMode;
import org.hibernate.EntityMode;
+import org.hibernate.ScrollableResults;
import org.hibernate.Session;
-import org.hibernate.ScrollableResults;
-import org.hibernate.ConnectionReleaseMode;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
+import org.hibernate.criterion.Order;
import org.hibernate.dialect.SybaseDialect;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.transaction.CMTTransactionFactory;
import org.hibernate.util.SerializationHelper;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.cfg.Environment;
-import org.hibernate.criterion.Order;
-import org.hibernate.test.TestCase;
/**
* @author Gavin King
*/
-public class CMTTest extends TestCase {
-
+public class CMTTest extends FunctionalTestCase {
+
public CMTTest(String str) {
- super(str);
+ super( str );
}
-
+
+ public String[] getMappings() {
+ return new String[] { "tm/Item.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty( Environment.CONNECTION_PROVIDER, DummyConnectionProvider.class.getName() );
+ cfg.setProperty( Environment.TRANSACTION_MANAGER_STRATEGY, DummyTransactionManagerLookup.class.getName() );
+ cfg.setProperty( Environment.TRANSACTION_STRATEGY, CMTTransactionFactory.class.getName() );
+ cfg.setProperty( Environment.AUTO_CLOSE_SESSION, "true" );
+ cfg.setProperty( Environment.FLUSH_BEFORE_COMPLETION, "true" );
+ cfg.setProperty( Environment.RELEASE_CONNECTIONS, ConnectionReleaseMode.AFTER_STATEMENT.toString() );
+ cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
+ cfg.setProperty( Environment.USE_QUERY_CACHE, "true" );
+ cfg.setProperty( Environment.DEFAULT_ENTITY_MODE, EntityMode.MAP.toString() );
+ }
+
+ public String getCacheConcurrencyStrategy() {
+ return "transactional";
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( CMTTest.class );
+ }
+
public void testConcurrent() throws Exception {
getSessions().getStatistics().clear();
-
+
DummyTransactionManager.INSTANCE.begin();
Session s = openSession();
Map foo = new HashMap();
- foo.put("name", "Foo");
- foo.put("description", "a big foo");
- s.persist("Item", foo);
+ foo.put( "name", "Foo" );
+ foo.put( "description", "a big foo" );
+ s.persist( "Item", foo );
Map bar = new HashMap();
- bar.put("name", "Bar");
- bar.put("description", "a small bar");
- s.persist("Item", bar);
+ bar.put( "name", "Bar" );
+ bar.put( "description", "a small bar" );
+ s.persist( "Item", bar );
DummyTransactionManager.INSTANCE.commit();
-
- getSessions().evictEntity("Item");
-
+
+ getSessions().evictEntity( "Item" );
+
DummyTransactionManager.INSTANCE.begin();
Session s1 = openSession();
- foo = (Map) s1.get("Item", "Foo");
+ foo = ( Map ) s1.get( "Item", "Foo" );
//foo.put("description", "a big red foo");
//s1.flush();
Transaction tx1 = DummyTransactionManager.INSTANCE.suspend();
-
+
DummyTransactionManager.INSTANCE.begin();
Session s2 = openSession();
- foo = (Map) s2.get("Item", "Foo");
+ foo = ( Map ) s2.get( "Item", "Foo" );
DummyTransactionManager.INSTANCE.commit();
-
- DummyTransactionManager.INSTANCE.resume(tx1);
+
+ DummyTransactionManager.INSTANCE.resume( tx1 );
tx1.commit();
-
- getSessions().evictEntity("Item");
+ getSessions().evictEntity( "Item" );
+
DummyTransactionManager.INSTANCE.begin();
s1 = openSession();
- s1.createCriteria("Item").list();
+ s1.createCriteria( "Item" ).list();
//foo.put("description", "a big red foo");
//s1.flush();
tx1 = DummyTransactionManager.INSTANCE.suspend();
-
+
DummyTransactionManager.INSTANCE.begin();
s2 = openSession();
- s2.createCriteria("Item").list();
+ s2.createCriteria( "Item" ).list();
DummyTransactionManager.INSTANCE.commit();
-
- DummyTransactionManager.INSTANCE.resume(tx1);
+
+ DummyTransactionManager.INSTANCE.resume( tx1 );
tx1.commit();
-
+
DummyTransactionManager.INSTANCE.begin();
s2 = openSession();
- s2.createCriteria("Item").list();
+ s2.createCriteria( "Item" ).list();
DummyTransactionManager.INSTANCE.commit();
-
+
assertEquals( getSessions().getStatistics().getEntityLoadCount(), 7 );
assertEquals( getSessions().getStatistics().getEntityFetchCount(), 0 );
assertEquals( getSessions().getStatistics().getQueryExecutionCount(), 3 );
@@ -94,48 +117,50 @@
DummyTransactionManager.INSTANCE.begin();
s = openSession();
- s.createQuery("delete from Item").executeUpdate();
+ s.createQuery( "delete from Item" ).executeUpdate();
DummyTransactionManager.INSTANCE.commit();
}
-
+
public void testConcurrentCachedQueries() throws Exception {
-
+
DummyTransactionManager.INSTANCE.begin();
Session s = openSession();
Map foo = new HashMap();
- foo.put("name", "Foo");
- foo.put("description", "a big foo");
- s.persist("Item", foo);
+ foo.put( "name", "Foo" );
+ foo.put( "description", "a big foo" );
+ s.persist( "Item", foo );
Map bar = new HashMap();
- bar.put("name", "Bar");
- bar.put("description", "a small bar");
- s.persist("Item", bar);
+ bar.put( "name", "Bar" );
+ bar.put( "description", "a small bar" );
+ s.persist( "Item", bar );
DummyTransactionManager.INSTANCE.commit();
-
- synchronized (this) { wait(1000); }
+ synchronized ( this ) {
+ wait( 1000 );
+ }
+
getSessions().getStatistics().clear();
-
- getSessions().evictEntity("Item");
+ getSessions().evictEntity( "Item" );
+
DummyTransactionManager.INSTANCE.begin();
Session s4 = openSession();
Transaction tx4 = DummyTransactionManager.INSTANCE.suspend();
DummyTransactionManager.INSTANCE.begin();
Session s1 = openSession();
- List r1 = s1.createCriteria("Item").addOrder( Order.asc("description") )
- .setCacheable(true).list();
+ List r1 = s1.createCriteria( "Item" ).addOrder( Order.asc( "description" ) )
+ .setCacheable( true ).list();
assertEquals( r1.size(), 2 );
Transaction tx1 = DummyTransactionManager.INSTANCE.suspend();
DummyTransactionManager.INSTANCE.begin();
Session s2 = openSession();
- List r2 = s2.createCriteria("Item").addOrder( Order.asc("description") )
- .setCacheable(true).list();
+ List r2 = s2.createCriteria( "Item" ).addOrder( Order.asc( "description" ) )
+ .setCacheable( true ).list();
assertEquals( r2.size(), 2 );
DummyTransactionManager.INSTANCE.commit();
-
+
assertEquals( getSessions().getStatistics().getSecondLevelCacheHitCount(), 2 );
assertEquals( getSessions().getStatistics().getSecondLevelCacheMissCount(), 0 );
assertEquals( getSessions().getStatistics().getEntityLoadCount(), 2 );
@@ -144,16 +169,16 @@
assertEquals( getSessions().getStatistics().getQueryCachePutCount(), 1 );
assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 1 );
assertEquals( getSessions().getStatistics().getQueryCacheMissCount(), 1 );
-
- DummyTransactionManager.INSTANCE.resume(tx1);
+
+ DummyTransactionManager.INSTANCE.resume( tx1 );
tx1.commit();
-
+
DummyTransactionManager.INSTANCE.begin();
Session s3 = openSession();
- s3.createCriteria("Item").addOrder( Order.asc("description") )
- .setCacheable(true).list();
+ s3.createCriteria( "Item" ).addOrder( Order.asc( "description" ) )
+ .setCacheable( true ).list();
DummyTransactionManager.INSTANCE.commit();
-
+
assertEquals( getSessions().getStatistics().getSecondLevelCacheHitCount(), 4 );
assertEquals( getSessions().getStatistics().getSecondLevelCacheMissCount(), 0 );
assertEquals( getSessions().getStatistics().getEntityLoadCount(), 2 );
@@ -162,13 +187,13 @@
assertEquals( getSessions().getStatistics().getQueryCachePutCount(), 1 );
assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 2 );
assertEquals( getSessions().getStatistics().getQueryCacheMissCount(), 1 );
-
- DummyTransactionManager.INSTANCE.resume(tx4);
- List r4 = s4.createCriteria("Item").addOrder( Order.asc("description") )
- .setCacheable(true).list();
+
+ DummyTransactionManager.INSTANCE.resume( tx4 );
+ List r4 = s4.createCriteria( "Item" ).addOrder( Order.asc( "description" ) )
+ .setCacheable( true ).list();
assertEquals( r4.size(), 2 );
tx4.commit();
-
+
assertEquals( getSessions().getStatistics().getSecondLevelCacheHitCount(), 6 );
assertEquals( getSessions().getStatistics().getSecondLevelCacheMissCount(), 0 );
assertEquals( getSessions().getStatistics().getEntityLoadCount(), 2 );
@@ -177,13 +202,13 @@
assertEquals( getSessions().getStatistics().getQueryCachePutCount(), 1 );
assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 3 );
assertEquals( getSessions().getStatistics().getQueryCacheMissCount(), 1 );
-
+
DummyTransactionManager.INSTANCE.begin();
s = openSession();
- s.createQuery("delete from Item").executeUpdate();
+ s.createQuery( "delete from Item" ).executeUpdate();
DummyTransactionManager.INSTANCE.commit();
}
-
+
public void testConcurrentCachedDirtyQueries() throws Exception {
if ( getDialect() instanceof SybaseDialect ) {
// sybase and sqlserver have serious locking issues here...
@@ -194,42 +219,44 @@
DummyTransactionManager.INSTANCE.begin();
Session s = openSession();
Map foo = new HashMap();
- foo.put("name", "Foo");
- foo.put("description", "a big foo");
- s.persist("Item", foo);
+ foo.put( "name", "Foo" );
+ foo.put( "description", "a big foo" );
+ s.persist( "Item", foo );
Map bar = new HashMap();
- bar.put("name", "Bar");
- bar.put("description", "a small bar");
- s.persist("Item", bar);
+ bar.put( "name", "Bar" );
+ bar.put( "description", "a small bar" );
+ s.persist( "Item", bar );
DummyTransactionManager.INSTANCE.commit();
-
- synchronized (this) { wait(1000); }
+ synchronized ( this ) {
+ wait( 1000 );
+ }
+
getSessions().getStatistics().clear();
-
- getSessions().evictEntity("Item");
+ getSessions().evictEntity( "Item" );
+
DummyTransactionManager.INSTANCE.begin();
Session s4 = openSession();
Transaction tx4 = DummyTransactionManager.INSTANCE.suspend();
DummyTransactionManager.INSTANCE.begin();
Session s1 = openSession();
- List r1 = s1.createCriteria("Item").addOrder( Order.asc("description") )
- .setCacheable(true).list();
+ List r1 = s1.createCriteria( "Item" ).addOrder( Order.asc( "description" ) )
+ .setCacheable( true ).list();
assertEquals( r1.size(), 2 );
- foo = (Map) r1.get(0);
- foo.put("description", "a big red foo");
+ foo = ( Map ) r1.get( 0 );
+ foo.put( "description", "a big red foo" );
s1.flush();
Transaction tx1 = DummyTransactionManager.INSTANCE.suspend();
DummyTransactionManager.INSTANCE.begin();
Session s2 = openSession();
- List r2 = s2.createCriteria("Item").addOrder( Order.asc("description") )
- .setCacheable(true).list();
+ List r2 = s2.createCriteria( "Item" ).addOrder( Order.asc( "description" ) )
+ .setCacheable( true ).list();
assertEquals( r2.size(), 2 );
DummyTransactionManager.INSTANCE.commit();
-
+
assertEquals( getSessions().getStatistics().getSecondLevelCacheHitCount(), 0 );
assertEquals( getSessions().getStatistics().getSecondLevelCacheMissCount(), 0 );
assertEquals( getSessions().getStatistics().getEntityLoadCount(), 4 );
@@ -238,16 +265,16 @@
assertEquals( getSessions().getStatistics().getQueryCachePutCount(), 2 );
assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 0 );
assertEquals( getSessions().getStatistics().getQueryCacheMissCount(), 2 );
-
- DummyTransactionManager.INSTANCE.resume(tx1);
+
+ DummyTransactionManager.INSTANCE.resume( tx1 );
tx1.commit();
-
+
DummyTransactionManager.INSTANCE.begin();
Session s3 = openSession();
- s3.createCriteria("Item").addOrder( Order.asc("description") )
- .setCacheable(true).list();
+ s3.createCriteria( "Item" ).addOrder( Order.asc( "description" ) )
+ .setCacheable( true ).list();
DummyTransactionManager.INSTANCE.commit();
-
+
assertEquals( getSessions().getStatistics().getSecondLevelCacheHitCount(), 0 );
assertEquals( getSessions().getStatistics().getSecondLevelCacheMissCount(), 0 );
assertEquals( getSessions().getStatistics().getEntityLoadCount(), 6 );
@@ -256,13 +283,13 @@
assertEquals( getSessions().getStatistics().getQueryCachePutCount(), 3 );
assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 0 );
assertEquals( getSessions().getStatistics().getQueryCacheMissCount(), 3 );
-
- DummyTransactionManager.INSTANCE.resume(tx4);
- List r4 = s4.createCriteria("Item").addOrder( Order.asc("description") )
- .setCacheable(true).list();
+
+ DummyTransactionManager.INSTANCE.resume( tx4 );
+ List r4 = s4.createCriteria( "Item" ).addOrder( Order.asc( "description" ) )
+ .setCacheable( true ).list();
assertEquals( r4.size(), 2 );
tx4.commit();
-
+
assertEquals( getSessions().getStatistics().getSecondLevelCacheHitCount(), 2 );
assertEquals( getSessions().getStatistics().getSecondLevelCacheMissCount(), 0 );
assertEquals( getSessions().getStatistics().getEntityLoadCount(), 6 );
@@ -271,13 +298,13 @@
assertEquals( getSessions().getStatistics().getQueryCachePutCount(), 3 );
assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 1 );
assertEquals( getSessions().getStatistics().getQueryCacheMissCount(), 3 );
-
+
DummyTransactionManager.INSTANCE.begin();
s = openSession();
- s.createQuery("delete from Item").executeUpdate();
+ s.createQuery( "delete from Item" ).executeUpdate();
DummyTransactionManager.INSTANCE.commit();
}
-
+
public void testCMT() throws Exception {
getSessions().getStatistics().clear();
@@ -296,17 +323,17 @@
DummyTransactionManager.INSTANCE.begin();
s = openSession();
Map item = new HashMap();
- item.put("name", "The Item");
- item.put("description", "The only item we have");
- s.persist("Item", item);
+ item.put( "name", "The Item" );
+ item.put( "description", "The only item we have" );
+ s.persist( "Item", item );
DummyTransactionManager.INSTANCE.getTransaction().commit();
assertFalse( s.isOpen() );
DummyTransactionManager.INSTANCE.begin();
s = openSession();
- item = (Map) s.createQuery("from Item").uniqueResult();
- assertNotNull(item);
- s.delete(item);
+ item = ( Map ) s.createQuery( "from Item" ).uniqueResult();
+ assertNotNull( item );
+ s.delete( item );
DummyTransactionManager.INSTANCE.getTransaction().commit();
assertFalse( s.isOpen() );
@@ -321,9 +348,9 @@
DummyTransactionManager.INSTANCE.begin();
s = openSession();
- s.createQuery("delete from Item").executeUpdate();
+ s.createQuery( "delete from Item" ).executeUpdate();
DummyTransactionManager.INSTANCE.commit();
-
+
}
public void testCurrentSession() throws Exception {
@@ -417,7 +444,7 @@
DummyTransactionManager.INSTANCE.begin();
s = getSessions().getCurrentSession();
results = s.createQuery( "from Item" ).scroll();
- while( !results.isLast() ) {
+ while ( !results.isLast() ) {
results.next();
}
DummyTransactionManager.INSTANCE.getTransaction().commit();
@@ -426,7 +453,7 @@
DummyTransactionManager.INSTANCE.begin();
s = getSessions().getCurrentSession();
results = s.createQuery( "from Item" ).scroll();
- while( !results.isLast() ) {
+ while ( !results.isLast() ) {
results.next();
}
results.close();
@@ -483,28 +510,5 @@
}
}
- protected String[] getMappings() {
- return new String[] { "tm/Item.hbm.xml" };
- }
-
- public String getCacheConcurrencyStrategy() {
- return "transactional";
- }
-
- public static Test suite() {
- return new TestSuite(CMTTest.class);
- }
-
- protected void configure(Configuration cfg) {
- cfg.setProperty( Environment.CONNECTION_PROVIDER, DummyConnectionProvider.class.getName() );
- cfg.setProperty( Environment.TRANSACTION_MANAGER_STRATEGY, DummyTransactionManagerLookup.class.getName() );
- cfg.setProperty( Environment.TRANSACTION_STRATEGY, CMTTransactionFactory.class.getName() );
- cfg.setProperty( Environment.AUTO_CLOSE_SESSION, "true" );
- cfg.setProperty( Environment.FLUSH_BEFORE_COMPLETION, "true" );
- cfg.setProperty( Environment.RELEASE_CONNECTIONS, ConnectionReleaseMode.AFTER_STATEMENT.toString() );
- cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
- cfg.setProperty( Environment.USE_QUERY_CACHE, "true" );
- cfg.setProperty( Environment.DEFAULT_ENTITY_MODE, EntityMode.MAP.toString() );
- }
}
Modified: trunk/Hibernate3/test/org/hibernate/test/tool/TestSchemaTools.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/tool/TestSchemaTools.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/tool/TestSchemaTools.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -2,14 +2,16 @@
import java.sql.Connection;
import java.sql.Statement;
+import java.sql.SQLException;
import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
import org.hibernate.HibernateException;
import org.hibernate.Session;
-import org.hibernate.test.TestCase;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.dialect.HSQLDialect;
+import org.hibernate.junit.functional.DatabaseSpecificFunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.tool.hbm2ddl.SchemaExport;
import org.hibernate.tool.hbm2ddl.SchemaUpdate;
import org.hibernate.tool.hbm2ddl.SchemaValidator;
@@ -25,7 +27,50 @@
* This schema should not be the same at the default db user schema and should come after the users schema alphabetically.
*
*/
-public class TestSchemaTools extends TestCase{
+public class TestSchemaTools extends DatabaseSpecificFunctionalTestCase {
+
+ public TestSchemaTools(String name) {
+ super( name );
+ }
+
+ public String[] getMappings() {
+ return new String[] { "tool/Team.hbm.xml" };
+ }
+
+ public boolean createSchema() {
+ return false;
+ }
+
+
+ public void afterSessionFactoryBuilt() {
+ super.afterSessionFactoryBuilt();
+ try {
+ Session session = openSession();
+ Connection conn = session.connection();
+ Statement stat = conn.createStatement();
+ stat.execute("CREATE SCHEMA sb AUTHORIZATION DBA ");
+ stat.execute(" CREATE SCHEMA sa AUTHORIZATION DBA ");
+ stat.execute(" CREATE TABLE \"SA\".\"Team\" (test INTEGER) ");
+ stat.close();
+ conn.close();
+ }
+ catch ( SQLException e ) {
+ throw new RuntimeException( "could not prepare additional schemas" );
+ }
+ }
+
+ protected void prepareTest() throws Exception {
+ super.prepareTest();
+ }
+
+
+ public boolean appliesTo(Dialect dialect) {
+ return dialect instanceof HSQLDialect;
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( TestSchemaTools.class );
+ }
public void testSchemaTools() throws Exception{
// database schema have been created thanks to the setUp method
@@ -170,40 +215,4 @@
session.close();
}
- public TestSchemaTools(String arg0) {
- super(arg0);
- }
-
- public String[] getMappings() {
- return new String[] {"tool/Team.hbm.xml"};
- }
-
- public static Test suite() {
- return new TestSuite(TestSchemaTools.class);
- }
-
- public static void main(String[] args) throws Exception {
- TestRunner.run( suite() );
- }
-
- protected boolean recreateSchema() {
- return false;
- }
-
-
- protected void setUp() throws Exception {
- super.setUp();
- Session session = openSession();
- Connection conn = session.connection();
- Statement stat = conn.createStatement();
- stat.execute("CREATE SCHEMA sb AUTHORIZATION DBA ");
- stat.execute(" CREATE SCHEMA sa AUTHORIZATION DBA ");
- stat.execute(" CREATE TABLE \"SA\".\"Team\" (test INTEGER) ");
- stat.close();
- conn.close();
-
- }
-
-
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/typedmanytoone/TypedManyToOneTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/typedmanytoone/TypedManyToOneTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/typedmanytoone/TypedManyToOneTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -4,21 +4,29 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class TypedManyToOneTest extends TestCase {
+public class TypedManyToOneTest extends FunctionalTestCase {
public TypedManyToOneTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "typedmanytoone/Customer.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( TypedManyToOneTest.class );
+ }
public void testCreateQuery() {
Customer cust = new Customer();
@@ -100,14 +108,6 @@
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "typedmanytoone/Customer.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(TypedManyToOneTest.class);
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/typedonetoone/TypedOneToOneTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/typedonetoone/TypedOneToOneTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/typedonetoone/TypedOneToOneTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -4,21 +4,29 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class TypedOneToOneTest extends TestCase {
+public class TypedOneToOneTest extends FunctionalTestCase {
public TypedOneToOneTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "typedonetoone/Customer.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( TypedOneToOneTest.class );
+ }
public void testCreateQuery() {
Customer cust = new Customer();
@@ -90,14 +98,6 @@
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "typedonetoone/Customer.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(TypedOneToOneTest.class);
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/typeparameters/TypeParameterTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/typeparameters/TypeParameterTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/typeparameters/TypeParameterTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -5,43 +5,32 @@
import java.sql.PreparedStatement;
import java.sql.ResultSet;
-import org.hibernate.classic.Session;
-import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
-
import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
+import org.hibernate.Transaction;
+import org.hibernate.classic.Session;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+
/**
* Test for parameterizable types.
*
* @author Michael Gloegl
*/
-public class TypeParameterTest extends TestCase {
+public class TypeParameterTest extends FunctionalTestCase {
public TypeParameterTest(String name) {
super(name);
}
- public void setUp() throws Exception {
- super.setUp();
+ public String[] getMappings() {
+ return new String[] { "typeparameters/Typedef.hbm.xml", "typeparameters/Widget.hbm.xml" };
}
- public void tearDown() throws Exception {
- super.tearDown();
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( TypeParameterTest.class );
}
- /**
- * @see org.hibernate.test.TestCase#getMappings()
- */
- protected String[] getMappings() {
- return new String[] {
- "typeparameters/Typedef.hbm.xml",
- "typeparameters/Widget.hbm.xml"
- };
- }
-
public void testSave() throws Exception {
deleteData();
@@ -130,12 +119,4 @@
t.commit();
s.close();
}
-
- public static Test suite() {
- return new TestSuite(TypeParameterTest.class);
- }
-
- public static void main(String[] args) throws Exception {
- TestRunner.run(suite());
- }
}
\ No newline at end of file
Modified: trunk/Hibernate3/test/org/hibernate/test/unconstrained/UnconstrainedTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/unconstrained/UnconstrainedTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/unconstrained/UnconstrainedTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -2,24 +2,32 @@
package org.hibernate.test.unconstrained;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.FetchMode;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.criterion.Restrictions;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class UnconstrainedTest extends TestCase {
+public class UnconstrainedTest extends FunctionalTestCase {
public UnconstrainedTest(String str) {
super(str);
}
-
+
+ public String[] getMappings() {
+ return new String[] { "unconstrained/Person.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( UnconstrainedTest.class );
+ }
+
public void testUnconstrainedNoCache() {
Session session = openSession();
Transaction tx = session.beginTransaction();
@@ -115,13 +123,5 @@
session.close();
}
- protected String[] getMappings() {
- return new String[] { "unconstrained/Person.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(UnconstrainedTest.class);
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/unidir/BackrefTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/unidir/BackrefTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/unidir/BackrefTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -2,21 +2,33 @@
package org.hibernate.test.unidir;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class BackrefTest extends TestCase {
+public class BackrefTest extends FunctionalTestCase {
public BackrefTest(String str) {
super(str);
}
-
+
+ public String[] getMappings() {
+ return new String[] { "unidir/ParentChild.hbm.xml" };
+ }
+
+ public String getCacheConcurrencyStrategy() {
+ return null;
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( BackrefTest.class );
+ }
+
public void testBackRef() {
Session s = openSession();
Transaction t = s.beginTransaction();
@@ -72,18 +84,5 @@
t.commit();
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "unidir/ParentChild.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(BackrefTest.class);
- }
-
- public String getCacheConcurrencyStrategy() {
- return null;
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/unionsubclass/UnionSubclassTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/unionsubclass/UnionSubclassTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/unionsubclass/UnionSubclassTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -5,24 +5,32 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.FetchMode;
import org.hibernate.Hibernate;
+import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.Query;
import org.hibernate.criterion.Order;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class UnionSubclassTest extends TestCase {
+public class UnionSubclassTest extends FunctionalTestCase {
public UnionSubclassTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "unionsubclass/Beings.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( UnionSubclassTest.class );
+ }
public void testUnionSubclassCollection() {
Session s = openSession();
@@ -389,14 +397,5 @@
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "unionsubclass/Beings.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(UnionSubclassTest.class);
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/unionsubclass2/UnionSubclassTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/unionsubclass2/UnionSubclassTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/unionsubclass2/UnionSubclassTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -6,28 +6,33 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.criterion.Expression;
import org.hibernate.criterion.Property;
-import org.hibernate.dialect.DB2Dialect;
import org.hibernate.dialect.HSQLDialect;
-import org.hibernate.dialect.MySQLDialect;
-import org.hibernate.dialect.PostgreSQLDialect;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class UnionSubclassTest extends TestCase {
+public class UnionSubclassTest extends FunctionalTestCase {
public UnionSubclassTest(String str) {
super(str);
}
-
+
+ public String[] getMappings() {
+ return new String[] { "unionsubclass2/Person.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( UnionSubclassTest.class );
+ }
+
public void testUnionSubclass() {
Session s = openSession();
Transaction t = s.beginTransaction();
@@ -104,7 +109,9 @@
}
public void testQuerySubclassAttribute() {
- if ( getDialect() instanceof HSQLDialect ) return; //why??
+ if ( getDialect() instanceof HSQLDialect ) {
+ return; // TODO : why??
+ }
Session s = openSession();
Transaction t = s.beginTransaction();
@@ -142,14 +149,5 @@
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "unionsubclass2/Person.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(UnionSubclassTest.class);
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/usercollection/UserCollectionTypeTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/usercollection/UserCollectionTypeTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/usercollection/UserCollectionTypeTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -2,22 +2,30 @@
package org.hibernate.test.usercollection;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Max Rydahl Andersen
*/
-public class UserCollectionTypeTest extends TestCase {
+public class UserCollectionTypeTest extends FunctionalTestCase {
public UserCollectionTypeTest(String str) {
super(str);
}
+ public String[] getMappings() {
+ return new String[] { "usercollection/UserPermissions.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( UserCollectionTypeTest.class );
+ }
+
public void testBasicOperation() {
Session s = openSession();
Transaction t = s.beginTransaction();
@@ -50,15 +58,6 @@
t.commit();
s.close();
}
-
-
- protected String[] getMappings() {
- return new String[] { "usercollection/UserPermissions.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(UserCollectionTypeTest.class);
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/util/PropertiesHelperTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/util/PropertiesHelperTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/util/PropertiesHelperTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,18 +1,17 @@
package org.hibernate.test.util;
-import junit.framework.TestCase;
+import java.util.Properties;
+
import junit.framework.Test;
import junit.framework.TestSuite;
-import java.util.Properties;
-import java.util.Iterator;
-
+import org.hibernate.junit.UnitTestCase;
import org.hibernate.util.PropertiesHelper;
/**
- * @author <a href="mailto:steve@hibernate.org">Steve Ebersole </a>
+ * @author Steve Ebersole
*/
-public class PropertiesHelperTest extends TestCase {
+public class PropertiesHelperTest extends UnitTestCase {
private Properties props;
@@ -20,6 +19,10 @@
super( string );
}
+ public static Test suite() {
+ return new TestSuite( PropertiesHelperTest.class );
+ }
+
protected void setUp() throws Exception {
props = new Properties();
@@ -103,8 +106,4 @@
catch( NumberFormatException expected ) {
}
}
-
- public static Test suite() {
- return new TestSuite( PropertiesHelperTest.class );
- }
}
Modified: trunk/Hibernate3/test/org/hibernate/test/util/StringHelperTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/util/StringHelperTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/util/StringHelperTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,20 +1,24 @@
package org.hibernate.test.util;
-import junit.framework.TestCase;
import junit.framework.Test;
import junit.framework.TestSuite;
+
+import org.hibernate.junit.UnitTestCase;
import org.hibernate.util.StringHelper;
/**
- * todo: describe StringHelperTest
- *
* @author Steve Ebersole
*/
-public class StringHelperTest extends TestCase {
+public class StringHelperTest extends UnitTestCase {
+
public StringHelperTest(String string) {
super( string );
}
+ public static Test suite() {
+ return new TestSuite( StringHelperTest.class );
+ }
+
public void testAliasGeneration() {
assertSimpleAlias( "xyz", "xyz_" );
assertSimpleAlias( "_xyz", "xyz_" );
@@ -25,8 +29,4 @@
private void assertSimpleAlias(String source, String expected) {
assertEquals( expected, StringHelper.generateAlias( source ) );
}
-
- public static Test suite() {
- return new TestSuite( StringHelperTest.class );
- }
}
Modified: trunk/Hibernate3/test/org/hibernate/test/util/dtd/EntityResolverTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/util/dtd/EntityResolverTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/util/dtd/EntityResolverTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,28 +1,32 @@
package org.hibernate.test.util.dtd;
-import junit.framework.TestCase;
import junit.framework.Test;
import junit.framework.TestSuite;
+
import org.hibernate.cfg.Configuration;
+import org.hibernate.junit.UnitTestCase;
/**
- * todo: describe EntityResolverTest
- *
* @author Steve Ebersole
*/
-public class EntityResolverTest extends TestCase {
+public class EntityResolverTest extends UnitTestCase {
+
public EntityResolverTest(String name) {
super( name );
}
+ public static Test suite() {
+ return new TestSuite( EntityResolverTest.class );
+ }
+
public void testEntityIncludeResolution() {
+ // Parent.hbm.xml contains the following entity include:
+ // <!ENTITY child SYSTEM "classpath://org/hibernate/test/util/dtd/child.xml">
+ // which we are expecting the Hibernate custom entity resolver to be able to resolve
+ // locally via classpath lookup.
Configuration cfg = new Configuration();
cfg.addResource( "org/hibernate/test/util/dtd/Parent.hbm.xml" );
cfg.buildMappings();
}
-
- public static Test suite() {
- return new TestSuite( EntityResolverTest.class );
- }
}
Modified: trunk/Hibernate3/test/org/hibernate/test/version/VersionTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/version/VersionTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/version/VersionTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -2,22 +2,30 @@
package org.hibernate.test.version;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Max Rydahl Andersen
*/
-public class VersionTest extends TestCase {
+public class VersionTest extends FunctionalTestCase {
public VersionTest(String str) {
super(str);
}
+ public String[] getMappings() {
+ return new String[] { "version/PersonThing.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( VersionTest.class );
+ }
+
public void testVersionShortCircuitFlush() {
Session s = openSession();
Transaction t = s.beginTransaction();
@@ -122,15 +130,6 @@
t.commit();
s.close();
}
-
-
- protected String[] getMappings() {
- return new String[] { "version/PersonThing.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(VersionTest.class);
- }
-
}
Modified: trunk/Hibernate3/test/org/hibernate/test/version/db/DbVersionTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/version/db/DbVersionTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/version/db/DbVersionTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -3,36 +3,33 @@
import java.sql.Timestamp;
-import org.hibernate.test.TestCase;
+import junit.framework.Test;
+
+import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.Hibernate;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
/**
* Implementation of DbVersionTest.
*
* @author Steve Ebersole
*/
-public class DbVersionTest extends TestCase {
+public class DbVersionTest extends FunctionalTestCase {
public DbVersionTest(String x) {
super( x );
}
- protected String[] getMappings() {
- return new String[] { "User.hbm.xml" };
+
+ public String[] getMappings() {
+ return new String[] { "version/db/User.hbm.xml" };
}
- /**
- * @return
- */
- protected String getBaseForMappings() {
- return super.getBaseForMappings() + "version/db/";
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( DbVersionTest.class );
}
-
public void testCollectionVersion() throws Exception {
Session s = openSession();
Transaction t = s.beginTransaction();
@@ -47,9 +44,7 @@
// For dialects (Oracle8 for example) which do not return "true
// timestamps" sleep for a bit to allow the db date-time increment...
- //if ( steveTimestamp.getNanos() == 0 ) {
- Thread.sleep( 1500 );
- //}
+ Thread.sleep( 1500 );
s = openSession();
t = s.beginTransaction();
@@ -63,9 +58,7 @@
assertFalse( "owner version not incremented", Hibernate.TIMESTAMP.isEqual( steveTimestamp, steve.getTimestamp() ) );
steveTimestamp = steve.getTimestamp();
- //if ( steveTimestamp.getNanos() == 0 ) {
- Thread.sleep( 1500 );
- //}
+ Thread.sleep( 1500 );
s = openSession();
t = s.beginTransaction();
@@ -123,8 +116,4 @@
t.commit();
s.close();
}
-
- public static Test suite() {
- return new TestSuite(DbVersionTest.class);
- }
}
\ No newline at end of file
Modified: trunk/Hibernate3/test/org/hibernate/test/version/sybase/SybaseTimestampVersioningTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/version/sybase/SybaseTimestampVersioningTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/version/sybase/SybaseTimestampVersioningTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -1,30 +1,29 @@
// $Id$
package org.hibernate.test.version.sybase;
-import org.hibernate.test.TestCase;
-import org.hibernate.test.DatabaseSpecificTestCase;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
+import junit.framework.Test;
+
import org.hibernate.Hibernate;
import org.hibernate.HibernateException;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.SybaseDialect;
+import org.hibernate.junit.functional.DatabaseSpecificFunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
/**
* Implementation of VersionTest.
*
* @author Steve Ebersole
*/
-public class SybaseTimestampVersioningTest extends DatabaseSpecificTestCase {
+public class SybaseTimestampVersioningTest extends DatabaseSpecificFunctionalTestCase {
public SybaseTimestampVersioningTest(String x) {
super( x );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "version/sybase/User.hbm.xml" };
}
@@ -32,6 +31,9 @@
return dialect instanceof SybaseDialect;
}
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( SybaseTimestampVersioningTest.class );
+ }
public void testLocking() throws Throwable {
// First, create the needed row...
@@ -197,8 +199,4 @@
t.commit();
s.close();
}
-
- public static Test suite() {
- return new TestSuite(SybaseTimestampVersioningTest.class);
- }
}
\ No newline at end of file
Modified: trunk/Hibernate3/test/org/hibernate/test/where/WhereTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/where/WhereTest.java 2006-12-12 23:22:26 UTC (rev 10976)
+++ trunk/Hibernate3/test/org/hibernate/test/where/WhereTest.java 2006-12-12 23:28:04 UTC (rev 10977)
@@ -2,17 +2,29 @@
package org.hibernate.test.where;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.FetchMode;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Max Rydahl Andersen
*/
-public class WhereTest extends TestCase {
+public class WhereTest extends FunctionalTestCase {
+
+ public WhereTest(String str) {
+ super(str);
+ }
+
+ public String[] getMappings() {
+ return new String[] { "where/File.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( WhereTest.class );
+ }
public void testWhere() {
Session s = openSession();
@@ -40,18 +52,6 @@
s.getTransaction().commit();
s.close();
}
-
- public WhereTest(String str) {
- super(str);
- }
-
- protected String[] getMappings() {
- return new String[] { "where/File.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(WhereTest.class);
- }
-
}
17 years, 11 months
Hibernate SVN: r10976 - in branches/Branch_3_2/Hibernate3/test/org/hibernate: . junit junit/functional test test/abstractembeddedcomponents/cid test/abstractembeddedcomponents/propertyref test/any test/array test/ast test/batch test/batchfetch test/bidi test/bytecode/cglib test/bytecode/javassist test/cache test/cache/ehcache test/cache/treecache/optimistic test/cache/treecache/pessimistic test/cascade test/cfg test/cid test/collection test/collection/bag test/collection/idbag test/colle
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-12-12 18:22:26 -0500 (Tue, 12 Dec 2006)
New Revision: 10976
Added:
branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/
branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/AbstractClassLoaderIsolatedTestCase.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/SkipLog.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/TestSuiteVisitor.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/UnitTestCase.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/functional/
branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/functional/DatabaseSpecificFunctionalTestCase.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/functional/ExecutionEnvironment.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/functional/FunctionalTestCase.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/functional/FunctionalTestClassTestSuite.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/any/ComplexPropertyValue.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/original/
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/original/CollectionTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/original/Email.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/original/Permission.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/original/User.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/original/UserPermissions.hbm.xml
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/dynamicentity/DynamicEntitySuite.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/EntityModeSuite.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/Dom4jSuite.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/accessors/
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/accessors/Dom4jAccessorTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/basic/
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/basic/AB.hbm.xml
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/basic/Account.hbm.xml
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/basic/Dom4jTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/basic/Employer.hbm.xml
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/many2one/
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/many2one/Car.hbm.xml
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/many2one/Car.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/many2one/CarPart.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/many2one/CarType.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/many2one/Dom4jManyToOneTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/map/
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/map/MapSuite.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/map/basic/
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/map/basic/DynamicClassTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/map/basic/ProductLine.hbm.xml
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/multi/
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/multi/MultiRepresentationTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/multi/Stock.hbm.xml
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/multi/Stock.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/multi/Valuation.hbm.xml
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/multi/Valuation.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/generated/GeneratedPropertySuite.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/generatedkeys/GeneratedKeysSuite.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/CriteriaClassicAggregationReturnTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/lock/JPALockTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/ql/NativeQueryTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/OneToOneSuite.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/formula/
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/formula/Address.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/formula/OneToOneFormulaTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/formula/Person.hbm.xml
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/formula/Person.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/joined/JoinedSubclassOneToOneTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/link/
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/link/Customer.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/link/Employee.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/link/OneToOneLinkTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/link/Person.hbm.xml
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/link/Person.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/nopojo/DynamicMapOneToOneTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/singletable/DiscrimSubclassOneToOneTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/orphan/OrphanSuite.java
Removed:
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/AbstractClassLoaderIsolatedTestCase.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/DatabaseSpecificTestCase.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/TestSuiteVisitor.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/CollectionTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/Email.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/Permission.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/User.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/UserPermissions.hbm.xml
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/dom4j/
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/dynamic/
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entity/
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/lock/EJB3LockTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/joined/OneToOneTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/nopojo/OneToOneTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/singletable/OneToOneTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetooneformula/
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoonelink/
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sqlinterceptor/
Modified:
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/AllTests.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/TestCase.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/TestSelector.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/abstractembeddedcomponents/cid/AbstractCompositeIdTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/abstractembeddedcomponents/propertyref/AbstractComponentPropertyRefTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/any/AnyTypeTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/any/Properties.hbm.xml
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/array/ArrayTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ast/ASTIteratorTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ast/ASTUtilTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/batch/BatchTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/batchfetch/BatchFetchTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bidi/AuctionTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bidi/AuctionTest2.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bytecode/cglib/InvocationTargetExceptionTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bytecode/cglib/ReflectionOptimizerTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bytecode/javassist/InvocationTargetExceptionTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bytecode/javassist/ReflectionOptimizerTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cache/BaseCacheProviderTestCase.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cache/ehcache/EhCacheTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cache/treecache/optimistic/OptimisticTreeCacheTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cache/treecache/pessimistic/TreeCacheTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cascade/RefreshTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cfg/CacheableFileTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cid/CompositeIdTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/CollectionSuite.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/bag/PersistentBagTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/idbag/PersistentIdBagTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/list/PersistentListTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/map/PersistentMapTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/set/PersistentSetTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/component/ComponentTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/compositeelement/CompositeElementTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/connections/AggressiveReleaseTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/connections/BasicConnectionProviderTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/connections/ConnectionManagementTestCase.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/connections/ConnectionsSuite.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/connections/CurrentSessionConnectionTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/connections/SuppliedConnectionTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/connections/ThreadLocalCurrentSessionTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/criteria/CriteriaQueryTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cuk/CompositePropertyRefTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cuk/Person.hbm.xml
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cut/CompositeUserTypeTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/deletetransient/DeleteTransientEntityTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/dialect/cache/SQLFunctionsInterSystemsTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/discriminator/DiscriminatorTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/dynamicentity/interceptor/InterceptorDynamicEntityTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/dynamicentity/tuplizer/TuplizerDynamicEntityTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ecid/EmbeddedCompositeIdTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/exception/SQLExceptionConversionTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/extendshbm/ExtendsTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/extralazy/ExtraLazyTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/filter/DynamicFilterTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/formulajoin/FormulaJoinTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/generated/AbstractGeneratedPropertyTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/generated/TimestampGeneratedValuesWithCachingTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/generated/TriggerGeneratedValuesWithCachingTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/generated/TriggerGeneratedValuesWithoutCachingTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/generatedkeys/identity/IdentityGeneratedKeysTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/generatedkeys/select/SelectGeneratorTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/generatedkeys/seqidentity/SequenceIdentityTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/ASTParserLoadingTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/BulkManipulationTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/ClassicTranslatorTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/CriteriaHQLAlignmentTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/EJBQLTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/FooBarCopy.hbm.xml
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/HQLSuite.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/HQLTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/HqlParserTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/QueryTranslatorTestCase.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/ScrollableCollectionFetchingTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/Zoo.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/id/MultipleHiLoPerTableGeneratorTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/idbag/IdBagTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/idclass/IdClassTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/idprops/IdentifierPropertyReferencesTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/immutable/ImmutableTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/buildtime/InstrumentTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/cases/AbstractExecutable.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/cases/TestDirtyCheckExecutable.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/cases/TestFetchAllExecutable.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/cases/TestInjectFieldInterceptorExecutable.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/cases/TestIsPropertyInitializedExecutable.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/domain/Documents.hbm.xml
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/domain/Problematic.hbm.xml
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/domain/Problematic.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/runtime/AbstractTransformingClassLoaderInstrumentTestCase.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/runtime/CGLIBInstrumentationTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/runtime/JavassistInstrumentationTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/interceptor/InterceptorTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/interfaceproxy/InterfaceProxyTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/iterate/IterateTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/join/JoinTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/join/Person.hbm.xml
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/joinedsubclass/JoinedSubclassTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/joinfetch/JoinFetchTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/AbstractJPATest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/JPAComplianceSuite.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/cascade/CascadeTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/fetch/FetchingTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/lock/RepeatableReadTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/proxy/JPAProxyTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/ql/JPAQLComplianceTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/removed/RemovedEntityTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/lazycache/InstrumentCacheTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/lazycache/InstrumentCacheTest2.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/lazyonetoone/LazyOneToOneTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/ABCProxyTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/ABCTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/CacheTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/ComponentNotNullTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/ConfigurationPerformanceTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/CustomPersister.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/CustomSQLTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/FooBar.hbm.xml
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/FooBarTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/FumTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/Glarch.hbm.xml
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/IJ2Test.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/IJTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/LegacyTestCase.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/MapTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/MasterDetailTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/MultiTableTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/NonReflectiveBinderTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/OneToOneCacheTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/ParentChildTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/QueryByExampleTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/SQLFunctionsTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/SQLLoaderTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/StatisticsTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/lob/BlobTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/lob/ClobTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/lob/LobHolder.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/lob/LobMappings.hbm.xml
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/lob/SerializableTypeTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/manytomany/ManyToManyTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/manytomany/ordered/OrderedManyToManyTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/map/MapIndexFormulaTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/mapcompelem/MapCompositeElementTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/mapelemformula/MapElementFormulaTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/mapping/PersistentClassVisitorTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/mapping/ValueVisitorTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/mappingexception/MappingExceptionTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/mixed/MixedTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/naturalid/NaturalIdTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ondelete/OnDeleteTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetomany/OneToManyTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ops/AbstractOperationTestCase.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ops/CreateTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ops/DeleteTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ops/GetLoadTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ops/MergeTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ops/Node.hbm.xml
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ops/OneToOne.hbm.xml
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ops/SaveOrUpdateTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/optlock/Document.hbm.xml
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/optlock/OptimisticLockTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ordered/OrderByTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/orphan/OrphanIdRollbackTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/orphan/OrphanTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/orphan/PropertyRefTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/pagination/PaginationTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/pretty/SQLFormatterTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/basic/Person.hbm.xml
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/basic/PropertyRefTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/complete/CompleteComponentPropertyRefTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/partial/PartialComponentPropertyRefTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/discrim/SubclassPropertyRefTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/joined/JoinedSubclassPropertyRefTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/union/UnionSubclassPropertyRefTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/proxy/ProxyTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/querycache/QueryCacheTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/readonly/ReadOnlyTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/rowid/Point.hbm.xml
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/rowid/RowIdTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/schemaupdate/MigrationTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sorted/SortTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/DataDirectOracleSQLTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/Db2SQLTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/GeneralTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/HandSQLTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/MSSQLTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/MySQLTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/OracleSQLTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/check/OracleCheckStyleTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/check/ResultCheckStyleTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/stateless/StatelessSessionTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/stats/SessionStatsTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/stats/StatsTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/subclassfilter/DiscrimSubclassFilterTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/subclassfilter/JoinedSubclassFilterTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/subclassfilter/UnionSubclassFilterTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/subselect/SubselectTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/subselectfetch/SubselectFetchTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ternary/TernaryTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/timestamp/TimestampTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/tm/CMTTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/tool/TestSchemaTools.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/typedmanytoone/TypedManyToOneTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/typedonetoone/TypedOneToOneTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/typeparameters/TypeParameterTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/unconstrained/UnconstrainedTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/unidir/BackrefTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/unionsubclass/UnionSubclassTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/unionsubclass2/UnionSubclassTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/usercollection/UserCollectionTypeTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/util/PropertiesHelperTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/util/StringHelperTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/util/dtd/EntityResolverTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/util/dtd/Parent.hbm.xml
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/version/VersionTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/version/db/DbVersionTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/version/sybase/SybaseTimestampVersioningTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/where/WhereTest.java
Log:
test suite reorg
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/AbstractClassLoaderIsolatedTestCase.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/AbstractClassLoaderIsolatedTestCase.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/AbstractClassLoaderIsolatedTestCase.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,34 @@
+package org.hibernate.junit;
+
+/**
+ * A specialized TestCase for running tests in an isolated class-loader
+ *
+ * @author Steve Ebersole
+ */
+public abstract class AbstractClassLoaderIsolatedTestCase extends UnitTestCase {
+ private ClassLoader parentLoader;
+ private ClassLoader isolatedLoader;
+
+ public AbstractClassLoaderIsolatedTestCase(String string) {
+ super( string );
+ }
+
+ protected void setUp() throws Exception {
+ parentLoader = Thread.currentThread().getContextClassLoader();
+ isolatedLoader = buildIsolatedClassLoader( parentLoader );
+ Thread.currentThread().setContextClassLoader( isolatedLoader );
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ Thread.currentThread().setContextClassLoader( parentLoader );
+ releaseIsolatedClassLoader( isolatedLoader );
+ parentLoader = null;
+ isolatedLoader = null;
+ }
+
+ protected abstract ClassLoader buildIsolatedClassLoader(ClassLoader parent);
+
+ protected abstract void releaseIsolatedClassLoader(ClassLoader isolatedLoader);
+}
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/SkipLog.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/SkipLog.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/SkipLog.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,13 @@
+package org.hibernate.junit;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Well-known-location lookup for the test-skip log...
+ *
+ * @author Steve Ebersole
+ */
+public class SkipLog {
+ public static final Log LOG = LogFactory.getLog( "org.hibernate.test.SKIPPED" );
+}
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/TestSuiteVisitor.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/TestSuiteVisitor.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/TestSuiteVisitor.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,42 @@
+package org.hibernate.junit;
+
+import java.util.Enumeration;
+
+import junit.framework.TestSuite;
+import junit.framework.Test;
+
+/**
+ * Handles walking a TestSuite hierarchy for recognition of individual tests.
+ *
+ * @author Steve Ebersole
+ */
+public class TestSuiteVisitor {
+
+ private final TestSuiteVisitor.Handler handler;
+
+ public TestSuiteVisitor(TestSuiteVisitor.Handler handler) {
+ this.handler = handler;
+ }
+
+ public void visit(TestSuite testSuite) {
+ handler.startingTestSuite( testSuite );
+ Enumeration tests = testSuite.tests();
+ while ( tests.hasMoreElements() ) {
+ Test test = ( Test ) tests.nextElement();
+ if ( test instanceof TestSuite ) {
+ visit( ( TestSuite ) test );
+ }
+ else {
+ handler.handleTestCase( test );
+ }
+ }
+ handler.completedTestSuite( testSuite );
+ }
+
+ public static interface Handler {
+ public void handleTestCase(Test test);
+ public void startingTestSuite(TestSuite suite);
+ public void completedTestSuite(TestSuite suite);
+ }
+
+}
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/UnitTestCase.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/UnitTestCase.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/UnitTestCase.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,84 @@
+package org.hibernate.junit;
+
+import java.util.Iterator;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import junit.framework.AssertionFailedError;
+
+
+/**
+ * A basic JUnit {@link junit.framework.TestCase} subclass for
+ * adding some Hibernate specific behavior and functionality.
+ *
+ * @author Steve Ebersole
+ */
+public abstract class UnitTestCase extends junit.framework.TestCase {
+
+ private static final Log log = LogFactory.getLog( UnitTestCase.class );
+
+ public UnitTestCase(String string) {
+ super( string );
+ }
+
+ /**
+ * runBare overridden in order to apply FailureExpected validations
+ * as well as start/complete logging
+ *
+ * @throws Throwable
+ */
+ public void runBare() throws Throwable {
+ final boolean doValidate = getName().endsWith( "FailureExpected" ) && Boolean.getBoolean( "hibernate.test.validatefailureexpected" );
+ try {
+ log.info( "Starting test [" + fullTestName() + "]" );
+ super.runBare();
+ if ( doValidate ) {
+ fail( "Test marked as FailureExpected, but did not fail!" );
+ }
+ }
+ catch( Throwable t ) {
+ if ( doValidate ) {
+ skipExpectedFailure( t );
+ }
+ else {
+ throw t;
+ }
+ }
+ finally {
+ log.info( "Completed test [" + fullTestName() + "]" );
+ }
+ }
+
+ protected void skipExpectedFailure(Throwable error) {
+ reportSkip( "ignoring *FailuredExpected methods", "Failed with: " + error.toString() );
+ }
+
+ // additional assertions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ public static void assertElementTypeAssignability(java.util.Collection collection, Class clazz) throws AssertionFailedError {
+ Iterator itr = collection.iterator();
+ while ( itr.hasNext() ) {
+ assertClassAssignability( itr.next().getClass(), clazz );
+ }
+ }
+
+ public static void assertClassAssignability(Class source, Class target) throws AssertionFailedError {
+ if ( !target.isAssignableFrom( source ) ) {
+ throw new AssertionFailedError(
+ "Classes were not assignment-compatible : source<" + source.getName() +
+ "> target<" + target.getName() + ">"
+ );
+ }
+ }
+
+
+ // test skipping ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ public String fullTestName() {
+ return this.getClass().getName() + "#" + this.getName();
+ }
+
+ protected void reportSkip(String reason, String testDescription) {
+ SkipLog.LOG.warn( "*** skipping [" + fullTestName() + "] - " + testDescription + " : " + reason, new Exception() );
+ }
+}
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/functional/DatabaseSpecificFunctionalTestCase.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/functional/DatabaseSpecificFunctionalTestCase.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/functional/DatabaseSpecificFunctionalTestCase.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,27 @@
+package org.hibernate.junit.functional;
+
+import org.hibernate.junit.SkipLog;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public abstract class DatabaseSpecificFunctionalTestCase extends FunctionalTestCase {
+ public DatabaseSpecificFunctionalTestCase(String string) {
+ super( string );
+ }
+
+ protected void runTest() throws Throwable {
+ // Note: this protection comes into play when running
+ // tests individually. The suite as a whole is already
+ // "protected" by the fact that these tests are actually
+ // filtered out of the suite
+ if ( appliesTo( getDialect() ) ) {
+ super.runTest();
+ }
+ else {
+ SkipLog.LOG.warn( "skipping database-specific test [" + fullTestName() + "] for dialect [" + getDialect().getClass().getName() + "]" );
+ }
+ }
+}
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/functional/ExecutionEnvironment.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/functional/ExecutionEnvironment.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/functional/ExecutionEnvironment.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,165 @@
+package org.hibernate.junit.functional;
+
+import java.util.Iterator;
+import java.sql.Blob;
+import java.sql.Clob;
+
+import org.hibernate.dialect.Dialect;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
+import org.hibernate.cfg.Mappings;
+import org.hibernate.SessionFactory;
+import org.hibernate.mapping.PersistentClass;
+import org.hibernate.mapping.Property;
+import org.hibernate.mapping.SimpleValue;
+import org.hibernate.mapping.Collection;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class ExecutionEnvironment {
+
+ public static final Dialect DIALECT = Dialect.getDialect();
+
+ private final ExecutionEnvironment.Settings settings;
+
+ private Configuration configuration;
+ private SessionFactory sessionFactory;
+ private boolean allowRebuild;
+
+ public ExecutionEnvironment(ExecutionEnvironment.Settings settings) {
+ this.settings = settings;
+ }
+
+ public boolean isAllowRebuild() {
+ return allowRebuild;
+ }
+
+ public void setAllowRebuild(boolean allowRebuild) {
+ this.allowRebuild = allowRebuild;
+ }
+
+ public Dialect getDialect() {
+ return DIALECT;
+ }
+
+ public Configuration getConfiguration() {
+ return configuration;
+ }
+
+ public SessionFactory getSessionFactory() {
+ return sessionFactory;
+ }
+
+ public void initialize() {
+ if ( sessionFactory != null ) {
+ throw new IllegalStateException( "attempt to initialize already initialized ExecutionEnvironment" );
+ }
+ if ( ! settings.appliesTo( getDialect() ) ) {
+ return;
+ }
+
+ Configuration configuration = new Configuration();
+ configuration.setProperty( Environment.CACHE_PROVIDER, "org.hibernate.cache.HashtableCacheProvider" );
+
+ settings.configure( configuration );
+
+ applyMappings( configuration );
+ applyCacheSettings( configuration );
+
+
+ if ( settings.createSchema() ) {
+ configuration.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
+ }
+
+ // make sure we use the same dialect...
+ configuration.setProperty( Environment.DIALECT, getDialect().getClass().getName() );
+
+ configuration.buildMappings();
+ settings.afterConfigurationBuilt( configuration.createMappings(), getDialect() );
+
+ SessionFactory sessionFactory = configuration.buildSessionFactory();
+ this.configuration = configuration;
+ this.sessionFactory = sessionFactory;
+
+ settings.afterSessionFactoryBuilt();
+ }
+
+ private void applyMappings(Configuration configuration) {
+ String[] mappings = settings.getMappings();
+ for ( int i = 0; i < mappings.length; i++ ) {
+ configuration.addResource( settings.getBaseForMappings() + mappings[i], ExecutionEnvironment.class.getClassLoader() );
+ }
+ }
+
+ private void applyCacheSettings(Configuration configuration) {
+ if ( settings.getCacheConcurrencyStrategy() != null ) {
+ Iterator iter = configuration.getClassMappings();
+ while ( iter.hasNext() ) {
+ PersistentClass clazz = (PersistentClass) iter.next();
+ Iterator props = clazz.getPropertyClosureIterator();
+ boolean hasLob = false;
+ while ( props.hasNext() ) {
+ Property prop = (Property) props.next();
+ if ( prop.getValue().isSimpleValue() ) {
+ String type = ( ( SimpleValue ) prop.getValue() ).getTypeName();
+ if ( "blob".equals(type) || "clob".equals(type) ) {
+ hasLob = true;
+ }
+ if ( Blob.class.getName().equals(type) || Clob.class.getName().equals(type) ) {
+ hasLob = true;
+ }
+ }
+ }
+ if ( !hasLob && !clazz.isInherited() && settings.overrideCacheStrategy() ) {
+ configuration.setCacheConcurrencyStrategy( clazz.getEntityName(), settings.getCacheConcurrencyStrategy() );
+ }
+ }
+ iter = configuration.getCollectionMappings();
+ while ( iter.hasNext() ) {
+ Collection coll = (Collection) iter.next();
+ configuration.setCollectionCacheConcurrencyStrategy( coll.getRole(), settings.getCacheConcurrencyStrategy() );
+ }
+ }
+ }
+
+ protected void afterSessionFactoryBuilt() {
+ // for subclasses to override in order to perform extra "stuff" only
+ // when SF (re)built...
+ }
+
+ public void rebuild() {
+ if ( !allowRebuild ) {
+ return;
+ }
+ if ( sessionFactory != null ) {
+ sessionFactory.close();
+ sessionFactory = null;
+ }
+ sessionFactory = configuration.buildSessionFactory();
+ afterSessionFactoryBuilt();
+ }
+
+ public void complete() {
+ if ( sessionFactory != null ) {
+ sessionFactory.close();
+ sessionFactory = null;
+ }
+ configuration = null;
+ }
+
+ public static interface Settings {
+ public String[] getMappings();
+ public String getBaseForMappings();
+ public boolean createSchema();
+ public boolean recreateSchemaAfterFailure();
+ public void configure(Configuration cfg);
+ public boolean overrideCacheStrategy();
+ public String getCacheConcurrencyStrategy();
+ public void afterSessionFactoryBuilt();
+ public void afterConfigurationBuilt(Mappings mappings, Dialect dialect);
+ public boolean appliesTo(Dialect dialect);
+ }
+}
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/functional/FunctionalTestCase.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/functional/FunctionalTestCase.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/functional/FunctionalTestCase.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,504 @@
+package org.hibernate.junit.functional;
+
+import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Mappings;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.dialect.DB2Dialect;
+import org.hibernate.dialect.DerbyDialect;
+import org.hibernate.SessionFactory;
+import org.hibernate.HibernateException;
+import org.hibernate.Interceptor;
+import org.hibernate.Session;
+import org.hibernate.junit.UnitTestCase;
+import org.hibernate.engine.SessionFactoryImplementor;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Most of the Hibernate test suite in fact is a series of functional tests, not
+ * unit tests. Here is a base class for these functional tests.
+ *
+ * @author Steve Ebersole
+ */
+public abstract class FunctionalTestCase extends UnitTestCase implements ExecutionEnvironment.Settings {
+
+ private static final Log log = LogFactory.getLog( FunctionalTestCase.class );
+
+ private ExecutionEnvironment environment;
+ private boolean isEnvironmentLocallyManaged;
+
+ private org.hibernate.classic.Session session;
+
+ public FunctionalTestCase(String string) {
+ super( string );
+ }
+
+ public ExecutionEnvironment getEnvironment() {
+ return environment;
+ }
+
+ public void setEnvironment(ExecutionEnvironment environment) {
+ this.environment = environment;
+ }
+
+ protected void prepareTest() throws Exception {
+ }
+
+ protected void cleanupTest() throws Exception {
+ }
+
+ // JUnit hooks ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ /**
+ * Override {@link junit.framework.TestCase#setUp()} to check if we need
+ * to build a locally managed execution environment.
+ *
+ * @throws Exception
+ */
+ protected final void setUp() throws Exception {
+ if ( environment == null ) {
+ log.info( "Building locally managed execution env" );
+ isEnvironmentLocallyManaged = true;
+ environment = new ExecutionEnvironment( this );
+ environment.initialize();
+ }
+ prepareTest();
+ }
+
+ /**
+ * Override {@link junit.framework.TestCase#tearDown()} to tear down
+ * the execution environment if it is locally managed.
+ *
+ * @throws Exception
+ */
+ protected final void tearDown() throws Exception {
+ cleanupTest();
+ if ( isEnvironmentLocallyManaged ) {
+ log.info( "Destroying locally managed execution env" );
+ environment.complete();
+ environment = null;
+ }
+ }
+
+ /**
+ * runTest is overridden in order to apply session closure assertions.
+ *
+ * @throws Throwable
+ */
+ protected void runTest() throws Throwable {
+ final boolean stats = sfi().getStatistics().isStatisticsEnabled();
+ try {
+ if ( stats ) {
+ sfi().getStatistics().clear();
+ }
+
+ super.runTest();
+
+ if ( stats ) {
+ sfi().getStatistics().logSummary();
+ }
+
+ if ( session != null && session.isOpen() ) {
+ if ( session.isConnected() ) {
+ session.connection().rollback();
+ }
+ session.close();
+ session = null;
+ fail( "unclosed session" );
+ }
+ else {
+ session = null;
+ }
+ assertAllDataRemoved();
+ }
+ catch ( Throwable e ) {
+ try {
+ if ( session != null && session.isOpen() ) {
+ if ( session.isConnected() ) {
+ session.connection().rollback();
+ }
+ session.close();
+ }
+ }
+ catch ( Exception ignore ) {
+ }
+ try {
+ if ( recreateSchemaAfterFailure() && environment != null ) {
+ environment.rebuild();
+ }
+ }
+ catch ( Exception ignore ) {
+ }
+ throw e;
+ }
+ }
+
+ protected void assertAllDataRemoved() {
+ if ( !createSchema() ) {
+ return; // no tables were created...
+ }
+ if ( !Boolean.getBoolean( "hibernate.test.validateDataCleanup" ) ) {
+ return;
+ }
+
+ Session tmpSession = getSessions().openSession();
+ try {
+ List list = tmpSession.createQuery( "select o from java.lang.Object o" ).list();
+
+ Map items = new HashMap();
+ if ( !list.isEmpty() ) {
+ for ( Iterator iter = list.iterator(); iter.hasNext(); ) {
+ Object element = iter.next();
+ Integer l = ( Integer ) items.get( tmpSession.getEntityName( element ) );
+ if ( l == null ) {
+ l = new Integer( 0 );
+ }
+ l = new Integer( l.intValue() + 1 );
+ items.put( tmpSession.getEntityName( element ), l );
+ System.out.println( "Data left: " + element );
+ }
+ fail( "Data is left in the database: " + items.toString() );
+ }
+ }
+ finally {
+ try {
+ tmpSession.close();
+ }
+ catch( Throwable t ) {
+ // intentionally empty
+ }
+ }
+ }
+
+ protected void skipExpectedFailure(Throwable error) {
+ super.skipExpectedFailure( error );
+ try {
+ if ( recreateSchemaAfterFailure() && environment != null ) {
+ environment.rebuild();
+ }
+ }
+ catch ( Exception ignore ) {
+ }
+ }
+
+ // ExecutionEnvironment.Settings implementation ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ public String getBaseForMappings() {
+ return "org/hibernate/test/";
+ }
+
+ public boolean createSchema() {
+ return true;
+ }
+
+ public boolean recreateSchemaAfterFailure() {
+ return true;
+ }
+
+ public void configure(Configuration cfg) {
+ }
+
+ public boolean overrideCacheStrategy() {
+ return true;
+ }
+
+ public String getCacheConcurrencyStrategy() {
+ return "nonstrict-read-write";
+ }
+
+ public void afterSessionFactoryBuilt() {
+ }
+
+ public void afterConfigurationBuilt(Mappings mappings, Dialect dialect) {
+ }
+
+ /**
+ * Intended to indicate that this test class as a whole is intended for
+ * a dialect or series of dialects. Skips here (appliesTo = false) therefore
+ * simply indicate that the given tests target a particular feature of the
+ * checked database and none of the tests on this class should be run for the
+ * checked dialect.
+ *
+ * @param dialect The dialect to be checked.
+ * @return False if the test class as a whole is specifically targetting
+ * a dialect (or series of dialects) other than the indicated dialect
+ * and the test should therefore be skipped in its entirety;
+ * true otherwise.
+ */
+ public boolean appliesTo(Dialect dialect) {
+ return true;
+ }
+
+
+ // methods for subclasses to access environment ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ /**
+ * Get the factory for this test environment.
+ *
+ * @return The factory.
+ */
+ protected SessionFactory getSessions() {
+ return environment.getSessionFactory();
+ }
+
+ /**
+ * Get the factory for this test environment, casted to {@link org.hibernate.engine.SessionFactoryImplementor}.
+ * <p/>
+ * Shorthand for ( {@link org.hibernate.engine.SessionFactoryImplementor} ) {@link #getSessions()}...
+ *
+ * @return The factory
+ */
+ protected SessionFactoryImplementor sfi() {
+ return ( SessionFactoryImplementor ) getSessions();
+ }
+
+ protected Dialect getDialect() {
+ return ExecutionEnvironment.DIALECT;
+ }
+
+ protected Configuration getCfg() {
+ return environment.getConfiguration();
+ }
+
+ public org.hibernate.classic.Session openSession() throws HibernateException {
+ session = getSessions().openSession();
+ return session;
+ }
+
+ public org.hibernate.classic.Session openSession(Interceptor interceptor) throws HibernateException {
+ session = getSessions().openSession(interceptor);
+ return session;
+ }
+
+
+
+
+ /**
+ * Is connection at least read committed?
+ * <p/>
+ * Not, that this skip check relies on the JDBC driver reporting
+ * the true isolation level correctly. HSQLDB, for example, will
+ * report whatever you specify as the isolation
+ * (Connection.setTransationIsolation()), even though it only supports
+ * read-uncommitted.
+ *
+ * @param scenario text description of the scenario being tested.
+ * @return true if read-committed isolation is maintained.
+ */
+ protected boolean readCommittedIsolationMaintained(String scenario) {
+ int isolation = java.sql.Connection.TRANSACTION_READ_UNCOMMITTED;
+ Session testSession = null;
+ try {
+ testSession = openSession();
+ isolation = testSession.connection().getTransactionIsolation();
+ }
+ catch( Throwable ignore ) {
+ }
+ finally {
+ if ( testSession != null ) {
+ try {
+ testSession.close();
+ }
+ catch( Throwable ignore ) {
+ }
+ }
+ }
+ if ( isolation < java.sql.Connection.TRANSACTION_READ_COMMITTED ) {
+ reportSkip( "environment does not support at least read committed isolation", scenario );
+ return false;
+ }
+ else {
+ return true;
+ }
+ }
+
+ /**
+ * Does the db/dialect support using a column's physical name in the order-by clause
+ * even after it has been aliased in the select clause. This is not actually
+ * required by the SQL spec, although virtually ever DB in the world supports this
+ * (the most glaring omission here being IBM-variant DBs ala DB2 and Derby).
+ *
+ * @param testDescription description of the scenario being tested.
+ * @return true if is allowed
+ */
+ protected boolean allowsPhysicalColumnNameInOrderby(String testDescription) {
+ if ( DB2Dialect.class.isInstance( getDialect() ) ) {
+ // https://issues.apache.org/jira/browse/DERBY-1624
+ reportSkip( "Dialect does not support physical column name in order-by clause after it is aliased", testDescription );
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Does the db/dialect support using a column's physical name in the having clause
+ * even after it has been aliased in the select/group-by clause. This is not actually
+ * required by the SQL spec, although virtually ever DB in the world supports this.
+ *
+ * @param testDescription description of the scenario being tested.
+ * @return true if is allowed
+ */
+ protected boolean allowsPhysicalColumnNameInHaving(String testDescription) {
+ // I only *know* of this being a limitation on Derby, although I highly suspect
+ // it is a limitation on any IBM/DB2 variant
+ if ( DerbyDialect.class.isInstance( getDialect() ) ) {
+ // https://issues.apache.org/jira/browse/DERBY-1624
+ reportSkip( "Dialect does not support physical column name in having clause after it is aliased", testDescription );
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Does the db/dialect support empty lists in the IN operator?
+ * <p/>
+ * For example, is "... a.b IN () ..." supported?
+ *
+ * @param testDescription description of the scenario being tested.
+ * @return true if is allowed
+ */
+ protected boolean dialectSupportsEmptyInList(String testDescription) {
+ if ( ! getDialect().supportsEmptyInList() ) {
+ reportSkip( "Dialect does not support SQL empty in list : x in ()", testDescription );
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Is the db/dialect sensitive in terms of string comparisons?
+ * @param testDescription description of the scenario being tested.
+ * @return true if sensitive
+ */
+ protected boolean dialectIsCaseSensitive(String testDescription) {
+ if ( getDialect().areStringComparisonsCaseInsensitive() ) {
+ reportSkip( "Dialect is case sensitive. ", testDescription );
+ return true;
+ }
+ return false;
+ }
+
+ protected boolean supportsRowValueConstructorSyntaxInInList() {
+ if ( ! getDialect().supportsRowValueConstructorSyntaxInInList() ) {
+ reportSkip( "Dialect does not support 'tuple' syntax as part of an IN value list", "query support" );
+ return false;
+ }
+ return true;
+ }
+
+ protected boolean supportsResultSetPositionQueryMethodsOnForwardOnlyCursor() {
+ if ( ! getDialect().supportsResultSetPositionQueryMethodsOnForwardOnlyCursor() ) {
+ reportSkip( "Driver does not support 'position query' methods on forward-only cursors", "query support" );
+ return false;
+ }
+ return true;
+ }
+
+ protected boolean supportsCircularCascadeDelete() {
+ if ( ! getDialect().supportsCircularCascadeDeleteConstraints() ) {
+ reportSkip( "db/dialect does not support 'circular' cascade delete constraints", "cascade delete constraint support" );
+ return false;
+ }
+ return true;
+ }
+
+ protected boolean supportsSubselectOnLeftSideIn() {
+ if ( ! getDialect().supportsSubselectAsInPredicateLHS() ) {
+ reportSkip( "Database does not support (<subselect>) in ( ... ) ", "query support" );
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Expected LOB usage pattern is such that I can perform an insert
+ * via prepared statement with a parameter binding for a LOB value
+ * without crazy casting to JDBC driver implementation-specific classes...
+ * <p/>
+ * Part of the trickiness here is the fact that this is largely
+ * driver dependent. For Oracle, which is notoriously bad with
+ * LOB support in their drivers actually does a pretty good job with
+ * LOB support as of the 10.2.x versions of their drivers...
+ *
+ * @return True if expected usage pattern is support; false otherwise.
+ */
+ protected boolean supportsExpectedLobUsagePattern() {
+ if ( ! getDialect().supportsExpectedLobUsagePattern() ) {
+ reportSkip( "database/driver does not support expected LOB usage pattern", "LOB support" );
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Does the current dialect support propogating changes to LOB
+ * values back to the database? Talking about mutating the
+ * underlying value as opposed to supplying a new
+ * LOB instance...
+ *
+ * @return True if the changes are propogated back to the
+ * database; false otherwise.
+ */
+ protected boolean supportsLobValueChangePropogation() {
+ if ( ! getDialect().supportsLobValueChangePropogation() ) {
+ reportSkip( "database/driver does not support propogating LOB value change back to database", "LOB support" );
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Is it supported to materialize a LOB locator outside the transaction in
+ * which it was created?
+ * <p/>
+ * Again, part of the trickiness here is the fact that this is largely
+ * driver dependent.
+ * <p/>
+ * NOTE: all database I have tested which {@link #supportsExpectedLobUsagePattern()}
+ * also support the ability to materialize a LOB outside the owning transaction...
+ *
+ * @return True if unbounded materialization is supported; false otherwise.
+ */
+ protected boolean supportsUnboundedLobLocatorMaterialization() {
+ if ( !getDialect().supportsUnboundedLobLocatorMaterialization() ) {
+ reportSkip( "database/driver does not support materializing a LOB locator outside the 'owning' transaction", "LOB support" );
+ return false;
+ }
+ return true;
+ }
+
+ protected boolean supportsSubqueryOnMutatingTable() {
+ if ( !getDialect().supportsSubqueryOnMutatingTable() ) {
+ reportSkip( "database/driver does not support referencing mutating table in subquery", "bulk DML support" );
+ return false;
+ }
+ return true;
+ }
+
+ protected boolean dialectIs(Class dialectClass) {
+ return dialectClass.isInstance( getDialect() );
+ }
+
+ protected boolean dialectIsOneOf(Class[] dialectClasses) {
+ for ( int i = 0; i < dialectClasses.length; i++ ) {
+ if ( dialectClasses[i].isInstance( getDialect() ) ) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ protected boolean dialectIsNot(Class dialectClass) {
+ return ! dialectIs( dialectClass );
+ }
+
+ protected boolean dialectIsNot(Class[] dialectClasses) {
+ return ! dialectIsOneOf( dialectClasses );
+ }
+}
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/functional/FunctionalTestClassTestSuite.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/functional/FunctionalTestClassTestSuite.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/functional/FunctionalTestClassTestSuite.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,117 @@
+package org.hibernate.junit.functional;
+
+import junit.framework.TestSuite;
+import junit.framework.Test;
+import junit.framework.TestResult;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * A specialized {@link junit.framework.TestSuite} implementation intended
+ * for use as an aggregate for a single test class specifically for the purpose
+ * of maintaing a single {@link org.hibernate.SessionFactory} for executings all
+ * tests defined as part of the given functional test class.
+ *
+ * @author Steve Ebersole
+ */
+public class FunctionalTestClassTestSuite extends TestSuite {
+
+ private static final Log log = LogFactory.getLog( FunctionalTestClassTestSuite.class );
+
+ private ExecutionEnvironment.Settings settings;
+ private ExecutionEnvironment environment;
+ private Throwable environmentSetupError;
+ private int testCount;
+ private int testPosition;
+
+ public FunctionalTestClassTestSuite(Class testClass, String name) {
+ super( testClass, name );
+ }
+
+ public FunctionalTestClassTestSuite(Class testClass) {
+ this( testClass, testClass.getName() );
+ }
+
+ /**
+ * Constructor form used during {@link org.hibernate.test.AllTests} filtering...
+ *
+ * @param name The name.
+ */
+ private FunctionalTestClassTestSuite(String name) {
+ super( name );
+ }
+
+ public void addTest(Test test) {
+ if ( settings == null ) {
+ settings = ( ExecutionEnvironment.Settings ) test;
+ }
+ // todo : we could also centralize the skipping of "database specific" tests here
+ // instead of duplicating this notion in AllTests and DatabaseSpecificFunctionalTestCase.
+ testCount++;
+ super.addTest( test );
+ }
+
+ public void run(TestResult testResult) {
+ if ( testCount == 0 ) {
+ // might be zero if database-specific...
+ return;
+ }
+ try {
+ log.info( "Starting test-suite [" + getName() + "]" );
+ try {
+ setUp();
+ }
+ catch( Throwable t ) {
+ environmentSetupError = t;
+ }
+ testPosition = 0;
+ super.run( testResult );
+ }
+ finally {
+ try {
+ tearDown();
+ }
+ catch( Throwable ignore ) {
+ }
+ log.info( "Completed test-suite [" + getName() + "]" );
+ }
+ }
+
+ public void runTest(Test test, TestResult testResult) {
+ if ( environmentSetupError != null ) {
+ testResult.startTest( test );
+ testResult.addError( test, environmentSetupError );
+ testResult.endTest( test );
+ return;
+ }
+ FunctionalTestCase functionalTest = ( ( FunctionalTestCase ) test );
+ try {
+ if ( ++testPosition < testCount ) {
+ // disallow rebuilding the schema because this is the last test
+ // in this suite, thus it is about to get dropped immediately
+ // afterwards anyway...
+ environment.setAllowRebuild( true );
+ }
+ functionalTest.setEnvironment( environment );
+ super.runTest( functionalTest, testResult );
+ }
+ finally {
+ functionalTest.setEnvironment( null );
+ }
+ }
+
+ protected void setUp() {
+ log.info( "Building aggregated execution environment" );
+ environment = new ExecutionEnvironment( settings );
+ environment.initialize();
+ }
+
+ protected void tearDown() {
+ if ( environment != null ) {
+ log.info( "Destroying aggregated execution environment" );
+ environment.complete();
+ this.environment = null;
+ }
+ }
+}
Deleted: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/AbstractClassLoaderIsolatedTestCase.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/AbstractClassLoaderIsolatedTestCase.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/AbstractClassLoaderIsolatedTestCase.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,32 +0,0 @@
-package org.hibernate.test;
-
-import junit.framework.TestCase;
-
-/**
- * A specialized TestCase for running tests in an isolated class-loader
- *
- * @author Steve Ebersole
- */
-public abstract class AbstractClassLoaderIsolatedTestCase extends TestCase {
- private ClassLoader parentLoader;
- private ClassLoader isolatedLoader;
-
- protected void setUp() throws Exception {
- parentLoader = Thread.currentThread().getContextClassLoader();
- isolatedLoader = buildIsolatedClassLoader( parentLoader );
- Thread.currentThread().setContextClassLoader( isolatedLoader );
- super.setUp();
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- Thread.currentThread().setContextClassLoader( parentLoader );
- releaseIsolatedClassLoader( isolatedLoader );
- parentLoader = null;
- isolatedLoader = null;
- }
-
- protected abstract ClassLoader buildIsolatedClassLoader(ClassLoader parent);
-
- protected abstract void releaseIsolatedClassLoader(ClassLoader isolatedLoader);
-}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/AllTests.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/AllTests.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/AllTests.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,11 +1,14 @@
//$Id$
package org.hibernate.test;
+import java.lang.reflect.Constructor;
+
import junit.framework.Test;
import junit.framework.TestSuite;
import junit.textui.TestRunner;
import org.hibernate.dialect.Dialect;
+import org.hibernate.junit.TestSuiteVisitor;
import org.hibernate.test.abstractembeddedcomponents.cid.AbstractCompositeIdTest;
import org.hibernate.test.abstractembeddedcomponents.propertyref.AbstractComponentPropertyRefTest;
import org.hibernate.test.any.AnyTypeTest;
@@ -26,25 +29,19 @@
import org.hibernate.test.criteria.CriteriaQueryTest;
import org.hibernate.test.cuk.CompositePropertyRefTest;
import org.hibernate.test.cut.CompositeUserTypeTest;
+import org.hibernate.test.deletetransient.DeleteTransientEntityTest;
import org.hibernate.test.dialect.cache.SQLFunctionsInterSystemsTest;
import org.hibernate.test.discriminator.DiscriminatorTest;
-import org.hibernate.test.dom4j.Dom4jAccessorTest;
-import org.hibernate.test.dom4j.Dom4jManyToOneTest;
-import org.hibernate.test.dom4j.Dom4jTest;
-import org.hibernate.test.dynamic.DynamicClassTest;
import org.hibernate.test.dynamicentity.interceptor.InterceptorDynamicEntityTest;
import org.hibernate.test.dynamicentity.tuplizer.TuplizerDynamicEntityTest;
import org.hibernate.test.ecid.EmbeddedCompositeIdTest;
-import org.hibernate.test.entity.MultiRepresentationTest;
+import org.hibernate.test.entitymode.EntityModeSuite;
import org.hibernate.test.exception.SQLExceptionConversionTest;
import org.hibernate.test.extralazy.ExtraLazyTest;
import org.hibernate.test.filter.DynamicFilterTest;
import org.hibernate.test.formulajoin.FormulaJoinTest;
-import org.hibernate.test.generated.TimestampGeneratedValuesWithCachingTest;
-import org.hibernate.test.generated.TriggerGeneratedValuesWithCachingTest;
-import org.hibernate.test.generated.TriggerGeneratedValuesWithoutCachingTest;
-import org.hibernate.test.generatedkeys.select.SelectGeneratorTest;
-import org.hibernate.test.generatedkeys.seqidentity.SequenceIdentityTest;
+import org.hibernate.test.generated.GeneratedPropertySuite;
+import org.hibernate.test.generatedkeys.GeneratedKeysSuite;
import org.hibernate.test.hql.HQLSuite;
import org.hibernate.test.id.MultipleHiLoPerTableGeneratorTest;
import org.hibernate.test.idbag.IdBagTest;
@@ -69,6 +66,7 @@
import org.hibernate.test.legacy.CacheTest;
import org.hibernate.test.legacy.ComponentNotNullTest;
import org.hibernate.test.legacy.ConfigurationPerformanceTest;
+import org.hibernate.test.legacy.CustomSQLTest;
import org.hibernate.test.legacy.FooBarTest;
import org.hibernate.test.legacy.FumTest;
import org.hibernate.test.legacy.IJ2Test;
@@ -95,13 +93,11 @@
import org.hibernate.test.naturalid.NaturalIdTest;
import org.hibernate.test.ondelete.OnDeleteTest;
import org.hibernate.test.onetomany.OneToManyTest;
-import org.hibernate.test.onetoone.joined.OneToOneTest;
-import org.hibernate.test.onetooneformula.OneToOneFormulaTest;
+import org.hibernate.test.onetoone.OneToOneSuite;
import org.hibernate.test.ops.OpsSuite;
import org.hibernate.test.optlock.OptimisticLockTest;
import org.hibernate.test.ordered.OrderByTest;
-import org.hibernate.test.orphan.OrphanIdRollbackTest;
-import org.hibernate.test.orphan.OrphanTest;
+import org.hibernate.test.orphan.OrphanSuite;
import org.hibernate.test.pagination.PaginationTest;
import org.hibernate.test.propertyref.PropertyRefSuite;
import org.hibernate.test.proxy.ProxyTest;
@@ -131,6 +127,7 @@
import org.hibernate.test.version.db.DbVersionTest;
import org.hibernate.test.version.sybase.SybaseTimestampVersioningTest;
import org.hibernate.test.where.WhereTest;
+import org.hibernate.test.usercollection.UserCollectionTypeTest;
/**
* @author Gavin King
@@ -196,24 +193,19 @@
suite.addTest( CompositePropertyRefTest.suite() );
suite.addTest( FormulaJoinTest.suite() );
suite.addTest( DiscriminatorTest.suite() );
- suite.addTest( DynamicClassTest.suite() );
+ suite.addTest( EntityModeSuite.suite() );
suite.addTest( DynamicFilterTest.suite() );
suite.addTest( InterfaceProxyTest.suite() );
- suite.addTest( OrphanTest.suite() );
- suite.addTest( OrphanIdRollbackTest.suite() );
+ suite.addTest( OrphanSuite.suite() );
suite.addTest( JoinTest.suite() );
suite.addTest( JoinedSubclassTest.suite() );
suite.addTest( org.hibernate.test.unionsubclass2.UnionSubclassTest.suite() );
suite.addTest( MixedTest.suite() );
suite.addTest( OneToManyTest.suite() );
suite.addTest( ManyToManyTest.suite() );
- suite.addTest( OneToOneFormulaTest.suite() );
- suite.addTest( OneToOneTest.suite() );
- suite.addTest( org.hibernate.test.onetoone.singletable.OneToOneTest.suite() );
- suite.addTest( org.hibernate.test.onetoonelink.OneToOneTest.suite() );
+ suite.addTest( OneToOneSuite.suite() );
suite.addTest( OptimisticLockTest.suite() );
suite.addTest( PropertyRefSuite.suite() );
- suite.addTest( org.hibernate.test.orphan.PropertyRefTest.suite() );
suite.addTest( NativeSqlSupportSuite.suite() );
suite.addTest( CriteriaQueryTest.suite() );
suite.addTest( SubselectTest.suite() );
@@ -231,10 +223,6 @@
suite.addTest( TypedManyToOneTest.suite() );
suite.addTest( CMTTest.suite() );
suite.addTest( MultipleHiLoPerTableGeneratorTest.suite() );
- suite.addTest( MultiRepresentationTest.suite() );
- suite.addTest( Dom4jAccessorTest.suite() );
- suite.addTest( Dom4jTest.suite() );
- suite.addTest( Dom4jManyToOneTest.suite() );
suite.addTest( UnionSubclassFilterTest.suite() );
suite.addTest( JoinedSubclassFilterTest.suite() );
suite.addTest( DiscrimSubclassFilterTest.suite() );
@@ -273,11 +261,8 @@
suite.addTest( JavassistInstrumentationTest.suite() );
suite.addTest( SybaseTimestampVersioningTest.suite() );
suite.addTest( DbVersionTest.suite() );
- suite.addTest( TimestampGeneratedValuesWithCachingTest.suite() );
- suite.addTest( TriggerGeneratedValuesWithCachingTest.suite() );
- suite.addTest( TriggerGeneratedValuesWithoutCachingTest.suite() );
- suite.addTest( SelectGeneratorTest.suite() );
- suite.addTest( SequenceIdentityTest.suite() );
+ suite.addTest( GeneratedPropertySuite.suite() );
+ suite.addTest( GeneratedKeysSuite.suite() );
suite.addTest( InterceptorDynamicEntityTest.suite() );
suite.addTest( TuplizerDynamicEntityTest.suite() );
suite.addTest( BytecodeSuite.suite() );
@@ -289,6 +274,8 @@
suite.addTest( SQLFunctionsInterSystemsTest.suite() );
suite.addTest( LobSuite.suite() );
suite.addTest( IdentifierPropertyReferencesTest.suite() );
+ suite.addTest( DeleteTransientEntityTest.suite() );
+ suite.addTest( UserCollectionTypeTest.suite() );
return filter( suite );
//return suite;
@@ -335,6 +322,7 @@
suite.addTest( OneToOneCacheTest.suite() );
suite.addTest( NonReflectiveBinderTest.suite() );
suite.addTest( ConfigurationPerformanceTest.suite() ); // Added to ensure we can utilize the recommended performance tips ;)
+ suite.addTest( CustomSQLTest.suite() );
return filter( suite );
// return suite;
}
@@ -390,10 +378,7 @@
}
public void startingTestSuite(TestSuite suite) {
- currentStackElement = new TestSuiteStackEntry(
- new TestSuite( suite.getName() ),
- currentStackElement
- );
+ currentStackElement = new TestSuiteStackEntry( instantiateCopy( suite ), currentStackElement );
if ( topStackElement == null ) {
topStackElement = currentStackElement;
}
@@ -408,5 +393,19 @@
public TestSuite getFilteredTestSuite() {
return topStackElement.testSuite;
}
+
+ private static final Class[] EXPECTED_CTOR_SIG = new Class[] { String.class };
+
+ private TestSuite instantiateCopy(TestSuite suite) {
+ try {
+ Class testSuiteClass = suite.getClass();
+ Constructor ctor = testSuiteClass.getDeclaredConstructor( EXPECTED_CTOR_SIG );
+ ctor.setAccessible( true );
+ return ( TestSuite ) ctor.newInstance( new Object[] { suite.getName() } );
+ }
+ catch ( Throwable t ) {
+ throw new RuntimeException( "Unable to build test suite copy [" + suite + "]", t );
+ }
+ }
}
}
\ No newline at end of file
Deleted: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/DatabaseSpecificTestCase.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/DatabaseSpecificTestCase.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/DatabaseSpecificTestCase.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,23 +0,0 @@
-package org.hibernate.test;
-
-/**
- * @author Steve Ebersole
- */
-public abstract class DatabaseSpecificTestCase extends TestCase {
- public DatabaseSpecificTestCase(String name) {
- super( name );
- }
-
- protected void runTest() throws Throwable {
- // Note: this protection comes into play when running
- // tests individually. The suite as a whole is already
- // "protected" by the fact that these tests are actually
- // filtered out of the suite
- if ( appliesTo( getDialect() ) ) {
- super.runTest();
- }
- else {
- SKIP_LOG.warn( "skipping database-specific test [" + fullTestName() + "] for dialect [" + getDialect().getClass().getName() + "]" );
- }
- }
-}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/TestCase.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/TestCase.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/TestCase.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -114,6 +114,9 @@
}
protected Dialect getDialect() {
+ if ( dialect == null ) {
+ dialect = Dialect.getDialect();
+ }
return dialect;
}
@@ -515,7 +518,7 @@
}
return true;
}
-
+
protected boolean supportsSubselectOnLeftSideIn() {
if ( ! getDialect().supportsSubselectAsInPredicateLHS() ) {
reportSkip( "Database does not support (<subselect>) in ( ... ) ", "query support" );
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/TestSelector.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/TestSelector.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/TestSelector.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,26 +1,28 @@
package org.hibernate.test;
+import java.util.Set;
+import java.util.HashSet;
+import java.io.File;
+
import org.apache.tools.ant.types.selectors.FileSelector;
import org.apache.tools.ant.BuildException;
-import java.io.File;
-import java.util.Set;
-import java.util.HashSet;
+import org.hibernate.junit.TestSuiteVisitor;
-import junit.framework.TestSuite;
import junit.framework.Test;
+import junit.framework.TestSuite;
/**
* A custom Ant FileSelector used to limit the tests run from the Ant
- * build script to only those defined in the {@link AllTests} suite.
+ * build script to only those defined in the {@link org.hibernate.test.AllTests} suite.
* <p/>
- * {@link AllTests} is used/maintained by the developers to easily
+ * {@link org.hibernate.test.AllTests} is used/maintained by the developers to easily
* run the test suite in all IDEs. It represents all the tests
* which should actually be run and included in test results.
- *
+ *
* @author Steve Ebersole
*/
-public class TestSelector extends junit.framework.TestCase implements FileSelector {
+public class TestSelector implements FileSelector {
private final Set allTestClassNames = new HashSet();
@@ -59,12 +61,4 @@
return file;
}
-
- // unit tests ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- public void testFileSelection() {
- File file = new File( "" );
- assertTrue( "valid test not selected", isSelected( file, "org/hibernate/test/hql/HQLTest.class", file ) );
- assertFalse( "invalid test selected", isSelected( file, "hithere.class", file ) );
- }
}
Deleted: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/TestSuiteVisitor.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/TestSuiteVisitor.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/TestSuiteVisitor.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,42 +0,0 @@
-package org.hibernate.test;
-
-import junit.framework.TestSuite;
-import junit.framework.Test;
-
-import java.util.Enumeration;
-
-/**
- * Handles walking a TestSuite hierarchy for recognition of individual tests.
- *
- * @author Steve Ebersole
- */
-public class TestSuiteVisitor {
-
- private final Handler handler;
-
- public TestSuiteVisitor(Handler handler) {
- this.handler = handler;
- }
-
- public void visit(TestSuite testSuite) {
- handler.startingTestSuite( testSuite );
- Enumeration tests = testSuite.tests();
- while ( tests.hasMoreElements() ) {
- Test test = ( Test ) tests.nextElement();
- if ( test instanceof TestSuite ) {
- visit( ( TestSuite ) test );
- }
- else {
- handler.handleTestCase( test );
- }
- }
- handler.completedTestSuite( testSuite );
- }
-
- public static interface Handler {
- public void handleTestCase(Test test);
- public void startingTestSuite(TestSuite suite);
- public void completedTestSuite(TestSuite suite);
- }
-
-}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/abstractembeddedcomponents/cid/AbstractCompositeIdTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/abstractembeddedcomponents/cid/AbstractCompositeIdTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/abstractembeddedcomponents/cid/AbstractCompositeIdTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,24 +1,25 @@
package org.hibernate.test.abstractembeddedcomponents.cid;
-import org.hibernate.test.TestCase;
import org.hibernate.Session;
import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+
import junit.framework.Test;
-import junit.framework.TestSuite;
/**
* @author Steve Ebersole
*/
-public class AbstractCompositeIdTest extends TestCase {
+public class AbstractCompositeIdTest extends FunctionalTestCase {
public AbstractCompositeIdTest(String x) {
super( x );
}
public static Test suite() {
- return new TestSuite( AbstractCompositeIdTest.class );
+ return new FunctionalTestClassTestSuite( AbstractCompositeIdTest.class );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "abstractembeddedcomponents/cid/Mappings.hbm.xml" };
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/abstractembeddedcomponents/propertyref/AbstractComponentPropertyRefTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/abstractembeddedcomponents/propertyref/AbstractComponentPropertyRefTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/abstractembeddedcomponents/propertyref/AbstractComponentPropertyRefTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,24 +1,25 @@
package org.hibernate.test.abstractembeddedcomponents.propertyref;
-import org.hibernate.test.TestCase;
import org.hibernate.Session;
import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+
import junit.framework.Test;
-import junit.framework.TestSuite;
/**
* @author Steve Ebersole
*/
-public class AbstractComponentPropertyRefTest extends TestCase {
+public class AbstractComponentPropertyRefTest extends FunctionalTestCase {
public AbstractComponentPropertyRefTest(String name) {
super( name );
}
public static Test suite() {
- return new TestSuite( AbstractComponentPropertyRefTest.class );
+ return new FunctionalTestClassTestSuite( AbstractComponentPropertyRefTest.class );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "abstractembeddedcomponents/propertyref/Mappings.hbm.xml" };
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/any/AnyTypeTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/any/AnyTypeTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/any/AnyTypeTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,31 +1,32 @@
package org.hibernate.test.any;
-import org.hibernate.test.TestCase;
import org.hibernate.Session;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.junit.functional.FunctionalTestCase;
+
import junit.framework.Test;
-import junit.framework.TestSuite;
/**
* todo: describe AnyTypeTest
*
* @author Steve Ebersole
*/
-public class AnyTypeTest extends TestCase {
+public class AnyTypeTest extends FunctionalTestCase {
public AnyTypeTest(String name) {
super( name );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "any/Person.hbm.xml" };
}
- protected String getCacheConcurrencyStrategy() {
+ public String getCacheConcurrencyStrategy() {
// having second level cache causes a condition whereby the original test case would not fail...
return null;
}
public static Test suite() {
- return new TestSuite( AnyTypeTest.class );
+ return new FunctionalTestClassTestSuite( AnyTypeTest.class );
}
/**
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/any/ComplexPropertyValue.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/any/ComplexPropertyValue.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/any/ComplexPropertyValue.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,47 @@
+package org.hibernate.test.any;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Iterator;
+
+/**
+ * todo: describe ${NAME}
+ *
+ * @author Steve Ebersole
+ */
+public class ComplexPropertyValue implements PropertyValue {
+ private Long id;
+ private Map subProperties = new HashMap();
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public Map getSubProperties() {
+ return subProperties;
+ }
+
+ public void setSubProperties(Map subProperties) {
+ this.subProperties = subProperties;
+ }
+
+ public String asString() {
+ return "complex[" + keyString() + "]";
+ }
+
+ private String keyString() {
+ StringBuffer buff = new StringBuffer();
+ Iterator itr = subProperties.keySet().iterator();
+ while ( itr.hasNext() ) {
+ buff.append( itr.next() );
+ if ( itr.hasNext() ) {
+ buff.append( ", " );
+ }
+ }
+ return buff.toString();
+ }
+}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/any/Properties.hbm.xml
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/any/Properties.hbm.xml 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/any/Properties.hbm.xml 2006-12-12 23:22:26 UTC (rev 10976)
@@ -13,6 +13,7 @@
<any name="someSpecificProperty" id-type="long" meta-type="string" cascade="all">
<meta-value value="I" class="IntegerPropertyValue"/>
<meta-value value="S" class="StringPropertyValue"/>
+ <meta-value value="C" class="ComplexPropertyValue" />
<column name="S_S_PROP_TYPE"/>
<column name="S_S_PROP_ID"/>
</any>
@@ -42,4 +43,14 @@
<property name="value" column="VAL" not-null="true" type="integer"/>
</class>
+ <class name="ComplexPropertyValue" table="T_COMPLEX_PROP">
+ <id name="id" column="ID" type="long">
+ <generator class="increment"/>
+ </id>
+ <map name="subProperties" table="T_COMPLEX_SUB_PROPS" lazy="true">
+ <key column="PROP_ID" />
+ <map-key type="string" column="SUB_PROP_NAME" />
+ <element type="string" column="SUB_PROP_VAL" />
+ </map>
+ </class>
</hibernate-mapping>
\ No newline at end of file
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/array/ArrayTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/array/ArrayTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/array/ArrayTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -2,17 +2,29 @@
package org.hibernate.test.array;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Emmanuel Bernard
*/
-public class ArrayTest extends TestCase {
-
+public class ArrayTest extends FunctionalTestCase {
+
+ public ArrayTest(String x) {
+ super( x );
+ }
+
+ public String[] getMappings() {
+ return new String[] { "array/A.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( ArrayTest.class );
+ }
+
public void testArrayJoinFetch() throws Exception {
Session s;
Transaction tx;
@@ -38,18 +50,4 @@
tx.commit();
s.close();
}
-
- public ArrayTest(String x) {
- super( x );
- }
-
- public static Test suite() {
- return new TestSuite( ArrayTest.class );
- }
-
- protected String[] getMappings() {
- return new String[] {
- "array/A.hbm.xml"
- };
- }
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ast/ASTIteratorTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ast/ASTIteratorTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ast/ASTIteratorTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -3,8 +3,9 @@
import java.io.PrintWriter;
+import antlr.ASTFactory;
+import antlr.collections.AST;
import junit.framework.Test;
-import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.hibernate.hql.antlr.HqlTokenTypes;
@@ -13,14 +14,12 @@
import org.hibernate.hql.ast.util.ASTParentsFirstIterator;
import org.hibernate.hql.ast.util.ASTPrinter;
import org.hibernate.hql.ast.util.ASTUtil;
+import org.hibernate.junit.UnitTestCase;
-import antlr.ASTFactory;
-import antlr.collections.AST;
-
/**
* Test ASTIterator.
*/
-public class ASTIteratorTest extends TestCase {
+public class ASTIteratorTest extends UnitTestCase {
private ASTFactory factory;
/**
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ast/ASTUtilTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ast/ASTUtilTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ast/ASTUtilTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,19 +1,18 @@
// $Id$
package org.hibernate.test.ast;
+import antlr.ASTFactory;
+import antlr.collections.AST;
import junit.framework.Test;
-import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.hibernate.hql.ast.util.ASTUtil;
+import org.hibernate.junit.UnitTestCase;
-import antlr.ASTFactory;
-import antlr.collections.AST;
-
/**
* Unit test for ASTUtil.
*/
-public class ASTUtilTest extends TestCase {
+public class ASTUtilTest extends UnitTestCase {
private ASTFactory factory;
/**
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/batch/BatchTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/batch/BatchTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/batch/BatchTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -4,67 +4,78 @@
import java.math.BigDecimal;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.CacheMode;
import org.hibernate.ScrollMode;
import org.hibernate.ScrollableResults;
import org.hibernate.Session;
import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
-import org.hibernate.test.TestCase;
/**
* This is how to do batch processing in Hibernate.
- * Remember to enable JDBC batch updates, or this
+ * Remember to enable JDBC batch updates, or this
* test will take a Very Long Time!
- *
+ *
* @author Gavin King
*/
-public class BatchTest extends TestCase {
-
+public class BatchTest extends FunctionalTestCase {
+
public BatchTest(String str) {
- super(str);
+ super( str );
}
-
+
+ public String[] getMappings() {
+ return new String[] { "batch/DataPoint.hbm.xml" };
+ }
+
+ public String getCacheConcurrencyStrategy() {
+ return null;
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty( Environment.STATEMENT_BATCH_SIZE, "20" );
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( BatchTest.class );
+ }
+
public void testBatchInsertUpdate() {
-
- //remember to set hibernate.jdbc.batch_size=20
-
long start = System.currentTimeMillis();
-
- final boolean flushInBatches = true;
final int N = 5000; //26 secs with batch flush, 26 without
//final int N = 100000; //53 secs with batch flush, OOME without
//final int N = 250000; //137 secs with batch flush, OOME without
-
+
Session s = openSession();
- s.setCacheMode(CacheMode.IGNORE);
- Transaction t = s.beginTransaction();
- for ( int i=0; i<N; i++ ) {
+ s.setCacheMode( CacheMode.IGNORE );
+ Transaction t = s.beginTransaction();
+ for ( int i = 0; i < N; i++ ) {
DataPoint dp = new DataPoint();
- dp.setX( new BigDecimal(i * 0.1d).setScale(19, BigDecimal.ROUND_DOWN) );
- dp.setY( new BigDecimal( Math.cos( dp.getX().doubleValue() ) ).setScale(19, BigDecimal.ROUND_DOWN) );
- s.save(dp);
- if ( flushInBatches && i % 20 == 0 ) {
+ dp.setX( new BigDecimal( i * 0.1d ).setScale( 19, BigDecimal.ROUND_DOWN ) );
+ dp.setY( new BigDecimal( Math.cos( dp.getX().doubleValue() ) ).setScale( 19, BigDecimal.ROUND_DOWN ) );
+ s.save( dp );
+ if ( i % 20 == 0 ) {
s.flush();
s.clear();
}
}
t.commit();
s.close();
-
+
s = openSession();
- s.setCacheMode(CacheMode.IGNORE);
+ s.setCacheMode( CacheMode.IGNORE );
t = s.beginTransaction();
int i = 0;
- ScrollableResults sr = s.createQuery("from DataPoint dp order by dp.x asc")
- .scroll(ScrollMode.FORWARD_ONLY);
+ ScrollableResults sr = s.createQuery( "from DataPoint dp order by dp.x asc" )
+ .scroll( ScrollMode.FORWARD_ONLY );
while ( sr.next() ) {
- DataPoint dp = (DataPoint) sr.get(0);
- dp.setDescription("done!");
- if ( flushInBatches && ++i % 20 == 0 ) {
+ DataPoint dp = ( DataPoint ) sr.get( 0 );
+ dp.setDescription( "done!" );
+ if ( ++i % 20 == 0 ) {
s.flush();
s.clear();
}
@@ -73,22 +84,6 @@
s.close();
System.out.println( System.currentTimeMillis() - start );
}
-
- protected void configure(Configuration cfg) {
- cfg.setProperty(Environment.STATEMENT_BATCH_SIZE, "20");
- }
- protected String[] getMappings() {
- return new String[] { "batch/DataPoint.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(BatchTest.class);
- }
-
- public String getCacheConcurrencyStrategy() {
- return null;
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/batchfetch/BatchFetchTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/batchfetch/BatchFetchTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/batchfetch/BatchFetchTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -6,118 +6,117 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class BatchFetchTest extends TestCase {
-
+public class BatchFetchTest extends FunctionalTestCase {
+
public BatchFetchTest(String str) {
- super(str);
+ super( str );
}
-
+
+ public String[] getMappings() {
+ return new String[] { "batchfetch/ProductLine.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( BatchFetchTest.class );
+ }
+
public void testBatchFetch() {
Session s = openSession();
Transaction t = s.beginTransaction();
ProductLine cars = new ProductLine();
- cars.setDescription("Cars");
- Model monaro = new Model(cars);
- monaro.setName("monaro");
- monaro.setDescription("Holden Monaro");
- Model hsv = new Model(cars);
- hsv.setName("hsv");
- hsv.setDescription("Holden Commodore HSV");
- s.save(cars);
-
+ cars.setDescription( "Cars" );
+ Model monaro = new Model( cars );
+ monaro.setName( "monaro" );
+ monaro.setDescription( "Holden Monaro" );
+ Model hsv = new Model( cars );
+ hsv.setName( "hsv" );
+ hsv.setDescription( "Holden Commodore HSV" );
+ s.save( cars );
+
ProductLine oss = new ProductLine();
- oss.setDescription("OSS");
- Model jboss = new Model(oss);
- jboss.setName("JBoss");
- jboss.setDescription("JBoss Application Server");
- Model hibernate = new Model(oss);
- hibernate.setName("Hibernate");
- hibernate.setDescription("Hibernate");
- Model cache = new Model(oss);
- cache.setName("JBossCache");
- cache.setDescription("JBoss TreeCache");
- s.save(oss);
-
+ oss.setDescription( "OSS" );
+ Model jboss = new Model( oss );
+ jboss.setName( "JBoss" );
+ jboss.setDescription( "JBoss Application Server" );
+ Model hibernate = new Model( oss );
+ hibernate.setName( "Hibernate" );
+ hibernate.setDescription( "Hibernate" );
+ Model cache = new Model( oss );
+ cache.setName( "JBossCache" );
+ cache.setDescription( "JBoss TreeCache" );
+ s.save( oss );
+
t.commit();
s.close();
-
- s.getSessionFactory().evict(Model.class);
- s.getSessionFactory().evict(ProductLine.class);
-
+
+ s.getSessionFactory().evict( Model.class );
+ s.getSessionFactory().evict( ProductLine.class );
+
s = openSession();
t = s.beginTransaction();
-
- List list = s.createQuery("from ProductLine pl order by pl.description").list();
- cars = (ProductLine) list.get(0);
- oss = (ProductLine) list.get(1);
+
+ List list = s.createQuery( "from ProductLine pl order by pl.description" ).list();
+ cars = ( ProductLine ) list.get( 0 );
+ oss = ( ProductLine ) list.get( 1 );
assertFalse( Hibernate.isInitialized( cars.getModels() ) );
assertFalse( Hibernate.isInitialized( oss.getModels() ) );
assertEquals( cars.getModels().size(), 2 ); //fetch both collections
assertTrue( Hibernate.isInitialized( cars.getModels() ) );
assertTrue( Hibernate.isInitialized( oss.getModels() ) );
-
+
s.clear();
-
- list = s.createQuery("from Model m").list();
- hibernate = (Model) s.get(Model.class, hibernate.getId());
+
+ list = s.createQuery( "from Model m" ).list();
+ hibernate = ( Model ) s.get( Model.class, hibernate.getId() );
hibernate.getProductLine().getId();
- for ( Iterator i=list.iterator(); i.hasNext(); ) {
- assertFalse( Hibernate.isInitialized( ( (Model) i.next() ).getProductLine() ) );
+ for ( Iterator i = list.iterator(); i.hasNext(); ) {
+ assertFalse( Hibernate.isInitialized( ( ( Model ) i.next() ).getProductLine() ) );
}
assertEquals( hibernate.getProductLine().getDescription(), "OSS" ); //fetch both productlines
-
+
s.clear();
-
- Iterator iter = s.createQuery("from Model").iterate();
+
+ Iterator iter = s.createQuery( "from Model" ).iterate();
list = new ArrayList();
while ( iter.hasNext() ) {
list.add( iter.next() );
}
- Model m = (Model) list.get(0);
+ Model m = ( Model ) list.get( 0 );
m.getDescription(); //fetch a batch of 4
-
+
s.clear();
-
- list = s.createQuery("from ProductLine").list();
- ProductLine pl = (ProductLine) list.get(0);
- ProductLine pl2 = (ProductLine) list.get(1);
- s.evict(pl2);
+
+ list = s.createQuery( "from ProductLine" ).list();
+ ProductLine pl = ( ProductLine ) list.get( 0 );
+ ProductLine pl2 = ( ProductLine ) list.get( 1 );
+ s.evict( pl2 );
pl.getModels().size(); //fetch just one collection! (how can we write an assertion for that??)
-
+
t.commit();
s.close();
s = openSession();
t = s.beginTransaction();
- list = s.createQuery("from ProductLine pl order by pl.description").list();
- cars = (ProductLine) list.get(0);
- oss = (ProductLine) list.get(1);
+ list = s.createQuery( "from ProductLine pl order by pl.description" ).list();
+ cars = ( ProductLine ) list.get( 0 );
+ oss = ( ProductLine ) list.get( 1 );
assertEquals( cars.getModels().size(), 2 );
assertEquals( oss.getModels().size(), 3 );
- s.delete(cars);
- s.delete(oss);
+ s.delete( cars );
+ s.delete( oss );
t.commit();
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "batchfetch/ProductLine.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(BatchFetchTest.class);
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bidi/AuctionTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bidi/AuctionTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bidi/AuctionTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -5,65 +5,75 @@
import java.util.Date;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.dialect.PostgreSQLDialect;
-import org.hibernate.test.TestCase;
/**
* @author Gavin King
*/
-public class AuctionTest extends TestCase {
-
+public class AuctionTest extends FunctionalTestCase {
+
public AuctionTest(String str) {
- super(str);
+ super( str );
}
-
+
+ public String[] getMappings() {
+ return new String[] { "bidi/Auction.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( AuctionTest.class );
+ }
+
public void testLazy() {
- if ( getDialect() instanceof PostgreSQLDialect ) return; //doesn't like boolean=1
-
+ if ( getDialect() instanceof PostgreSQLDialect ) {
+ return; //doesn't like boolean=1
+ }
+
Session s = openSession();
Transaction t = s.beginTransaction();
Auction a = new Auction();
- a.setDescription("an auction for something");
+ a.setDescription( "an auction for something" );
a.setEnd( new Date() );
Bid b = new Bid();
- b.setAmount( new BigDecimal(123.34).setScale(19, BigDecimal.ROUND_DOWN) );
- b.setSuccessful(true);
+ b.setAmount( new BigDecimal( 123.34 ).setScale( 19, BigDecimal.ROUND_DOWN ) );
+ b.setSuccessful( true );
b.setDatetime( new Date() );
- b.setItem(a);
- a.getBids().add(b);
- a.setSuccessfulBid(b);
- s.persist(b);
+ b.setItem( a );
+ a.getBids().add( b );
+ a.setSuccessfulBid( b );
+ s.persist( b );
t.commit();
s.close();
-
+
Long aid = a.getId();
Long bid = b.getId();
-
+
s = openSession();
t = s.beginTransaction();
- b = (Bid) s.load( Bid.class, bid );
- assertFalse( Hibernate.isInitialized(b) );
- a = (Auction) s.get( Auction.class, aid );
+ b = ( Bid ) s.load( Bid.class, bid );
+ assertFalse( Hibernate.isInitialized( b ) );
+ a = ( Auction ) s.get( Auction.class, aid );
assertFalse( Hibernate.isInitialized( a.getBids() ) );
assertTrue( Hibernate.isInitialized( a.getSuccessfulBid() ) );
assertSame( a.getBids().iterator().next(), b );
assertSame( b, a.getSuccessfulBid() );
- assertTrue( Hibernate.isInitialized(b) );
+ assertTrue( Hibernate.isInitialized( b ) );
assertTrue( b.isSuccessful() );
t.commit();
s.close();
s = openSession();
t = s.beginTransaction();
- b = (Bid) s.load( Bid.class, bid );
- assertFalse( Hibernate.isInitialized(b) );
- a = (Auction) s.createQuery("from Auction a left join fetch a.bids").uniqueResult();
- assertTrue( Hibernate.isInitialized(b) );
+ b = ( Bid ) s.load( Bid.class, bid );
+ assertFalse( Hibernate.isInitialized( b ) );
+ a = ( Auction ) s.createQuery( "from Auction a left join fetch a.bids" ).uniqueResult();
+ assertTrue( Hibernate.isInitialized( b ) );
assertTrue( Hibernate.isInitialized( a.getBids() ) );
assertSame( b, a.getSuccessfulBid() );
assertSame( a.getBids().iterator().next(), b );
@@ -73,13 +83,13 @@
s = openSession();
t = s.beginTransaction();
- b = (Bid) s.load( Bid.class, bid );
- a = (Auction) s.load( Auction.class, aid );
- assertFalse( Hibernate.isInitialized(b) );
- assertFalse( Hibernate.isInitialized(a) );
- s.createQuery("from Auction a left join fetch a.successfulBid").list();
- assertTrue( Hibernate.isInitialized(b) );
- assertTrue( Hibernate.isInitialized(a) );
+ b = ( Bid ) s.load( Bid.class, bid );
+ a = ( Auction ) s.load( Auction.class, aid );
+ assertFalse( Hibernate.isInitialized( b ) );
+ assertFalse( Hibernate.isInitialized( a ) );
+ s.createQuery( "from Auction a left join fetch a.successfulBid" ).list();
+ assertTrue( Hibernate.isInitialized( b ) );
+ assertTrue( Hibernate.isInitialized( a ) );
assertSame( b, a.getSuccessfulBid() );
assertFalse( Hibernate.isInitialized( a.getBids() ) );
assertSame( a.getBids().iterator().next(), b );
@@ -89,14 +99,14 @@
s = openSession();
t = s.beginTransaction();
- b = (Bid) s.load( Bid.class, bid );
- a = (Auction) s.load( Auction.class, aid );
- assertFalse( Hibernate.isInitialized(b) );
- assertFalse( Hibernate.isInitialized(a) );
+ b = ( Bid ) s.load( Bid.class, bid );
+ a = ( Auction ) s.load( Auction.class, aid );
+ assertFalse( Hibernate.isInitialized( b ) );
+ assertFalse( Hibernate.isInitialized( a ) );
assertSame( s.get( Bid.class, bid ), b );
- assertTrue( Hibernate.isInitialized(b) );
- assertSame( s.get(Auction.class, aid ), a );
- assertTrue( Hibernate.isInitialized(a) );
+ assertTrue( Hibernate.isInitialized( b ) );
+ assertSame( s.get( Auction.class, aid ), a );
+ assertTrue( Hibernate.isInitialized( a ) );
assertSame( b, a.getSuccessfulBid() );
assertFalse( Hibernate.isInitialized( a.getBids() ) );
assertSame( a.getBids().iterator().next(), b );
@@ -104,14 +114,6 @@
t.commit();
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "bidi/Auction.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(AuctionTest.class);
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bidi/AuctionTest2.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bidi/AuctionTest2.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bidi/AuctionTest2.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -7,64 +7,74 @@
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.dialect.Oracle9Dialect;
-import org.hibernate.test.TestCase;
import junit.framework.Test;
-import junit.framework.TestSuite;
/**
* @author Gavin King
*/
-public class AuctionTest2 extends TestCase {
-
+public class AuctionTest2 extends FunctionalTestCase {
+
public AuctionTest2(String str) {
- super(str);
+ super( str );
}
+ public String[] getMappings() {
+ return new String[] { "bidi/Auction2.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( AuctionTest2.class );
+ }
+
public void testLazy() {
-
- if ( getDialect() instanceof Oracle9Dialect ) return; //ora doesn't like exists() in the select clause
-
+
+ if ( getDialect() instanceof Oracle9Dialect ) {
+ return; //ora doesn't like exists() in the select clause
+ }
+
Session s = openSession();
Transaction t = s.beginTransaction();
Auction a = new Auction();
- a.setDescription("an auction for something");
+ a.setDescription( "an auction for something" );
a.setEnd( new Date() );
Bid b = new Bid();
- b.setAmount( new BigDecimal(123.34).setScale(19, BigDecimal.ROUND_DOWN) );
- b.setSuccessful(true);
+ b.setAmount( new BigDecimal( 123.34 ).setScale( 19, BigDecimal.ROUND_DOWN ) );
+ b.setSuccessful( true );
b.setDatetime( new Date() );
- b.setItem(a);
- a.getBids().add(b);
- a.setSuccessfulBid(b);
- s.persist(b);
+ b.setItem( a );
+ a.getBids().add( b );
+ a.setSuccessfulBid( b );
+ s.persist( b );
t.commit();
s.close();
-
+
Long aid = a.getId();
Long bid = b.getId();
-
+
s = openSession();
t = s.beginTransaction();
- b = (Bid) s.load( Bid.class, bid );
- assertFalse( Hibernate.isInitialized(b) );
- a = (Auction) s.get( Auction.class, aid );
+ b = ( Bid ) s.load( Bid.class, bid );
+ assertFalse( Hibernate.isInitialized( b ) );
+ a = ( Auction ) s.get( Auction.class, aid );
assertFalse( Hibernate.isInitialized( a.getBids() ) );
assertFalse( Hibernate.isInitialized( a.getSuccessfulBid() ) );
assertSame( a.getBids().iterator().next(), b );
assertSame( b, a.getSuccessfulBid() );
- assertTrue( Hibernate.isInitialized(b) );
+ assertTrue( Hibernate.isInitialized( b ) );
assertTrue( b.isSuccessful() );
t.commit();
s.close();
s = openSession();
t = s.beginTransaction();
- b = (Bid) s.load( Bid.class, bid );
- assertFalse( Hibernate.isInitialized(b) );
- a = (Auction) s.createQuery("from Auction a left join fetch a.bids").uniqueResult();
- assertTrue( Hibernate.isInitialized(b) );
+ b = ( Bid ) s.load( Bid.class, bid );
+ assertFalse( Hibernate.isInitialized( b ) );
+ a = ( Auction ) s.createQuery( "from Auction a left join fetch a.bids" ).uniqueResult();
+ assertTrue( Hibernate.isInitialized( b ) );
assertTrue( Hibernate.isInitialized( a.getBids() ) );
assertSame( b, a.getSuccessfulBid() );
assertSame( a.getBids().iterator().next(), b );
@@ -74,13 +84,13 @@
s = openSession();
t = s.beginTransaction();
- b = (Bid) s.load( Bid.class, bid );
- a = (Auction) s.load( Auction.class, aid );
- assertFalse( Hibernate.isInitialized(b) );
- assertFalse( Hibernate.isInitialized(a) );
- s.createQuery("from Auction a left join fetch a.successfulBid").list();
- assertTrue( Hibernate.isInitialized(b) );
- assertTrue( Hibernate.isInitialized(a) );
+ b = ( Bid ) s.load( Bid.class, bid );
+ a = ( Auction ) s.load( Auction.class, aid );
+ assertFalse( Hibernate.isInitialized( b ) );
+ assertFalse( Hibernate.isInitialized( a ) );
+ s.createQuery( "from Auction a left join fetch a.successfulBid" ).list();
+ assertTrue( Hibernate.isInitialized( b ) );
+ assertTrue( Hibernate.isInitialized( a ) );
assertSame( b, a.getSuccessfulBid() );
assertFalse( Hibernate.isInitialized( a.getBids() ) );
assertSame( a.getBids().iterator().next(), b );
@@ -90,14 +100,14 @@
s = openSession();
t = s.beginTransaction();
- b = (Bid) s.load( Bid.class, bid );
- a = (Auction) s.load( Auction.class, aid );
- assertFalse( Hibernate.isInitialized(b) );
- assertFalse( Hibernate.isInitialized(a) );
+ b = ( Bid ) s.load( Bid.class, bid );
+ a = ( Auction ) s.load( Auction.class, aid );
+ assertFalse( Hibernate.isInitialized( b ) );
+ assertFalse( Hibernate.isInitialized( a ) );
assertSame( s.get( Bid.class, bid ), b );
- assertTrue( Hibernate.isInitialized(b) );
- assertSame( s.get(Auction.class, aid ), a );
- assertTrue( Hibernate.isInitialized(a) );
+ assertTrue( Hibernate.isInitialized( b ) );
+ assertSame( s.get( Auction.class, aid ), a );
+ assertTrue( Hibernate.isInitialized( a ) );
assertSame( b, a.getSuccessfulBid() );
assertFalse( Hibernate.isInitialized( a.getBids() ) );
assertSame( a.getBids().iterator().next(), b );
@@ -105,13 +115,5 @@
t.commit();
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "bidi/Auction2.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(AuctionTest2.class);
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bytecode/cglib/InvocationTargetExceptionTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bytecode/cglib/InvocationTargetExceptionTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bytecode/cglib/InvocationTargetExceptionTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -4,6 +4,9 @@
import org.hibernate.test.bytecode.Bean;
import org.hibernate.Session;
import org.hibernate.Hibernate;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.cfg.Environment;
import junit.framework.TestSuite;
@@ -15,17 +18,17 @@
*
* @author Steve Ebersole
*/
-public class InvocationTargetExceptionTest extends TestCase {
+public class InvocationTargetExceptionTest extends FunctionalTestCase {
public InvocationTargetExceptionTest(String name) {
super( name );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "bytecode/Bean.hbm.xml" };
}
public static TestSuite suite() {
- return new TestSuite( InvocationTargetExceptionTest.class );
+ return new FunctionalTestClassTestSuite( InvocationTargetExceptionTest.class );
}
public void testProxiedInvocationException() {
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bytecode/cglib/ReflectionOptimizerTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bytecode/cglib/ReflectionOptimizerTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bytecode/cglib/ReflectionOptimizerTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,16 +1,22 @@
package org.hibernate.test.bytecode.cglib;
-import junit.framework.TestCase;
import junit.framework.TestSuite;
+
+import org.hibernate.bytecode.ReflectionOptimizer;
import org.hibernate.bytecode.cglib.BytecodeProviderImpl;
-import org.hibernate.bytecode.ReflectionOptimizer;
+import org.hibernate.junit.UnitTestCase;
import org.hibernate.test.bytecode.Bean;
import org.hibernate.test.bytecode.BeanReflectionHelper;
/**
* @author Steve Ebersole
*/
-public class ReflectionOptimizerTest extends TestCase {
+public class ReflectionOptimizerTest extends UnitTestCase {
+
+ public ReflectionOptimizerTest(String string) {
+ super( string );
+ }
+
public void testReflectionOptimization() {
BytecodeProviderImpl provider = new BytecodeProviderImpl();
ReflectionOptimizer optimizer = provider.getReflectionOptimizer(
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bytecode/javassist/InvocationTargetExceptionTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bytecode/javassist/InvocationTargetExceptionTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bytecode/javassist/InvocationTargetExceptionTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,38 +1,41 @@
package org.hibernate.test.bytecode.javassist;
-import org.hibernate.test.TestCase;
-import org.hibernate.test.bytecode.Bean;
-import org.hibernate.Session;
-import org.hibernate.Hibernate;
-import org.hibernate.cfg.Environment;
-
import java.text.ParseException;
import junit.framework.TestSuite;
+import org.hibernate.Hibernate;
+import org.hibernate.Session;
+import org.hibernate.cfg.Environment;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.test.bytecode.Bean;
+
/**
* Test that the Javassist-based lazy initializer properly handles
* InvocationTargetExceptions
*
* @author Steve Ebersole
*/
-public class InvocationTargetExceptionTest extends TestCase {
+public class InvocationTargetExceptionTest extends FunctionalTestCase {
public InvocationTargetExceptionTest(String name) {
super( name );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "bytecode/Bean.hbm.xml" };
}
public static TestSuite suite() {
- return new TestSuite( InvocationTargetExceptionTest.class );
+ return new FunctionalTestClassTestSuite( InvocationTargetExceptionTest.class );
}
public void testProxiedInvocationException() {
- if ( ! ( Environment.getBytecodeProvider() instanceof org.hibernate.bytecode.javassist.BytecodeProviderImpl ) ) {
+ if ( !( Environment.getBytecodeProvider() instanceof org.hibernate.bytecode.javassist.BytecodeProviderImpl ) ) {
// because of the scoping :(
- reportSkip( "env not configured for javassist provider", "bytecode-provider InvocationTargetException handling" );
+ reportSkip(
+ "env not configured for javassist provider", "bytecode-provider InvocationTargetException handling"
+ );
return;
}
Session s = openSession();
@@ -54,7 +57,7 @@
catch ( ParseException e ) {
// expected behavior
}
- catch( Throwable t ) {
+ catch ( Throwable t ) {
fail( "unexpected exception type : " + t );
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bytecode/javassist/ReflectionOptimizerTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bytecode/javassist/ReflectionOptimizerTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bytecode/javassist/ReflectionOptimizerTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,16 +1,22 @@
package org.hibernate.test.bytecode.javassist;
-import junit.framework.TestCase;
import junit.framework.TestSuite;
+
+import org.hibernate.bytecode.ReflectionOptimizer;
import org.hibernate.bytecode.javassist.BytecodeProviderImpl;
-import org.hibernate.bytecode.ReflectionOptimizer;
+import org.hibernate.junit.UnitTestCase;
import org.hibernate.test.bytecode.Bean;
import org.hibernate.test.bytecode.BeanReflectionHelper;
/**
* @author Steve Ebersole
*/
-public class ReflectionOptimizerTest extends TestCase {
+public class ReflectionOptimizerTest extends UnitTestCase {
+
+ public ReflectionOptimizerTest(String string) {
+ super( string );
+ }
+
public void testReflectionOptimization() {
BytecodeProviderImpl provider = new BytecodeProviderImpl();
ReflectionOptimizer optimizer = provider.getReflectionOptimizer(
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cache/BaseCacheProviderTestCase.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cache/BaseCacheProviderTestCase.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cache/BaseCacheProviderTestCase.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,16 +1,16 @@
package org.hibernate.test.cache;
+import java.util.HashMap;
import java.util.Map;
-import java.util.HashMap;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cache.ReadWriteCache;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
+import org.hibernate.junit.functional.FunctionalTestCase;
import org.hibernate.stat.SecondLevelCacheStatistics;
import org.hibernate.stat.Statistics;
-import org.hibernate.test.TestCase;
import org.hibernate.test.tm.DummyConnectionProvider;
import org.hibernate.test.tm.DummyTransactionManagerLookup;
import org.hibernate.transaction.JDBCTransactionFactory;
@@ -20,7 +20,7 @@
*
* @author Steve Ebersole
*/
-public abstract class BaseCacheProviderTestCase extends TestCase {
+public abstract class BaseCacheProviderTestCase extends FunctionalTestCase {
// note that a lot of the fucntionality here is intended to be used
// in creating specific tests for each CacheProvider that would extend
@@ -30,11 +30,11 @@
super( x );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "cache/Item.hbm.xml" };
}
- protected void configure(Configuration cfg) {
+ public void configure(Configuration cfg) {
super.configure( cfg );
cfg.setProperty( Environment.CACHE_REGION_PREFIX, "" );
cfg.setProperty( Environment.USE_SECOND_LEVEL_CACHE, "true" );
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cache/ehcache/EhCacheTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cache/ehcache/EhCacheTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cache/ehcache/EhCacheTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -2,9 +2,10 @@
package org.hibernate.test.cache.ehcache;
import junit.framework.Test;
-import junit.framework.TestSuite;
+
import org.hibernate.cache.EhCacheProvider;
import org.hibernate.cfg.Environment;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.test.cache.BaseCacheProviderTestCase;
/**
@@ -21,7 +22,7 @@
}
public static Test suite() {
- return new TestSuite( EhCacheTest.class );
+ return new FunctionalTestClassTestSuite( EhCacheTest.class );
}
public String getCacheConcurrencyStrategy() {
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cache/treecache/optimistic/OptimisticTreeCacheTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cache/treecache/optimistic/OptimisticTreeCacheTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cache/treecache/optimistic/OptimisticTreeCacheTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,16 +1,17 @@
package org.hibernate.test.cache.treecache.optimistic;
import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.hibernate.cache.OptimisticTreeCacheProvider;
-import org.hibernate.cfg.Environment;
-import org.hibernate.test.cache.BaseCacheProviderTestCase;
-import org.hibernate.test.tm.DummyTransactionManager;
import org.jboss.cache.Fqn;
import org.jboss.cache.TreeCache;
import org.jboss.cache.config.Option;
import org.jboss.cache.optimistic.DataVersion;
+import org.hibernate.cache.OptimisticTreeCacheProvider;
+import org.hibernate.cfg.Environment;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.test.cache.BaseCacheProviderTestCase;
+import org.hibernate.test.tm.DummyTransactionManager;
+
/**
* @author Steve Ebersole
*/
@@ -25,7 +26,7 @@
}
public static Test suite() {
- return new TestSuite( OptimisticTreeCacheTest.class );
+ return new FunctionalTestClassTestSuite( OptimisticTreeCacheTest.class );
}
public String getCacheConcurrencyStrategy() {
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cache/treecache/pessimistic/TreeCacheTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cache/treecache/pessimistic/TreeCacheTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cache/treecache/pessimistic/TreeCacheTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,10 +1,11 @@
package org.hibernate.test.cache.treecache.pessimistic;
-import org.hibernate.test.cache.BaseCacheProviderTestCase;
+import junit.framework.Test;
+
import org.hibernate.cache.TreeCacheProvider;
import org.hibernate.cfg.Environment;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.test.cache.BaseCacheProviderTestCase;
/**
* @author Steve Ebersole
@@ -20,7 +21,7 @@
}
public static Test suite() {
- return new TestSuite( TreeCacheTest.class );
+ return new FunctionalTestClassTestSuite( TreeCacheTest.class );
}
public String getCacheConcurrencyStrategy() {
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cascade/RefreshTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cascade/RefreshTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cascade/RefreshTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,38 +1,35 @@
// $Id$
package org.hibernate.test.cascade;
-import org.hibernate.test.TestCase;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-
-import java.util.Date;
-import java.util.Iterator;
import java.sql.Connection;
import java.sql.PreparedStatement;
+import java.util.Date;
+import java.util.Iterator;
import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+
/**
* Implementation of RefreshTest.
*
* @author Steve Ebersole
*/
-public class RefreshTest extends TestCase {
+public class RefreshTest extends FunctionalTestCase {
public RefreshTest(String name) {
super( name );
}
- protected String[] getMappings() {
- return new String[] {
- "cascade/Job.hbm.xml",
- "cascade/JobBatch.hbm.xml"
- };
+ public String[] getMappings() {
+ return new String[] { "cascade/Job.hbm.xml", "cascade/JobBatch.hbm.xml" };
}
public static Test suite() {
- return new TestSuite( RefreshTest.class );
+ return new FunctionalTestClassTestSuite( RefreshTest.class );
}
public void testRefreshCascade() throws Throwable {
@@ -64,7 +61,6 @@
}
private void updateStatuses(Connection connection) throws Throwable {
-
PreparedStatement stmnt = null;
try {
stmnt = connection.prepareStatement( "UPDATE T_JOB SET JOB_STATUS = 1" );
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cfg/CacheableFileTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cfg/CacheableFileTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cfg/CacheableFileTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -2,21 +2,24 @@
import java.io.File;
-import junit.framework.TestCase;
-
import org.hibernate.cfg.Configuration;
+import org.hibernate.junit.UnitTestCase;
/**
* {@inheritDoc}
*
* @author Steve Ebersole
*/
-public class CacheableFileTest extends TestCase {
+public class CacheableFileTest extends UnitTestCase {
public static final String MAPPING = "org/hibernate/test/cfg/Cacheable.hbm.xml";
private File mappingFile;
+ public CacheableFileTest(String string) {
+ super( string );
+ }
+
protected void setUp() throws Exception {
super.setUp();
mappingFile = new File( getClass().getClassLoader().getResource( MAPPING ).getFile() );
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cid/CompositeIdTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cid/CompositeIdTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cid/CompositeIdTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -7,21 +7,29 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class CompositeIdTest extends TestCase {
+public class CompositeIdTest extends FunctionalTestCase {
public CompositeIdTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "cid/Customer.hbm.xml", "cid/Order.hbm.xml", "cid/LineItem.hbm.xml", "cid/Product.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite(CompositeIdTest.class);
+ }
public void testQuery() {
Session s = openSession();
@@ -257,18 +265,5 @@
s.close();
}
- protected String[] getMappings() {
- return new String[] {
- "cid/Customer.hbm.xml",
- "cid/Order.hbm.xml",
- "cid/LineItem.hbm.xml",
- "cid/Product.hbm.xml"
- };
- }
-
- public static Test suite() {
- return new TestSuite(CompositeIdTest.class);
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/CollectionSuite.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/CollectionSuite.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/CollectionSuite.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -7,10 +7,11 @@
import org.hibernate.test.collection.idbag.PersistentIdBagTest;
import org.hibernate.test.collection.list.PersistentListTest;
import org.hibernate.test.collection.map.PersistentMapTest;
+import org.hibernate.test.collection.original.CollectionTest;
import org.hibernate.test.collection.set.PersistentSetTest;
/**
- * Suite of collection (esp PersistentCollection) related tests
+ * Suite of collection (i.e. PersistentCollection) related tests
*
* @author Steve Ebersole
*/
@@ -18,11 +19,11 @@
public static Test suite() {
TestSuite suite = new TestSuite( "Collection-related tests" );
- suite.addTest( CollectionTest.suite() );
suite.addTest( PersistentBagTest.suite() );
suite.addTest( PersistentIdBagTest.suite() );
suite.addTest( PersistentListTest.suite() );
suite.addTest( PersistentMapTest.suite() );
+ suite.addTest( CollectionTest.suite() );
suite.addTest( PersistentSetTest.suite() );
return suite;
}
Deleted: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/CollectionTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/CollectionTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/CollectionTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,252 +0,0 @@
-//$Id$
-package org.hibernate.test.collection;
-
-import java.sql.SQLException;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.hibernate.Hibernate;
-import org.hibernate.HibernateException;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
-
-/**
- * @author Gavin King
- */
-public class CollectionTest extends TestCase {
-
- public CollectionTest(String str) {
- super(str);
- }
-
- public void testExtraLazy() throws HibernateException, SQLException {
- Session s = openSession();
- Transaction t = s.beginTransaction();
- User u = new User("gavin");
- u.getPermissions().add( new Permission("obnoxiousness") );
- u.getPermissions().add( new Permission("pigheadedness") );
- u.getSessionData().put("foo", "foo value");
- s.persist(u);
- t.commit();
- s.close();
- s = openSession();
- t = s.beginTransaction();
- u = (User) s.get(User.class, "gavin");
-
- assertFalse( Hibernate.isInitialized( u.getPermissions() ) );
- assertEquals( u.getPermissions().size(), 2 );
- assertTrue( u.getPermissions().contains( new Permission("obnoxiousness") ) );
- assertFalse( u.getPermissions().contains( new Permission("silliness") ) );
- assertNotNull( u.getPermissions().get(1) );
- assertNull( u.getPermissions().get(3) );
- assertFalse( Hibernate.isInitialized( u.getPermissions() ) );
-
- assertFalse( Hibernate.isInitialized( u.getSessionData() ) );
- assertEquals( u.getSessionData().size(), 1 );
- assertTrue( u.getSessionData().containsKey("foo") );
- assertFalse( u.getSessionData().containsKey("bar") );
- assertTrue( u.getSessionData().containsValue("foo value") );
- assertFalse( u.getSessionData().containsValue("bar") );
- assertEquals( "foo value", u.getSessionData().get("foo") );
- assertNull( u.getSessionData().get("bar") );
- assertFalse( Hibernate.isInitialized( u.getSessionData() ) );
-
- assertFalse( Hibernate.isInitialized( u.getSessionData() ) );
- u.getSessionData().put("bar", "bar value");
- u.getSessionAttributeNames().add("bar");
- assertFalse( Hibernate.isInitialized( u.getSessionAttributeNames() ) );
- assertTrue( Hibernate.isInitialized( u.getSessionData() ) );
-
- s.delete(u);
- t.commit();
- s.close();
- }
-
- /*public void testFilter() throws HibernateException, SQLException {
- Session s = openSession();
- Transaction t = s.beginTransaction();
- User u = new User("gavin");
- u.getPermissions().add( new Permission("obnoxiousness") );
- u.getPermissions().add( new Permission("pigheadedness") );
- s.persist(u);
- t.commit();
- s.close();
- s = openSession();
- t = s.beginTransaction();
- u = (User) s.get(User.class, "gavin");
- assertFalse( Hibernate.isInitialized( u.getPermissions() ) );
- assertEquals( s.createFilter( u.getPermissions(), "select count(*)" ).uniqueResult(), new Integer(2) );
- assertFalse( Hibernate.isInitialized( u.getPermissions() ) );
- assertFalse( Hibernate.isInitialized( u.getSessionData() ) );
- assertEquals( s.createFilter( u.getSessionData(), "select count(*)" ).uniqueResult(), new Integer(0) );
- assertFalse( Hibernate.isInitialized( u.getSessionData() ) );
- s.delete(u);
- t.commit();
- s.close();
- }*/
-
- public void testMerge() throws HibernateException, SQLException {
- Session s = openSession();
- Transaction t = s.beginTransaction();
- User u = new User("gavin");
- u.getPermissions().add( new Permission("obnoxiousness") );
- u.getPermissions().add( new Permission("pigheadedness") );
- s.persist(u);
- t.commit();
- s.close();
-
- s = openSession();
- t = s.beginTransaction();
- User u2 = (User) s.createCriteria(User.class).uniqueResult();
- u2.setPermissions(null); //forces one shot delete
- s.merge(u);
- t.commit();
- s.close();
-
- u.getPermissions().add( new Permission("silliness") );
-
- s = openSession();
- t = s.beginTransaction();
- s.merge(u);
- t.commit();
- s.close();
-
- s = openSession();
- t = s.beginTransaction();
- u2 = (User) s.createCriteria(User.class).uniqueResult();
- assertEquals( u2.getPermissions().size(), 3 );
- assertEquals( ( (Permission) u2.getPermissions().get(0) ).getType(), "obnoxiousness" );
- assertEquals( ( (Permission) u2.getPermissions().get(2) ).getType(), "silliness" );
- t.commit();
- s.close();
-
- s = openSession();
- t = s.beginTransaction();
- s.delete(u2);
- s.flush();
- t.commit();
- s.close();
-
- }
-
- public void testFetch() {
- Session s = openSession();
- Transaction t = s.beginTransaction();
- User u = new User("gavin");
- u.getPermissions().add( new Permission("obnoxiousness") );
- u.getPermissions().add( new Permission("pigheadedness") );
- u.getEmailAddresses().add( new Email("gavin(a)hibernate.org") );
- u.getEmailAddresses().add( new Email("gavin.king(a)jboss.com") );
- s.persist(u);
- t.commit();
- s.close();
-
- s = openSession();
- t = s.beginTransaction();
- User u2 = (User) s.createCriteria(User.class).uniqueResult();
- assertTrue( Hibernate.isInitialized( u2.getEmailAddresses() ) );
- assertFalse( Hibernate.isInitialized( u2.getPermissions() ) );
- assertEquals( u2.getEmailAddresses().size(), 2 );
- s.delete(u2);
- t.commit();
- s.close();
- }
-
- public void testUpdateOrder() {
- Session s = openSession();
- Transaction t = s.beginTransaction();
- User u = new User("gavin");
- u.getSessionData().put("foo", "foo value");
- u.getSessionData().put("bar", "bar value");
- u.getEmailAddresses().add( new Email("gavin.king(a)jboss.com") );
- u.getEmailAddresses().add( new Email("gavin(a)hibernate.org") );
- u.getEmailAddresses().add( new Email("gavin(a)illflow.com") );
- u.getEmailAddresses().add( new Email("gavin(a)nospam.com") );
- s.persist(u);
- t.commit();
- s.close();
-
- u.getSessionData().clear();
- u.getSessionData().put("baz", "baz value");
- u.getSessionData().put("bar", "bar value");
- u.getEmailAddresses().remove(0);
- u.getEmailAddresses().remove(2);
-
- s = openSession();
- t = s.beginTransaction();
- s.update(u);
- t.commit();
- s.close();
-
- u.getSessionData().clear();
- u.getEmailAddresses().add(0, new Email("gavin(a)nospam.com") );
- u.getEmailAddresses().add( new Email("gavin.king(a)jboss.com") );
-
- s = openSession();
- t = s.beginTransaction();
- s.update(u);
- t.commit();
- s.close();
-
- s = openSession();
- t = s.beginTransaction();
- s.delete(u);
- t.commit();
- s.close();
-
- }
-
- public void testValueMap() {
- Session s = openSession();
- Transaction t = s.beginTransaction();
- User u = new User("gavin");
- u.getSessionData().put("foo", "foo value");
- u.getSessionData().put("bar", null);
- u.getEmailAddresses().add(null);
- u.getEmailAddresses().add( new Email("gavin.king(a)jboss.com") );
- u.getEmailAddresses().add(null);
- u.getEmailAddresses().add(null);
- s.persist(u);
- t.commit();
- s.close();
-
- s = openSession();
- t = s.beginTransaction();
- User u2 = (User) s.createCriteria(User.class).uniqueResult();
- assertFalse( Hibernate.isInitialized( u2.getSessionData() ) );
- assertEquals( u2.getSessionData().size(), 1 );
- assertEquals( u2.getEmailAddresses().size(), 2 );
- u2.getSessionData().put("foo", "new foo value");
- u2.getEmailAddresses().set( 1, new Email("gavin(a)hibernate.org") );
- //u2.getEmailAddresses().remove(3);
- //u2.getEmailAddresses().remove(2);
- t.commit();
- s.close();
-
- s = openSession();
- t = s.beginTransaction();
- u2 = (User) s.createCriteria(User.class).uniqueResult();
- assertFalse( Hibernate.isInitialized( u2.getSessionData() ) );
- assertEquals( u2.getSessionData().size(), 1 );
- assertEquals( u2.getEmailAddresses().size(), 2 );
- assertEquals( u2.getSessionData().get("foo"), "new foo value" );
- assertEquals( ( (Email) u2.getEmailAddresses().get(1) ).getAddress(), "gavin(a)hibernate.org" );
- s.delete(u2);
- t.commit();
- s.close();
- }
-
-
-
- protected String[] getMappings() {
- return new String[] { "collection/UserPermissions.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(CollectionTest.class);
- }
-
-}
-
Deleted: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/Email.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/Email.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/Email.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,27 +0,0 @@
-//$Id$
-package org.hibernate.test.collection;
-
-/**
- * @author Gavin King
- */
-public class Email {
- private String address;
- Email() {}
- public String getAddress() {
- return address;
- }
- public void setAddress(String type) {
- this.address = type;
- }
- public Email(String type) {
- this.address = type;
- }
- public boolean equals(Object that) {
- if ( !(that instanceof Email) ) return false;
- Email p = (Email) that;
- return this.address.equals(p.address);
- }
- public int hashCode() {
- return address.hashCode();
- }
-}
Deleted: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/Permission.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/Permission.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/Permission.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,27 +0,0 @@
-//$Id$
-package org.hibernate.test.collection;
-
-/**
- * @author Gavin King
- */
-public class Permission {
- private String type;
- Permission() {}
- public String getType() {
- return type;
- }
- public void setType(String type) {
- this.type = type;
- }
- public Permission(String type) {
- this.type = type;
- }
- public boolean equals(Object that) {
- if ( !(that instanceof Permission) ) return false;
- Permission p = (Permission) that;
- return this.type.equals(p.type);
- }
- public int hashCode() {
- return type.hashCode();
- }
-}
Deleted: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/User.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/User.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/User.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,55 +0,0 @@
-//$Id$
-package org.hibernate.test.collection;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author Gavin King
- */
-public class User {
- private String userName;
- private List permissions = new ArrayList();
- private List emailAddresses = new ArrayList();
- private Map sessionData = new HashMap();
- private Set sessionAttributeNames = new HashSet();
-
- User() {}
- public User(String name) {
- userName = name;
- }
- public List getPermissions() {
- return permissions;
- }
- public void setPermissions(List permissions) {
- this.permissions = permissions;
- }
- public String getUserName() {
- return userName;
- }
- public void setUserName(String userName) {
- this.userName = userName;
- }
- public List getEmailAddresses() {
- return emailAddresses;
- }
- public void setEmailAddresses(List emailAddresses) {
- this.emailAddresses = emailAddresses;
- }
- public Map getSessionData() {
- return sessionData;
- }
- public void setSessionData(Map sessionData) {
- this.sessionData = sessionData;
- }
- public Set getSessionAttributeNames() {
- return sessionAttributeNames;
- }
- public void setSessionAttributeNames(Set sessionAttributeNames) {
- this.sessionAttributeNames = sessionAttributeNames;
- }
-}
Deleted: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/UserPermissions.hbm.xml
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/UserPermissions.hbm.xml 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/UserPermissions.hbm.xml 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,54 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-
-<!--
-
- This mapping demonstrates how to use a composite
- element mapping to model a parent/child association.
-
--->
-
-<hibernate-mapping
- package="org.hibernate.test.collection">
-
- <import class="Permission"/>
-
- <class name="User" table="`Users`">
- <id name="userName"/>
- <list name="permissions" lazy="extra">
- <key column="userName"/>
- <list-index column="displayOrder" base="1"/>
- <composite-element class="Permission">
- <property name="type" column="permissionType"/>
- </composite-element>
- </list>
- <list name="emailAddresses" fetch="join">
- <key column="userName"/>
- <list-index column="displayOrder" base="1"/>
- <composite-element class="Email">
- <property name="address"/>
- </composite-element>
- </list>
- <map name="sessionData"
- order-by="lower(`attributeName`) asc"
- lazy="extra">
- <key column="userName"/>
- <map-key column="`attributeName`"
- type="string"/>
- <element column="`attributeValue`"
- type="serializable"
- not-null="true"/>
- </map>
- <set name="sessionAttributeNames"
- lazy="extra"
- inverse="true">
- <key column="userName"/>
- <element column="`attributeName`"
- type="string"/>
- </set>
- </class>
-
-
-</hibernate-mapping>
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/bag/PersistentBagTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/bag/PersistentBagTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/bag/PersistentBagTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,31 +1,30 @@
package org.hibernate.test.collection.bag;
-import java.util.HashSet;
import java.util.ArrayList;
import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.hibernate.test.TestCase;
import org.hibernate.Session;
import org.hibernate.collection.PersistentBag;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* Tests related to operations on a PersistentBag.
*
* @author Steve Ebersole
*/
-public class PersistentBagTest extends TestCase {
+public class PersistentBagTest extends FunctionalTestCase {
public PersistentBagTest(String name) {
super( name );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "collection/bag/Mappings.hbm.xml" };
}
public static Test suite() {
- return new TestSuite( PersistentBagTest.class );
+ return new FunctionalTestClassTestSuite( PersistentBagTest.class );
}
public void testWriteMethodDirtying() {
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/idbag/PersistentIdBagTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/idbag/PersistentIdBagTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/idbag/PersistentIdBagTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -3,28 +3,28 @@
import java.util.ArrayList;
import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.hibernate.test.TestCase;
import org.hibernate.Session;
import org.hibernate.collection.PersistentIdentifierBag;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* Tests related to operations on a PersistentIdentifierBag
*
* @author Steve Ebersole
*/
-public class PersistentIdBagTest extends TestCase {
+public class PersistentIdBagTest extends FunctionalTestCase {
public PersistentIdBagTest(String name) {
super( name );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "collection/idbag/Mappings.hbm.xml" };
}
public static Test suite() {
- return new TestSuite( PersistentIdBagTest.class );
+ return new FunctionalTestClassTestSuite( PersistentIdBagTest.class );
}
public void testWriteMethodDirtying() {
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/list/PersistentListTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/list/PersistentListTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/list/PersistentListTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -3,28 +3,28 @@
import java.util.ArrayList;
import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.hibernate.test.TestCase;
import org.hibernate.Session;
import org.hibernate.collection.PersistentList;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* Tests related to operations on a PersistentList
*
* @author Steve Ebersole
*/
-public class PersistentListTest extends TestCase {
+public class PersistentListTest extends FunctionalTestCase {
public PersistentListTest(String name) {
super( name );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "collection/list/Mappings.hbm.xml" };
}
public static Test suite() {
- return new TestSuite( PersistentListTest.class );
+ return new FunctionalTestClassTestSuite( PersistentListTest.class );
}
public void testWriteMethodDirtying() {
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/map/PersistentMapTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/map/PersistentMapTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/map/PersistentMapTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,30 +1,30 @@
package org.hibernate.test.collection.map;
-import org.hibernate.test.TestCase;
-import org.hibernate.Session;
-import org.hibernate.collection.PersistentMap;
-
import java.util.HashMap;
import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.Session;
+import org.hibernate.collection.PersistentMap;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+
/**
* todo: describe PersistentMapTest
*
* @author Steve Ebersole
*/
-public class PersistentMapTest extends TestCase {
+public class PersistentMapTest extends FunctionalTestCase {
public PersistentMapTest(String name) {
super( name );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "collection/map/Mappings.hbm.xml" };
}
public static Test suite() {
- return new TestSuite( PersistentMapTest.class );
+ return new FunctionalTestClassTestSuite( PersistentMapTest.class );
}
public void testWriteMethodDirtying() {
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/original/CollectionTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/original/CollectionTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/original/CollectionTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,228 @@
+//$Id: CollectionTest.java 7628 2005-07-24 06:55:01Z oneovthafew $
+package org.hibernate.test.collection.original;
+
+import java.sql.SQLException;
+
+import junit.framework.Test;
+
+import org.hibernate.Hibernate;
+import org.hibernate.HibernateException;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+
+/**
+ * @author Gavin King
+ */
+public class CollectionTest extends FunctionalTestCase {
+
+ public CollectionTest(String str) {
+ super( str );
+ }
+
+ public String[] getMappings() {
+ return new String[] { "collection/original/UserPermissions.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( CollectionTest.class );
+ }
+
+ public void testExtraLazy() throws HibernateException, SQLException {
+ Session s = openSession();
+ Transaction t = s.beginTransaction();
+ User u = new User( "gavin" );
+ u.getPermissions().add( new Permission( "obnoxiousness" ) );
+ u.getPermissions().add( new Permission( "pigheadedness" ) );
+ u.getSessionData().put( "foo", "foo value" );
+ s.persist( u );
+ t.commit();
+ s.close();
+ s = openSession();
+ t = s.beginTransaction();
+ u = ( User ) s.get( User.class, "gavin" );
+
+ assertFalse( Hibernate.isInitialized( u.getPermissions() ) );
+ assertEquals( u.getPermissions().size(), 2 );
+ assertTrue( u.getPermissions().contains( new Permission( "obnoxiousness" ) ) );
+ assertFalse( u.getPermissions().contains( new Permission( "silliness" ) ) );
+ assertNotNull( u.getPermissions().get( 1 ) );
+ assertNull( u.getPermissions().get( 3 ) );
+ assertFalse( Hibernate.isInitialized( u.getPermissions() ) );
+
+ assertFalse( Hibernate.isInitialized( u.getSessionData() ) );
+ assertEquals( u.getSessionData().size(), 1 );
+ assertTrue( u.getSessionData().containsKey( "foo" ) );
+ assertFalse( u.getSessionData().containsKey( "bar" ) );
+ assertTrue( u.getSessionData().containsValue( "foo value" ) );
+ assertFalse( u.getSessionData().containsValue( "bar" ) );
+ assertEquals( "foo value", u.getSessionData().get( "foo" ) );
+ assertNull( u.getSessionData().get( "bar" ) );
+ assertFalse( Hibernate.isInitialized( u.getSessionData() ) );
+
+ assertFalse( Hibernate.isInitialized( u.getSessionData() ) );
+ u.getSessionData().put( "bar", "bar value" );
+ u.getSessionAttributeNames().add( "bar" );
+ assertFalse( Hibernate.isInitialized( u.getSessionAttributeNames() ) );
+ assertTrue( Hibernate.isInitialized( u.getSessionData() ) );
+
+ s.delete( u );
+ t.commit();
+ s.close();
+ }
+
+ public void testMerge() throws HibernateException, SQLException {
+ Session s = openSession();
+ Transaction t = s.beginTransaction();
+ User u = new User( "gavin" );
+ u.getPermissions().add( new Permission( "obnoxiousness" ) );
+ u.getPermissions().add( new Permission( "pigheadedness" ) );
+ s.persist( u );
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ User u2 = ( User ) s.createCriteria( User.class ).uniqueResult();
+ u2.setPermissions( null ); //forces one shot delete
+ s.merge( u );
+ t.commit();
+ s.close();
+
+ u.getPermissions().add( new Permission( "silliness" ) );
+
+ s = openSession();
+ t = s.beginTransaction();
+ s.merge( u );
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ u2 = ( User ) s.createCriteria( User.class ).uniqueResult();
+ assertEquals( u2.getPermissions().size(), 3 );
+ assertEquals( ( ( Permission ) u2.getPermissions().get( 0 ) ).getType(), "obnoxiousness" );
+ assertEquals( ( ( Permission ) u2.getPermissions().get( 2 ) ).getType(), "silliness" );
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ s.delete( u2 );
+ s.flush();
+ t.commit();
+ s.close();
+
+ }
+
+ public void testFetch() {
+ Session s = openSession();
+ Transaction t = s.beginTransaction();
+ User u = new User( "gavin" );
+ u.getPermissions().add( new Permission( "obnoxiousness" ) );
+ u.getPermissions().add( new Permission( "pigheadedness" ) );
+ u.getEmailAddresses().add( new Email( "gavin(a)hibernate.org" ) );
+ u.getEmailAddresses().add( new Email( "gavin.king(a)jboss.com" ) );
+ s.persist( u );
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ User u2 = ( User ) s.createCriteria( User.class ).uniqueResult();
+ assertTrue( Hibernate.isInitialized( u2.getEmailAddresses() ) );
+ assertFalse( Hibernate.isInitialized( u2.getPermissions() ) );
+ assertEquals( u2.getEmailAddresses().size(), 2 );
+ s.delete( u2 );
+ t.commit();
+ s.close();
+ }
+
+ public void testUpdateOrder() {
+ Session s = openSession();
+ Transaction t = s.beginTransaction();
+ User u = new User( "gavin" );
+ u.getSessionData().put( "foo", "foo value" );
+ u.getSessionData().put( "bar", "bar value" );
+ u.getEmailAddresses().add( new Email( "gavin.king(a)jboss.com" ) );
+ u.getEmailAddresses().add( new Email( "gavin(a)hibernate.org" ) );
+ u.getEmailAddresses().add( new Email( "gavin(a)illflow.com" ) );
+ u.getEmailAddresses().add( new Email( "gavin(a)nospam.com" ) );
+ s.persist( u );
+ t.commit();
+ s.close();
+
+ u.getSessionData().clear();
+ u.getSessionData().put( "baz", "baz value" );
+ u.getSessionData().put( "bar", "bar value" );
+ u.getEmailAddresses().remove( 0 );
+ u.getEmailAddresses().remove( 2 );
+
+ s = openSession();
+ t = s.beginTransaction();
+ s.update( u );
+ t.commit();
+ s.close();
+
+ u.getSessionData().clear();
+ u.getEmailAddresses().add( 0, new Email( "gavin(a)nospam.com" ) );
+ u.getEmailAddresses().add( new Email( "gavin.king(a)jboss.com" ) );
+
+ s = openSession();
+ t = s.beginTransaction();
+ s.update( u );
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ s.delete( u );
+ t.commit();
+ s.close();
+
+ }
+
+ public void testValueMap() {
+ Session s = openSession();
+ Transaction t = s.beginTransaction();
+ User u = new User( "gavin" );
+ u.getSessionData().put( "foo", "foo value" );
+ u.getSessionData().put( "bar", null );
+ u.getEmailAddresses().add( null );
+ u.getEmailAddresses().add( new Email( "gavin.king(a)jboss.com" ) );
+ u.getEmailAddresses().add( null );
+ u.getEmailAddresses().add( null );
+ s.persist( u );
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ User u2 = ( User ) s.createCriteria( User.class ).uniqueResult();
+ assertFalse( Hibernate.isInitialized( u2.getSessionData() ) );
+ assertEquals( u2.getSessionData().size(), 1 );
+ assertEquals( u2.getEmailAddresses().size(), 2 );
+ u2.getSessionData().put( "foo", "new foo value" );
+ u2.getEmailAddresses().set( 1, new Email( "gavin(a)hibernate.org" ) );
+ //u2.getEmailAddresses().remove(3);
+ //u2.getEmailAddresses().remove(2);
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ u2 = ( User ) s.createCriteria( User.class ).uniqueResult();
+ assertFalse( Hibernate.isInitialized( u2.getSessionData() ) );
+ assertEquals( u2.getSessionData().size(), 1 );
+ assertEquals( u2.getEmailAddresses().size(), 2 );
+ assertEquals( u2.getSessionData().get( "foo" ), "new foo value" );
+ assertEquals( ( ( Email ) u2.getEmailAddresses().get( 1 ) ).getAddress(), "gavin(a)hibernate.org" );
+ s.delete( u2 );
+ t.commit();
+ s.close();
+ }
+
+
+}
+
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/original/Email.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/original/Email.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/original/Email.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,27 @@
+//$Id: Email.java 5686 2005-02-12 07:27:32Z steveebersole $
+package org.hibernate.test.collection.original;
+
+/**
+ * @author Gavin King
+ */
+public class Email {
+ private String address;
+ Email() {}
+ public String getAddress() {
+ return address;
+ }
+ public void setAddress(String type) {
+ this.address = type;
+ }
+ public Email(String type) {
+ this.address = type;
+ }
+ public boolean equals(Object that) {
+ if ( !(that instanceof Email) ) return false;
+ Email p = (Email) that;
+ return this.address.equals(p.address);
+ }
+ public int hashCode() {
+ return address.hashCode();
+ }
+}
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/original/Permission.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/original/Permission.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/original/Permission.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,27 @@
+//$Id: Permission.java 5686 2005-02-12 07:27:32Z steveebersole $
+package org.hibernate.test.collection.original;
+
+/**
+ * @author Gavin King
+ */
+public class Permission {
+ private String type;
+ Permission() {}
+ public String getType() {
+ return type;
+ }
+ public void setType(String type) {
+ this.type = type;
+ }
+ public Permission(String type) {
+ this.type = type;
+ }
+ public boolean equals(Object that) {
+ if ( !(that instanceof Permission) ) return false;
+ Permission p = (Permission) that;
+ return this.type.equals(p.type);
+ }
+ public int hashCode() {
+ return type.hashCode();
+ }
+}
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/original/User.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/original/User.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/original/User.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,55 @@
+//$Id: User.java 7628 2005-07-24 06:55:01Z oneovthafew $
+package org.hibernate.test.collection.original;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author Gavin King
+ */
+public class User {
+ private String userName;
+ private List permissions = new ArrayList();
+ private List emailAddresses = new ArrayList();
+ private Map sessionData = new HashMap();
+ private Set sessionAttributeNames = new HashSet();
+
+ User() {}
+ public User(String name) {
+ userName = name;
+ }
+ public List getPermissions() {
+ return permissions;
+ }
+ public void setPermissions(List permissions) {
+ this.permissions = permissions;
+ }
+ public String getUserName() {
+ return userName;
+ }
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+ public List getEmailAddresses() {
+ return emailAddresses;
+ }
+ public void setEmailAddresses(List emailAddresses) {
+ this.emailAddresses = emailAddresses;
+ }
+ public Map getSessionData() {
+ return sessionData;
+ }
+ public void setSessionData(Map sessionData) {
+ this.sessionData = sessionData;
+ }
+ public Set getSessionAttributeNames() {
+ return sessionAttributeNames;
+ }
+ public void setSessionAttributeNames(Set sessionAttributeNames) {
+ this.sessionAttributeNames = sessionAttributeNames;
+ }
+}
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/original/UserPermissions.hbm.xml
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/original/UserPermissions.hbm.xml 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/original/UserPermissions.hbm.xml 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,53 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<!--
+
+ This mapping demonstrates how to use a composite
+ element mapping to model a parent/child association.
+
+-->
+
+<hibernate-mapping package="org.hibernate.test.collection.original">
+
+ <import class="Permission"/>
+
+ <class name="User" table="`Users`">
+ <id name="userName"/>
+ <list name="permissions" lazy="extra">
+ <key column="userName"/>
+ <list-index column="displayOrder" base="1"/>
+ <composite-element class="Permission">
+ <property name="type" column="permissionType"/>
+ </composite-element>
+ </list>
+ <list name="emailAddresses" fetch="join">
+ <key column="userName"/>
+ <list-index column="displayOrder" base="1"/>
+ <composite-element class="Email">
+ <property name="address"/>
+ </composite-element>
+ </list>
+ <map name="sessionData"
+ order-by="lower(`attributeName`) asc"
+ lazy="extra">
+ <key column="userName"/>
+ <map-key column="`attributeName`"
+ type="string"/>
+ <element column="`attributeValue`"
+ type="serializable"
+ not-null="true"/>
+ </map>
+ <set name="sessionAttributeNames"
+ lazy="extra"
+ inverse="true">
+ <key column="userName"/>
+ <element column="`attributeName`"
+ type="string"/>
+ </set>
+ </class>
+
+
+</hibernate-mapping>
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/set/PersistentSetTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/set/PersistentSetTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/set/PersistentSetTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,30 +1,30 @@
package org.hibernate.test.collection.set;
-import org.hibernate.test.TestCase;
-import org.hibernate.Session;
-import org.hibernate.collection.PersistentSet;
-
import java.util.HashSet;
import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.Session;
+import org.hibernate.collection.PersistentSet;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+
/**
* todo: describe PersistentSetTest
*
* @author Steve Ebersole
*/
-public class PersistentSetTest extends TestCase {
+public class PersistentSetTest extends FunctionalTestCase {
public PersistentSetTest(String name) {
super( name );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "collection/set/Mappings.hbm.xml" };
}
public static Test suite() {
- return new TestSuite( PersistentSetTest.class );
+ return new FunctionalTestClassTestSuite( PersistentSetTest.class );
}
public void testWriteMethodDirtying() {
@@ -59,7 +59,7 @@
otherSet.add( otherChild );
assertFalse( children.removeAll( otherSet ) );
assertFalse( children.isDirty() );
-
+
assertTrue( children.retainAll( otherSet ));
assertTrue( children.isDirty() );
assertTrue( children.isEmpty() );
@@ -77,5 +77,4 @@
session.getTransaction().commit();
session.close();
}
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/component/ComponentTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/component/ComponentTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/component/ComponentTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,36 +1,74 @@
//$Id$
package org.hibernate.test.component;
+import java.util.ArrayList;
import java.util.Date;
+import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
+import org.hibernate.cfg.Mappings;
import org.hibernate.criterion.Property;
+import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.HSQLDialect;
-import org.hibernate.dialect.Oracle9Dialect;
-import org.hibernate.dialect.PostgreSQLDialect;
-import org.hibernate.dialect.SQLServerDialect;
-import org.hibernate.test.TestCase;
+import org.hibernate.dialect.function.SQLFunction;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.mapping.Component;
+import org.hibernate.mapping.Formula;
+import org.hibernate.mapping.PersistentClass;
/**
* @author Gavin King
*/
-public class ComponentTest extends TestCase {
+public class ComponentTest extends FunctionalTestCase {
public ComponentTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "component/User.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
+ }
+
+ public void afterConfigurationBuilt(Mappings mappings, Dialect dialect) {
+ super.afterConfigurationBuilt( mappings, dialect );
+ // Oracle and Postgres do not have year() functions, so we need to
+ // redefine the 'User.person.yob' formula
+ //
+ // consider temporary until we add the capability to define
+ // mapping foprmulas which can use dialect-registered functions...
+ PersistentClass user = mappings.getClass( User.class.getName() );
+ org.hibernate.mapping.Property personProperty = user.getProperty( "person" );
+ Component component = ( Component ) personProperty.getValue();
+ Formula f = ( Formula ) component.getProperty( "yob" ).getValue().getColumnIterator().next();
+
+ SQLFunction yearFunction = ( SQLFunction ) dialect.getFunctions().get( "year" );
+ if ( yearFunction == null ) {
+ // the dialect not know to support a year() function, so rely on the
+ // ANSI SQL extract function
+ f.setFormula( "extract( year from dob )");
+ }
+ else {
+ List args = new ArrayList();
+ args.add( "dob" );
+ f.setFormula( yearFunction.render( args, null ) );
+ }
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite(ComponentTest.class);
+ }
public void testUpdateFalse() {
-
- if ( getDialect() instanceof PostgreSQLDialect ) return; //postgres got no year() function
- if ( getDialect() instanceof Oracle9Dialect ) return; //oracle got no year() function
-
getSessions().getStatistics().clear();
Session s = openSession();
@@ -57,10 +95,6 @@
}
public void testComponent() {
-
- if ( getDialect() instanceof PostgreSQLDialect ) return; //postgres got no year() function
- if ( getDialect() instanceof Oracle9Dialect ) return; //oracle got no year() function
-
Session s = openSession();
Transaction t = s.beginTransaction();
User u = new User( "gavin", "secret", new Person("Gavin King", new Date(), "Karbarook Ave") );
@@ -92,9 +126,6 @@
}
public void testComponentQueries() {
-// if ( !dialectSupportsRowValueConstructorSyntax() ) {
-// return;
-// }
Session s = openSession();
Transaction t = s.beginTransaction();
Employee emp = new Employee();
@@ -114,17 +145,13 @@
}
public void testComponentFormulaQuery() {
-
- if ( getDialect() instanceof PostgreSQLDialect ) return; //postgres got no year() function
- if ( getDialect() instanceof Oracle9Dialect ) return; //oracle got no year() function
-
Session s = openSession();
Transaction t = s.beginTransaction();
s.createQuery("from User u where u.person.yob = 1999").list();
s.createCriteria(User.class)
.add( Property.forName("person.yob").between( new Integer(1999), new Integer(2002) ) )
.list();
- if ( ! (getDialect() instanceof HSQLDialect) ) {
+ if ( getDialect().supportsRowValueConstructorSyntax() ) {
s.createQuery("from User u where u.person = ('gavin', :dob, 'Peachtree Rd', 'Karbarook Ave', 1974, 'Peachtree Rd')")
.setDate("dob", new Date("March 25, 1974")).list();
s.createQuery("from User where person = ('gavin', :dob, 'Peachtree Rd', 'Karbarook Ave', 1974, 'Peachtree Rd')")
@@ -135,9 +162,6 @@
}
public void testNamedQuery() {
- if ( getDialect() instanceof PostgreSQLDialect ) return; //postgres got no year() function
- if ( getDialect() instanceof Oracle9Dialect ) return; //oracle got no year() function
-
Session s = openSession();
Transaction t = s.beginTransaction();
s.getNamedQuery("userNameIn")
@@ -146,18 +170,6 @@
t.commit();
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "component/User.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(ComponentTest.class);
- }
-
- protected void configure(Configuration cfg) {
- cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/compositeelement/CompositeElementTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/compositeelement/CompositeElementTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/compositeelement/CompositeElementTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,132 +1,90 @@
//$Id$
package org.hibernate.test.compositeelement;
+import java.util.ArrayList;
+
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.HibernateException;
-import org.hibernate.util.XMLHelper;
-import org.hibernate.util.StringHelper;
-import org.hibernate.util.CollectionHelper;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.cfg.HbmBinder;
-import org.hibernate.dialect.SybaseDialect;
-import org.hibernate.dialect.SQLServerDialect;
-import org.hibernate.test.TestCase;
-import org.xml.sax.InputSource;
-import org.dom4j.Element;
+import org.hibernate.cfg.Mappings;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.dialect.function.SQLFunction;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.mapping.Collection;
+import org.hibernate.mapping.Component;
+import org.hibernate.mapping.Formula;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Iterator;
-
/**
* @author Gavin King
*/
-public class CompositeElementTest extends TestCase {
+public class CompositeElementTest extends FunctionalTestCase {
public CompositeElementTest(String str) {
- super(str);
+ super( str );
}
- private boolean hasLengthFunction() {
- // neither support length() as a function, but each has len() which
- // is the same semantic
- return ! ( getDialect() instanceof SybaseDialect || getDialect() instanceof SQLServerDialect );
+ public String[] getMappings() {
+ return new String[] { "compositeelement/Parent.hbm.xml" };
}
- protected String[] getMappings() {
- return hasLengthFunction() ? new String[] { "compositeelement/Parent.hbm.xml" } : new String[0];
- }
+ public void afterConfigurationBuilt(Mappings mappings, Dialect dialect) {
+ super.afterConfigurationBuilt( mappings, dialect );
+ Collection children = mappings.getCollection( Parent.class.getName() + ".children" );
+ Component childComponents = ( Component ) children.getElement();
+ Formula f = ( Formula ) childComponents.getProperty( "bioLength" ).getValue().getColumnIterator().next();
- protected void configure(Configuration cfg) {
- super.configure( cfg );
- if ( !hasLengthFunction() ) {
- try {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- InputStream xmlInputStream = cl.getResourceAsStream( getBaseForMappings() + "compositeelement/Parent.hbm.xml" );
- XMLHelper xmlHelper = new XMLHelper();
- ArrayList errors = new ArrayList();
- org.dom4j.Document doc = xmlHelper.createSAXReader( "XML InputStream", errors, cfg.getEntityResolver() )
- .read( new InputSource( xmlInputStream ) );
-
- Element hmNode = doc.getRootElement();
- Iterator classNodes = hmNode.elementIterator( "class" );
- while ( classNodes.hasNext() ) {
- Element classNode = ( Element ) classNodes.next();
- if ( "Parent".equals( classNode.attributeValue( "name" ) ) ) {
- Iterator sets = classNode.elementIterator( "set" );
- while ( sets.hasNext() ) {
- Element set = ( Element ) sets.next();
- if ( "children".equals( set.attributeValue( "name" ) ) ) {
- Element component = set.element( "composite-element" );
- Iterator componentProperties = component.elementIterator( "property" );
- while ( componentProperties.hasNext() ) {
- Element property = ( Element ) componentProperties.next();
- if ( "bioLength".equals( property.attributeValue( "name" ) ) ) {
- String formula = property.attributeValue( "formula" );
- property.attribute( "formula" ).setValue( StringHelper.replace( formula, "length", "len" ) );
- }
- }
- }
- }
- }
- }
-
- // Whew! ;)
- HbmBinder.bindRoot( doc, cfg.createMappings(), CollectionHelper.EMPTY_MAP );
- }
- catch( Throwable t ) {
- throw new HibernateException( "Grrr" );
- }
+ SQLFunction lengthFunction = ( SQLFunction ) dialect.getFunctions().get( "length" );
+ if ( lengthFunction != null ) {
+ ArrayList args = new ArrayList();
+ args.add( "bio" );
+ f.setFormula( lengthFunction.render( args, null ) );
}
}
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( CompositeElementTest.class );
+ }
+
public void testHandSQL() {
Session s = openSession();
Transaction t = s.beginTransaction();
- Child c = new Child("Child One");
- Parent p = new Parent("Parent");
- p.getChildren().add(c);
- c.setParent(p);
- s.save(p);
+ Child c = new Child( "Child One" );
+ Parent p = new Parent( "Parent" );
+ p.getChildren().add( c );
+ c.setParent( p );
+ s.save( p );
s.flush();
- p.getChildren().remove(c);
- c.setParent(null);
+ p.getChildren().remove( c );
+ c.setParent( null );
s.flush();
- p.getChildren().add(c);
- c.setParent(p);
+ p.getChildren().add( c );
+ c.setParent( p );
t.commit();
s.close();
s = openSession();
t = s.beginTransaction();
- s.createQuery("select distinct p from Parent p join p.children c where c.name like 'Child%'").uniqueResult();
+ s.createQuery( "select distinct p from Parent p join p.children c where c.name like 'Child%'" ).uniqueResult();
s.clear();
- s.createQuery("select new Child(c.name) from Parent p left outer join p.children c where c.name like 'Child%'").uniqueResult();
+ s.createQuery( "select new Child(c.name) from Parent p left outer join p.children c where c.name like 'Child%'" )
+ .uniqueResult();
s.clear();
//s.createQuery("select c from Parent p left outer join p.children c where c.name like 'Child%'").uniqueResult(); //we really need to be able to do this!
s.clear();
- p = (Parent) s.createQuery("from Parent p left join fetch p.children").uniqueResult();
+ p = ( Parent ) s.createQuery( "from Parent p left join fetch p.children" ).uniqueResult();
t.commit();
s.close();
s = openSession();
t = s.beginTransaction();
- s.delete(p);
+ s.delete( p );
t.commit();
s.close();
}
-
-
- public static Test suite() {
- return new TestSuite(CompositeElementTest.class);
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/connections/AggressiveReleaseTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/connections/AggressiveReleaseTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/connections/AggressiveReleaseTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,27 +1,27 @@
// $Id$
package org.hibernate.test.connections;
-import org.hibernate.Session;
+import java.sql.Connection;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import junit.framework.Test;
+
import org.hibernate.ConnectionReleaseMode;
+import org.hibernate.Hibernate;
import org.hibernate.ScrollableResults;
-import org.hibernate.Hibernate;
-import org.hibernate.transaction.CMTTransactionFactory;
+import org.hibernate.Session;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
import org.hibernate.impl.SessionImpl;
-import org.hibernate.util.SerializationHelper;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.test.tm.DummyConnectionProvider;
+import org.hibernate.test.tm.DummyTransactionManager;
import org.hibernate.test.tm.DummyTransactionManagerLookup;
-import org.hibernate.test.tm.DummyTransactionManager;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.cfg.Environment;
+import org.hibernate.transaction.CMTTransactionFactory;
+import org.hibernate.util.SerializationHelper;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import java.sql.Connection;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Iterator;
-
/**
* Implementation of AggressiveReleaseTest.
*
@@ -34,10 +34,10 @@
}
public static Test suite() {
- return new TestSuite( AggressiveReleaseTest.class );
+ return new FunctionalTestClassTestSuite( AggressiveReleaseTest.class );
}
- protected void configure(Configuration cfg) {
+ public void configure(Configuration cfg) {
super.configure( cfg );
cfg.setProperty( Environment.RELEASE_CONNECTIONS, ConnectionReleaseMode.AFTER_STATEMENT.toString() );
cfg.setProperty( Environment.CONNECTION_PROVIDER, DummyConnectionProvider.class.getName() );
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/connections/BasicConnectionProviderTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/connections/BasicConnectionProviderTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/connections/BasicConnectionProviderTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,14 +1,14 @@
// $Id$
package org.hibernate.test.connections;
+import junit.framework.Test;
+
+import org.hibernate.ConnectionReleaseMode;
import org.hibernate.Session;
-import org.hibernate.ConnectionReleaseMode;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
/**
* Implementation of BasicConnectionProviderTest.
*
@@ -21,7 +21,7 @@
}
public static Test suite() {
- return new TestSuite( BasicConnectionProviderTest.class );
+ return new FunctionalTestClassTestSuite( BasicConnectionProviderTest.class );
}
protected Session getSessionUnderTest() {
@@ -32,7 +32,7 @@
session.reconnect();
}
- protected void configure(Configuration cfg) {
+ public void configure(Configuration cfg) {
super.configure( cfg );
cfg.setProperty( Environment.RELEASE_CONNECTIONS, ConnectionReleaseMode.ON_CLOSE.toString() );
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/connections/ConnectionManagementTestCase.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/connections/ConnectionManagementTestCase.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/connections/ConnectionManagementTestCase.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -4,6 +4,7 @@
import org.hibernate.test.TestCase;
import org.hibernate.Session;
import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestCase;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.util.SerializationHelper;
@@ -20,19 +21,16 @@
*
* @author Steve Ebersole
*/
-public abstract class ConnectionManagementTestCase extends TestCase {
+public abstract class ConnectionManagementTestCase extends FunctionalTestCase {
public ConnectionManagementTestCase(String name) {
super( name );
}
- protected final String[] getMappings() {
+ public final String[] getMappings() {
return new String[] { "connections/Silly.hbm.xml" };
}
- protected void configure(Configuration cfg) {
- super.configure( cfg );
- }
// hooks ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/connections/ConnectionsSuite.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/connections/ConnectionsSuite.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/connections/ConnectionsSuite.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -13,10 +13,11 @@
public static Test suite() {
TestSuite suite = new TestSuite( "Connection-management tests");
+ suite.addTest( AggressiveReleaseTest.suite() );
suite.addTest( BasicConnectionProviderTest.suite() );
+ suite.addTest( CurrentSessionConnectionTest.suite() );
suite.addTest( SuppliedConnectionTest.suite() );
- suite.addTest( AggressiveReleaseTest.suite() );
- suite.addTest( CurrentSessionConnectionTest.suite() );
+ suite.addTest( ThreadLocalCurrentSessionTest.suite() );
return suite;
}
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/connections/CurrentSessionConnectionTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/connections/CurrentSessionConnectionTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/connections/CurrentSessionConnectionTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,10 +1,11 @@
// $Id$
package org.hibernate.test.connections;
-import org.hibernate.Session;
import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.Session;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+
/**
* Implementation of CurrentSessionConnectionTest.
*
@@ -17,7 +18,7 @@
}
public static Test suite() {
- return new TestSuite( CurrentSessionConnectionTest.class );
+ return new FunctionalTestClassTestSuite( CurrentSessionConnectionTest.class );
}
protected Session getSessionUnderTest() throws Throwable {
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/connections/SuppliedConnectionTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/connections/SuppliedConnectionTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/connections/SuppliedConnectionTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,21 +1,21 @@
// $Id$
package org.hibernate.test.connections;
+import java.sql.Connection;
+import java.sql.ResultSet;
+
+import junit.framework.Test;
+
+import org.hibernate.ConnectionReleaseMode;
+import org.hibernate.Session;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
-import org.hibernate.ConnectionReleaseMode;
-import org.hibernate.Session;
-import org.hibernate.tool.hbm2ddl.SchemaExport;
import org.hibernate.connection.ConnectionProvider;
import org.hibernate.connection.ConnectionProviderFactory;
import org.hibernate.connection.UserSuppliedConnectionProvider;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.tool.hbm2ddl.SchemaExport;
-import java.sql.Connection;
-import java.sql.ResultSet;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
/**
* Implementation of SuppliedConnectionTest.
*
@@ -31,7 +31,7 @@
}
public static Test suite() {
- return new TestSuite( SuppliedConnectionTest.class );
+ return new FunctionalTestClassTestSuite( SuppliedConnectionTest.class );
}
protected Session getSessionUnderTest() throws Throwable {
@@ -47,7 +47,7 @@
cp.closeConnection( connectionUnderTest );
}
- protected void configure(Configuration cfg) {
+ public void configure(Configuration cfg) {
super.configure( cfg );
cfg.setProperty( Environment.RELEASE_CONNECTIONS, ConnectionReleaseMode.ON_CLOSE.toString() );
cfg.setProperty( Environment.CONNECTION_PROVIDER, UserSuppliedConnectionProvider.class.getName() );
@@ -69,8 +69,8 @@
return false;
}
- protected void setUp() throws Exception {
- super.setUp();
+ protected void prepareTest() throws Exception {
+ super.prepareTest();
Connection conn = cp.getConnection();
try {
new SchemaExport( getCfg(), conn ).create( false, true );
@@ -86,7 +86,7 @@
}
}
- protected void tearDown() throws Exception {
+ protected void cleanupTest() throws Exception {
Connection conn = cp.getConnection();
try {
new SchemaExport( getCfg(), conn ).drop( false, true );
@@ -105,6 +105,6 @@
}
catch( Throwable ignore ) {
}
- super.tearDown();
+ super.cleanupTest();
}
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/connections/ThreadLocalCurrentSessionTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/connections/ThreadLocalCurrentSessionTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/connections/ThreadLocalCurrentSessionTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,14 +1,17 @@
package org.hibernate.test.connections;
+import junit.framework.Test;
+
+import org.hibernate.HibernateException;
import org.hibernate.Session;
-import org.hibernate.HibernateException;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.context.ThreadLocalSessionContext;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
+import org.hibernate.context.ThreadLocalSessionContext;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
- * @author <a href="mailto:steve@hibernate.org">Steve Ebersole </a>
+ * @author Steve Ebersole
*/
public class ThreadLocalCurrentSessionTest extends ConnectionManagementTestCase {
@@ -16,7 +19,11 @@
super( name );
}
- protected void configure(Configuration cfg) {
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( ThreadLocalCurrentSessionTest.class );
+ }
+
+ public void configure(Configuration cfg) {
super.configure( cfg );
cfg.setProperty( Environment.CURRENT_SESSION_CONTEXT_CLASS, TestableThreadLocalContext.class.getName() );
cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
@@ -56,7 +63,7 @@
session.createQuery( "from Silly" );
fail( "method other than beginTransaction{} allowed" );
}
- catch( HibernateException e ) {
+ catch ( HibernateException e ) {
// ok
}
}
@@ -77,14 +84,17 @@
public static class TestableThreadLocalContext extends ThreadLocalSessionContext {
private static TestableThreadLocalContext me;
+
public TestableThreadLocalContext(SessionFactoryImplementor factory) {
super( factory );
me = this;
}
+
public static boolean isSessionBound(Session session) {
return sessionMap() != null && sessionMap().containsKey( me.factory )
&& sessionMap().get( me.factory ) == session;
}
+
public static boolean hasBind() {
return sessionMap() != null && sessionMap().containsKey( me.factory );
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/criteria/CriteriaQueryTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/criteria/CriteriaQueryTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/criteria/CriteriaQueryTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -5,7 +5,6 @@
import java.util.Map;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Criteria;
import org.hibernate.FetchMode;
@@ -16,6 +15,7 @@
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.criterion.DetachedCriteria;
+import org.hibernate.criterion.Example;
import org.hibernate.criterion.Expression;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Order;
@@ -24,8 +24,8 @@
import org.hibernate.criterion.Property;
import org.hibernate.criterion.Restrictions;
import org.hibernate.criterion.Subqueries;
-import org.hibernate.criterion.Example;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.test.hql.Animal;
import org.hibernate.test.hql.Reptile;
import org.hibernate.transform.Transformers;
@@ -35,12 +35,28 @@
/**
* @author Gavin King
*/
-public class CriteriaQueryTest extends TestCase {
+public class CriteriaQueryTest extends FunctionalTestCase {
public CriteriaQueryTest(String str) {
super(str);
}
+ public String[] getMappings() {
+ return new String[] { "criteria/Enrolment.hbm.xml", "hql/Animal.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ super.configure( cfg );
+ cfg.setProperty( Environment.USE_QUERY_CACHE, "true" );
+ cfg.setProperty( Environment.CACHE_REGION_PREFIX, "criteriaquerytest" );
+ cfg.setProperty( Environment.USE_SECOND_LEVEL_CACHE, "true" );
+ cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( CriteriaQueryTest.class );
+ }
+
public void testEscapeCharacter() {
Session session = openSession();
Transaction t = session.beginTransaction();
@@ -780,21 +796,5 @@
t.commit();
session.close();
}
-
- protected String[] getMappings() {
- return new String[] { "criteria/Enrolment.hbm.xml", "hql/Animal.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(CriteriaQueryTest.class);
- }
-
- protected void configure(Configuration cfg) {
- super.configure( cfg );
- cfg.setProperty( Environment.USE_QUERY_CACHE, "true" );
- cfg.setProperty( Environment.CACHE_REGION_PREFIX, "criteriaquerytest" );
- cfg.setProperty( Environment.USE_SECOND_LEVEL_CACHE, "true" );
- cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
- }
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cuk/CompositePropertyRefTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cuk/CompositePropertyRefTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cuk/CompositePropertyRefTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -5,23 +5,35 @@
import java.util.Set;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class CompositePropertyRefTest extends TestCase {
+public class CompositePropertyRefTest extends FunctionalTestCase {
public CompositePropertyRefTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "cuk/Person.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty(Environment.DEFAULT_BATCH_FETCH_SIZE, "1");
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( CompositePropertyRefTest.class );
+ }
public void testOneToOnePropertyRef() {
Session s = openSession();
@@ -101,24 +113,12 @@
l = s.createQuery("from Person p left join fetch p.address").list();
s.clear();
- ((org.hibernate.classic.Session)s).delete( "from Address" );
- ((org.hibernate.classic.Session)s).delete( "from Person" );
- ((org.hibernate.classic.Session)s).delete( "from Account" );
+ s.createQuery( "delete Address" ).executeUpdate();
+ s.createQuery( "delete Account" ).executeUpdate();
+ s.createQuery( "delete Person" ).executeUpdate();
t.commit();
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "cuk/Person.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(CompositePropertyRefTest.class);
- }
-
- protected void configure(Configuration cfg) {
- cfg.setProperty(Environment.DEFAULT_BATCH_FETCH_SIZE, "1");
- }
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cuk/Person.hbm.xml
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cuk/Person.hbm.xml 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cuk/Person.hbm.xml 2006-12-12 23:22:26 UTC (rev 10976)
@@ -20,29 +20,19 @@
<hibernate-mapping package="org.hibernate.test.cuk">
<class name="Person">
-
<id name="id">
<generator class="hilo"/>
</id>
-
<property name="name" length="100"/>
-
- <one-to-one name="address"
- property-ref="person"
- cascade="all"
- fetch="join"/>
-
- <set name="accounts"
- inverse="true">
- <key property-ref="userIdAndDeleted">
+ <one-to-one name="address" property-ref="person" cascade="all" fetch="join"/>
+ <set name="accounts" inverse="true">
+ <key property-ref="userIdAndDeleted">
<column name="userId"/>
<column name="userDeleted"/>
</key>
<one-to-many class="Account"/>
</set>
-
- <properties name="userIdAndDeleted"
- update="false">
+ <properties name="userIdAndDeleted" update="false" unique="true">
<property name="userId" length="8"/>
<property name="deleted"/>
</properties>
@@ -50,32 +40,24 @@
</class>
<class name="Address">
-
- <id name="id">
+ <id name="id">
<generator class="hilo"/>
</id>
-
<property name="address" length="300"/>
<property name="zip" length="5"/>
<property name="country" length="25"/>
<many-to-one name="person" unique="true" not-null="true"/>
-
</class>
<class name="Account">
-
<id name="accountId" length="32">
<generator class="uuid.hex"/>
</id>
-
- <many-to-one name="user"
- property-ref="userIdAndDeleted">
+ <many-to-one name="user" property-ref="userIdAndDeleted">
<column name="userId"/>
<column name="userDeleted"/>
</many-to-one>
-
<property name="type" not-null="true"/>
-
</class>
</hibernate-mapping>
\ No newline at end of file
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cut/CompositeUserTypeTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cut/CompositeUserTypeTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cut/CompositeUserTypeTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -6,21 +6,29 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Session;
import org.hibernate.dialect.HSQLDialect;
import org.hibernate.dialect.Oracle9Dialect;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class CompositeUserTypeTest extends TestCase {
+public class CompositeUserTypeTest extends FunctionalTestCase {
public CompositeUserTypeTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "cut/types.hbm.xml", "cut/Transaction.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( CompositeUserTypeTest.class );
+ }
public void testCompositeUserType() {
Session s = openSession();
@@ -51,14 +59,5 @@
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "cut/types.hbm.xml", "cut/Transaction.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(CompositeUserTypeTest.class);
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/deletetransient/DeleteTransientEntityTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/deletetransient/DeleteTransientEntityTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/deletetransient/DeleteTransientEntityTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,23 +1,30 @@
package org.hibernate.test.deletetransient;
-import org.hibernate.test.TestCase;
+import junit.framework.Test;
+
import org.hibernate.Session;
import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* todo: describe DeleteTransientEntityTest
*
* @author Steve Ebersole
*/
-public class DeleteTransientEntityTest extends TestCase {
+public class DeleteTransientEntityTest extends FunctionalTestCase {
public DeleteTransientEntityTest(String name) {
super( name );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "deletetransient/Person.hbm.xml" };
}
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( DeleteTransientEntityTest.class );
+ }
+
public void testTransientEntityDeletionNoCascades() {
Session s = openSession();
Transaction t = s.beginTransaction();
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/dialect/cache/SQLFunctionsInterSystemsTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/dialect/cache/SQLFunctionsInterSystemsTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/dialect/cache/SQLFunctionsInterSystemsTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -22,6 +22,7 @@
import org.hibernate.Transaction;
import org.hibernate.classic.Session;
import org.hibernate.dialect.Cache71Dialect;
+import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.HSQLDialect;
import org.hibernate.dialect.InterbaseDialect;
import org.hibernate.dialect.MckoiDialect;
@@ -29,21 +30,21 @@
import org.hibernate.dialect.Oracle9Dialect;
import org.hibernate.dialect.SybaseDialect;
import org.hibernate.dialect.TimesTenDialect;
-import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.function.SQLFunction;
-import org.hibernate.test.DatabaseSpecificTestCase;
+import org.hibernate.junit.functional.DatabaseSpecificFunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.test.legacy.Blobber;
+import org.hibernate.test.legacy.Broken;
+import org.hibernate.test.legacy.Fixed;
import org.hibernate.test.legacy.Simple;
import org.hibernate.test.legacy.Single;
-import org.hibernate.test.legacy.Broken;
-import org.hibernate.test.legacy.Fixed;
-import org.hibernate.test.legacy.Blobber;
/**
* Tests for function support on CacheSQL...
*
* @author Jonathan Levinson
*/
-public class SQLFunctionsInterSystemsTest extends DatabaseSpecificTestCase {
+public class SQLFunctionsInterSystemsTest extends DatabaseSpecificFunctionalTestCase {
private static final Log log = LogFactory.getLog(SQLFunctionsInterSystemsTest.class);
@@ -61,10 +62,9 @@
}
public static Test suite() {
- return new TestSuite(SQLFunctionsInterSystemsTest.class);
+ return new FunctionalTestClassTestSuite( SQLFunctionsInterSystemsTest.class );
}
-
public boolean appliesTo(Dialect dialect) {
// all these test case apply only to testing InterSystems' CacheSQL dialect
return dialect instanceof Cache71Dialect;
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/discriminator/DiscriminatorTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/discriminator/DiscriminatorTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/discriminator/DiscriminatorTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,28 +1,36 @@
//$Id$
package org.hibernate.test.discriminator;
+import java.math.BigDecimal;
import java.util.Iterator;
import java.util.List;
-import java.math.BigDecimal;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.criterion.Property;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class DiscriminatorTest extends TestCase {
-
+public class DiscriminatorTest extends FunctionalTestCase {
+
public DiscriminatorTest(String str) {
super(str);
}
+ public String[] getMappings() {
+ return new String[] { "discriminator/Person.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( DiscriminatorTest.class );
+ }
+
public void testDiscriminatorSubclass() {
Session s = openSession();
Transaction t = s.beginTransaction();
@@ -163,14 +171,6 @@
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "discriminator/Person.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(DiscriminatorTest.class);
- }
-
}
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/dynamicentity/DynamicEntitySuite.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/dynamicentity/DynamicEntitySuite.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/dynamicentity/DynamicEntitySuite.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,21 @@
+package org.hibernate.test.dynamicentity;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.hibernate.test.dynamicentity.interceptor.InterceptorDynamicEntityTest;
+import org.hibernate.test.dynamicentity.tuplizer.TuplizerDynamicEntityTest;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class DynamicEntitySuite {
+ public static Test suite() {
+ TestSuite suite = new TestSuite( "dynamic entity suite" );
+ suite.addTest( InterceptorDynamicEntityTest.suite() );
+ suite.addTest( TuplizerDynamicEntityTest.suite() );
+ return suite;
+ }
+}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/dynamicentity/interceptor/InterceptorDynamicEntityTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/dynamicentity/interceptor/InterceptorDynamicEntityTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/dynamicentity/interceptor/InterceptorDynamicEntityTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,13 +1,15 @@
package org.hibernate.test.dynamicentity.interceptor;
-import org.hibernate.test.TestCase;
+import junit.framework.TestSuite;
+
+import org.hibernate.Hibernate;
+import org.hibernate.Session;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.test.dynamicentity.Company;
import org.hibernate.test.dynamicentity.Customer;
-import org.hibernate.test.dynamicentity.Company;
import org.hibernate.test.dynamicentity.ProxyHelper;
-import org.hibernate.Session;
-import org.hibernate.Hibernate;
-import org.hibernate.cfg.Configuration;
-import junit.framework.TestSuite;
/**
* Demonstrates custom interpretation of entity-name through
@@ -25,21 +27,21 @@
*
* @author Steve Ebersole
*/
-public class InterceptorDynamicEntityTest extends TestCase {
+public class InterceptorDynamicEntityTest extends FunctionalTestCase {
public InterceptorDynamicEntityTest(String x) {
super( x );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "dynamicentity/interceptor/Customer.hbm.xml" };
}
- public static TestSuite suite() {
- return new TestSuite( InterceptorDynamicEntityTest.class );
+ public void configure(Configuration cfg) {
+ cfg.setInterceptor( new ProxyInterceptor() );
}
- protected void configure(Configuration cfg) {
- cfg.setInterceptor( new ProxyInterceptor() );
+ public static TestSuite suite() {
+ return new FunctionalTestClassTestSuite( InterceptorDynamicEntityTest.class );
}
public void testIt() {
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/dynamicentity/tuplizer/TuplizerDynamicEntityTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/dynamicentity/tuplizer/TuplizerDynamicEntityTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/dynamicentity/tuplizer/TuplizerDynamicEntityTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -8,6 +8,10 @@
import org.hibernate.test.dynamicentity.Person;
import org.hibernate.Session;
import org.hibernate.Hibernate;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+
import junit.framework.TestSuite;
import java.util.HashSet;
@@ -21,24 +25,29 @@
* allow us to not have to explicitly supply the appropriate entity
* name to the Session calls.
*
- * @author <a href="mailto:steve@hibernate.org">Steve Ebersole </a>
+ * @author Steve Ebersole
*/
-public class TuplizerDynamicEntityTest extends TestCase {
+public class TuplizerDynamicEntityTest extends FunctionalTestCase {
public TuplizerDynamicEntityTest(String x) {
super( x );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "dynamicentity/tuplizer/Customer.hbm.xml" };
}
+ public void configure(Configuration cfg) {
+ super.configure( cfg );
+ cfg.setInterceptor( new EntityNameInterceptor() );
+ }
+
public static TestSuite suite() {
- return new TestSuite( TuplizerDynamicEntityTest.class );
+ return new FunctionalTestClassTestSuite( TuplizerDynamicEntityTest.class );
}
public void testIt() {
// Test saving these dyna-proxies
- Session session = openSession( new EntityNameInterceptor() );
+ Session session = openSession();
session.beginTransaction();
Company company = ProxyHelper.newCompanyProxy();
company.setName( "acme" );
@@ -69,7 +78,7 @@
assertNotNull( "wife:Person id not assigned", wife.getId() );
// Test loading these dyna-proxies, along with flush processing
- session = openSession( new EntityNameInterceptor() );
+ session = openSession();
session.beginTransaction();
customer = ( Customer ) session.load( Customer.class, customer.getId() );
assertFalse( "should-be-proxy was initialized", Hibernate.isInitialized( customer ) );
@@ -87,7 +96,7 @@
// Test detached entity re-attachment with these dyna-proxies
customer.setName( "Steve" );
- session = openSession( new EntityNameInterceptor() );
+ session = openSession();
session.beginTransaction();
session.update( customer );
session.flush();
@@ -97,7 +106,7 @@
session.close();
// Test querying
- session = openSession( new EntityNameInterceptor() );
+ session = openSession();
session.beginTransaction();
int count = session.createQuery( "from Customer" ).list().size();
assertEquals( "querying dynamic entity", 1, count );
@@ -108,7 +117,7 @@
session.close();
// test deleteing
- session = openSession( new EntityNameInterceptor() );
+ session = openSession();
session.beginTransaction();
session.delete( company );
session.delete( customer );
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ecid/EmbeddedCompositeIdTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ecid/EmbeddedCompositeIdTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ecid/EmbeddedCompositeIdTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -4,22 +4,30 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.proxy.HibernateProxy;
-import org.hibernate.test.TestCase;
/**
* @author Gavin King
*/
-public class EmbeddedCompositeIdTest extends TestCase {
+public class EmbeddedCompositeIdTest extends FunctionalTestCase {
public EmbeddedCompositeIdTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "ecid/Course.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( EmbeddedCompositeIdTest.class );
+ }
public void testMerge() {
Session s = openSession();
@@ -150,14 +158,5 @@
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "ecid/Course.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(EmbeddedCompositeIdTest.class);
- }
-
}
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/EntityModeSuite.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/EntityModeSuite.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/EntityModeSuite.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,23 @@
+package org.hibernate.test.entitymode;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.hibernate.test.entitymode.dom4j.Dom4jSuite;
+import org.hibernate.test.entitymode.map.MapSuite;
+import org.hibernate.test.entitymode.multi.MultiRepresentationTest;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class EntityModeSuite {
+ public static Test suite() {
+ TestSuite suite = new TestSuite( "entity-mode tests" );
+ suite.addTest( Dom4jSuite.suite() );
+ suite.addTest( MapSuite.suite() );
+ suite.addTest( MultiRepresentationTest.suite() );
+ return suite;
+ }
+}
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/Dom4jSuite.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/Dom4jSuite.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/Dom4jSuite.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,23 @@
+package org.hibernate.test.entitymode.dom4j;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.hibernate.test.entitymode.dom4j.accessors.Dom4jAccessorTest;
+import org.hibernate.test.entitymode.dom4j.basic.Dom4jTest;
+import org.hibernate.test.entitymode.dom4j.many2one.Dom4jManyToOneTest;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class Dom4jSuite {
+ public static Test suite() {
+ TestSuite suite = new TestSuite( "dom4j entity-mode suite" );
+ suite.addTest( Dom4jAccessorTest.suite() );
+ suite.addTest( Dom4jTest.suite() );
+ suite.addTest( Dom4jManyToOneTest.suite() );
+ return suite;
+ }
+}
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/accessors/Dom4jAccessorTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/accessors/Dom4jAccessorTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/accessors/Dom4jAccessorTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,157 @@
+// $Id: Dom4jAccessorTest.java 5821 2005-02-21 05:35:11Z oneovthafew $
+package org.hibernate.test.entitymode.dom4j.accessors;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import org.dom4j.DocumentFactory;
+import org.dom4j.Element;
+import org.dom4j.util.NodeComparator;
+
+import org.hibernate.EntityMode;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.mapping.Property;
+import org.hibernate.mapping.SimpleValue;
+import org.hibernate.property.Getter;
+import org.hibernate.property.PropertyAccessorFactory;
+import org.hibernate.property.Setter;
+
+/**
+ * Unit test of dom4j-based accessors
+ *
+ * @author Steve Ebersole
+ */
+public class Dom4jAccessorTest extends TestCase {
+
+ public static final Element DOM = generateTestElement();
+
+ public Dom4jAccessorTest(String name) {
+ super( name );
+ }
+
+ public void testStringElementExtraction() throws Throwable {
+ Property property = generateNameProperty();
+ Getter getter = PropertyAccessorFactory.getPropertyAccessor( property, EntityMode.DOM4J )
+ .getGetter( null, null );
+ String name = ( String ) getter.get( DOM );
+ assertEquals( "Not equals", "JBoss", name );
+ }
+
+ public void testStringTextExtraction() throws Throwable {
+ Property property = generateTextProperty();
+ Getter getter = PropertyAccessorFactory.getPropertyAccessor( property, EntityMode.DOM4J )
+ .getGetter( null, null );
+ String name = ( String ) getter.get( DOM );
+ assertEquals( "Not equals", "description...", name );
+ }
+
+ public void testLongAttributeExtraction() throws Throwable {
+ Property property = generateIdProperty();
+ Getter getter = PropertyAccessorFactory.getPropertyAccessor( property, EntityMode.DOM4J )
+ .getGetter( null, null );
+ Long id = ( Long ) getter.get( DOM );
+ assertEquals( "Not equals", new Long( 123 ), id );
+ }
+
+ public void testLongElementAttributeExtraction() throws Throwable {
+ Property property = generateAccountIdProperty();
+ Getter getter = PropertyAccessorFactory.getPropertyAccessor( property, EntityMode.DOM4J )
+ .getGetter( null, null );
+ Long id = ( Long ) getter.get( DOM );
+ assertEquals( "Not equals", new Long( 456 ), id );
+ }
+
+ public void testCompanyElementGeneration() throws Throwable {
+ Setter idSetter = PropertyAccessorFactory.getPropertyAccessor( generateIdProperty(), EntityMode.DOM4J )
+ .getSetter( null, null );
+ Setter nameSetter = PropertyAccessorFactory.getPropertyAccessor( generateNameProperty(), EntityMode.DOM4J )
+ .getSetter( null, null );
+ Setter textSetter = PropertyAccessorFactory.getPropertyAccessor( generateTextProperty(), EntityMode.DOM4J )
+ .getSetter( null, null );
+ Setter accountIdSetter = PropertyAccessorFactory.getPropertyAccessor(
+ generateAccountIdProperty(), EntityMode.DOM4J
+ )
+ .getSetter( null, null );
+
+ Element root = generateRootTestElement();
+
+ idSetter.set( root, new Long( 123 ), getSFI() );
+ textSetter.set( root, "description...", getSFI() );
+ nameSetter.set( root, "JBoss", getSFI() );
+ accountIdSetter.set( root, new Long( 456 ), getSFI() );
+
+ assertTrue( "DOMs not equal", new NodeComparator().compare( DOM, root ) == 0 );
+ }
+
+ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ private static Element generateTestElement() {
+ Element company = generateRootTestElement();
+ company.addAttribute( "id", "123" );
+ company.setText( "description..." );
+ company.addElement( "name" ).setText( "JBoss" );
+ company.addElement( "account" ).addAttribute( "num", "456" );
+
+ return company;
+ }
+
+ private static Element generateRootTestElement() {
+ return DocumentFactory.getInstance().createElement( "company" );
+ }
+
+ public static Test suite() {
+ return new TestSuite( Dom4jAccessorTest.class );
+ }
+
+ private SessionFactoryImplementor getSFI() {
+ return null;
+ }
+
+ private Property generateIdProperty() {
+ SimpleValue value = new SimpleValue();
+ value.setTypeName( "long" );
+
+ Property property = new Property();
+ property.setName( "id" );
+ property.setNodeName( "@id" );
+ property.setValue( value );
+
+ return property;
+ }
+
+ private Property generateTextProperty() {
+ SimpleValue value = new SimpleValue();
+ value.setTypeName( "string" );
+
+ Property property = new Property();
+ property.setName( "text" );
+ property.setNodeName( "." );
+ property.setValue( value );
+
+ return property;
+ }
+
+ private Property generateAccountIdProperty() {
+ SimpleValue value = new SimpleValue();
+ value.setTypeName( "long" );
+
+ Property property = new Property();
+ property.setName( "number" );
+ property.setNodeName( "account/@num" );
+ property.setValue( value );
+
+ return property;
+ }
+
+ private Property generateNameProperty() {
+ SimpleValue value = new SimpleValue();
+ value.setTypeName( "string" );
+
+ Property property = new Property();
+ property.setName( "name" );
+ property.setNodeName( "name" );
+ property.setValue( value );
+
+ return property;
+ }
+}
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/basic/AB.hbm.xml
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/basic/AB.hbm.xml 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/basic/AB.hbm.xml 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping >
+
+ <class entity-name="A" table="AX" node="a">
+ <id name="aId" type="int" column="aId" node="@id"/>
+ <property name="x" type="string"/>
+ <set name="bs" node="." embed-xml="true" cascade="all" inverse="true">
+ <key column="aId"/>
+ <one-to-many class="B"/>
+ </set>
+ </class>
+
+
+ <class entity-name="B" table="BX" node="b">
+ <composite-id>
+ <key-property name="bId" column="bId" type="int" node="@bId"/>
+ <key-property name="aId" column="aId" type="int" node="@aId"/>
+ </composite-id>
+ <property name="y" type="string" node="."/>
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/basic/Account.hbm.xml
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/basic/Account.hbm.xml 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/basic/Account.hbm.xml 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,51 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping>
+
+ <class entity-name="Customer" node="customer">
+ <id name="customerId" type="string" node="@id"/>
+ <component name="name">
+ <property name="first" type="string"/>
+ <property name="last" type="string"/>
+ </component>
+ <property name="address" type="string" node="address"/>
+ <map name="stuff">
+ <key column="customerId"/>
+ <map-key type="string" column="bar" node="@bar"/>
+ <element type="string" node="foo" column="foo"/>
+ </map>
+ <bag name="morestuff" node=".">
+ <key column="customerId"/>
+ <element type="integer" node="amount" column="amount"/>
+ </bag>
+ <list name="accounts" cascade="all">
+ <key column="customerId2"/>
+ <list-index column="acctno" base="1"/>
+ <one-to-many entity-name="Account" node="account"/>
+ </list>
+ <many-to-one name="location" node="location/@id" entity-name="Location" embed-xml="false"/>
+ <property name="description" node="." type="string"/>
+ <set name="unembedded" embed-xml="false">
+ <key column="x"/>
+ <element type="string" column="y" not-null="true"/>
+ </set>
+ </class>
+
+ <class entity-name="Account" node="account">
+ <id name="accountId" type="string" node="@id"/>
+ <many-to-one name="customer" column="customerId" entity-name="Customer" cascade="all" embed-xml="true" />
+ <!--not-null="true"-->
+ <property name="balance" type="big_decimal" node="balance" precision="10" scale="0" />
+ </class>
+
+ <class entity-name="Location" node="location">
+ <id name="id" node="@id" type="long">
+ <generator class="increment"/>
+ </id>
+ <property name="address" type="string"/>
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/basic/Dom4jTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/basic/Dom4jTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/basic/Dom4jTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,360 @@
+// $Id: Dom4jTest.java 9914 2006-05-09 04:37:18 -0500 (Tue, 09 May 2006) max.andersen(a)jboss.com $
+package org.hibernate.test.entitymode.dom4j.basic;
+
+import java.util.Map;
+
+import junit.framework.Test;
+import org.dom4j.DocumentFactory;
+import org.dom4j.Element;
+
+import org.hibernate.EntityMode;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
+import org.hibernate.criterion.Example;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.transform.Transformers;
+import org.hibernate.util.XMLHelper;
+
+/**
+ * @author Gavin King
+ */
+public class Dom4jTest extends FunctionalTestCase {
+
+ public Dom4jTest(String str) {
+ super( str );
+ }
+
+ public String[] getMappings() {
+ return new String[] {
+ "entitymode/dom4j/basic/Account.hbm.xml",
+ "entitymode/dom4j/basic/AB.hbm.xml",
+ "entitymode/dom4j/basic/Employer.hbm.xml"
+ };
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty( Environment.DEFAULT_ENTITY_MODE, EntityMode.DOM4J.toString() );
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( Dom4jTest.class );
+ }
+
+// TODO : still need to figure out inheritence support within the DOM4J entity-mode
+//
+// public void testSubtyping() throws Exception {
+// Element employer = DocumentFactory.getInstance().createElement( "employer" );
+// employer.addAttribute( "name", "JBoss" );
+// Element gavin = employer.addElement( "techie" );
+// gavin.addAttribute( "name", "Gavin" );
+// Element ben = employer.addElement( "sales-dude" );
+// ben.addAttribute( "name", "Ben" );
+// print( employer );
+//
+// Session s = openSession();
+// Transaction t = s.beginTransaction();
+// s.persist( "Employer", employer );
+// Long eid = new Long( employer.attributeValue( "id" ) );
+// t.commit();
+// s.close();
+//
+// s = openSession();
+// t = s.beginTransaction();
+// employer = (Element) s.get( "Employer", eid );
+// print( employer );
+// s.delete( "Employer", employer );
+// t.commit();
+// s.close();
+//
+// Element dept = DocumentFactory.getInstance().createElement( "department" );
+// dept.addAttribute( "name", "engineering" );
+// Element steve = dept.addElement( "manager" ).addElement( "techie" );
+// steve.addAttribute( "name", "Steve" );
+// print( dept );
+//
+// s = openSession();
+// t = s.beginTransaction();
+// s.persist( "Department", dept );
+// Long did = new Long( dept.attributeValue( "id" ) );
+// t.commit();
+// s.close();
+//
+// s = openSession();
+// t = s.beginTransaction();
+// dept = ( Element ) s.load( "Department", did );
+// print( dept );
+// s.delete( "Department", dept );
+// t.commit();
+// s.close();
+// }
+
+ public void testCompositeId() throws Exception {
+ Element a = DocumentFactory.getInstance().createElement( "a" );
+ a.addAttribute("id", "1");
+ a.addElement("x").setText("foo bar");
+ //Element bs = a.addElement("bs");
+ Element b = a.addElement("b");
+ //b.addElement("bId").setText("1");
+ //b.addElement("aId").setText("1");
+ b.addAttribute("bId", "1");
+ b.addAttribute("aId", "1");
+ b.setText("foo foo");
+ b = a.addElement("b");
+ //b.addElement("bId").setText("2");
+ //b.addElement("aId").setText("1");
+ b.addAttribute("bId", "2");
+ b.addAttribute("aId", "1");
+ b.setText("bar bar");
+
+ Session s = openSession();
+ Transaction t = s.beginTransaction();
+ s.persist("A", a);
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ a = (Element) s.createCriteria("A").uniqueResult();
+ assertEquals( a.elements("b").size(), 2 );
+ print(a);
+ s.delete("A", a);
+ t.commit();
+ s.close();
+ }
+
+ public void testDom4j() throws Exception {
+ Element acct = DocumentFactory.getInstance().createElement( "account" );
+ acct.addAttribute( "id", "abc123" );
+ acct.addElement( "balance" ).setText( "123.45" );
+ Element cust = acct.addElement( "customer" );
+ cust.addAttribute( "id", "xyz123" );
+ Element foo1 = cust.addElement( "stuff" ).addElement( "foo" );
+ foo1.setText( "foo" );
+ foo1.addAttribute("bar", "x");
+ Element foo2 = cust.element( "stuff" ).addElement( "foo" );
+ foo2.setText( "bar" );
+ foo2.addAttribute("bar", "y");
+ cust.addElement( "amount" ).setText( "45" );
+ cust.setText( "An example customer" );
+ Element name = cust.addElement( "name" );
+ name.addElement( "first" ).setText( "Gavin" );
+ name.addElement( "last" ).setText( "King" );
+
+ Element loc = DocumentFactory.getInstance().createElement( "location" );
+ loc.addElement( "address" ).setText( "Karbarook Avenue" );
+
+ print( acct );
+
+ Session s = openSession();
+ Transaction t = s.beginTransaction();
+ s.persist( "Location", loc );
+ cust.addElement( "location" ).addAttribute( "id", loc.attributeValue( "id" ) );
+ s.persist( "Account", acct );
+ t.commit();
+ s.close();
+
+ print( loc );
+
+ s = openSession();
+ t = s.beginTransaction();
+ cust = (Element) s.get( "Customer", "xyz123" );
+ print( cust );
+ acct = (Element) s.get( "Account", "abc123" );
+ print( acct );
+ assertEquals( acct.element( "customer" ), cust );
+ cust.element( "name" ).element( "first" ).setText( "Gavin A" );
+ Element foo3 = cust.element("stuff").addElement("foo");
+ foo3.setText("baz");
+ foo3.addAttribute("bar", "z");
+ cust.element("amount").setText("3");
+ cust.addElement("amount").setText("56");
+ t.commit();
+ s.close();
+
+ System.out.println();
+
+ acct.element( "balance" ).setText( "3456.12" );
+ cust.addElement( "address" ).setText( "Karbarook Ave" );
+
+ assertEquals( acct.element( "customer" ), cust );
+
+ cust.setText( "Still the same example!" );
+
+ s = openSession();
+ t = s.beginTransaction();
+ s.saveOrUpdate( "Account", acct );
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ cust = (Element) s.get( "Customer", "xyz123" );
+ print( cust );
+ acct = (Element) s.get( "Account", "abc123" );
+ print( acct );
+ assertEquals( acct.element( "customer" ), cust );
+ t.commit();
+ s.close();
+
+ System.out.println();
+
+ s = openSession();
+ t = s.beginTransaction();
+ cust = (Element) s.createCriteria( "Customer" )
+ .add( Example.create( cust ) )
+ .uniqueResult();
+ print( cust );
+ t.commit();
+ s.close();
+
+ System.out.println();
+
+ s = openSession();
+ t = s.beginTransaction();
+ acct = (Element) s.createQuery( "from Account a left join fetch a.customer" )
+ .uniqueResult();
+ print( acct );
+ t.commit();
+ s.close();
+
+ System.out.println();
+
+ s = openSession();
+ t = s.beginTransaction();
+ Map m = (Map) s.createQuery( "select a as acc from Account a left join fetch a.customer" )
+ .setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP).uniqueResult();
+ acct = (Element)m.get("acc");
+ print( acct );
+ t.commit();
+ s.close();
+
+ System.out.println();
+
+ s = openSession();
+ t = s.beginTransaction();
+ acct = (Element) s.createQuery( "from Account" ).uniqueResult();
+ print( acct );
+ t.commit();
+ s.close();
+
+ System.out.println();
+
+ s = openSession();
+ t = s.beginTransaction();
+ cust = (Element) s.createQuery( "from Customer c left join fetch c.stuff" ).uniqueResult();
+ print( cust );
+ t.commit();
+ s.close();
+
+ System.out.println();
+
+ s = openSession();
+ t = s.beginTransaction();
+ cust = (Element) s.createQuery( "from Customer c left join fetch c.morestuff" ).uniqueResult();
+ print( cust );
+ t.commit();
+ s.close();
+
+ System.out.println();
+
+ s = openSession();
+ t = s.beginTransaction();
+ cust = (Element) s.createQuery( "from Customer c left join fetch c.morestuff" ).uniqueResult();
+ print( cust );
+ cust = (Element) s.createQuery( "from Customer c left join fetch c.stuff" ).uniqueResult();
+ print( cust );
+ t.commit();
+ s.close();
+
+ System.out.println();
+
+ s = openSession();
+ t = s.beginTransaction();
+ cust = (Element) s.createQuery( "from Customer c left join fetch c.accounts" ).uniqueResult();
+ Element a1 = cust.element( "accounts" ).addElement( "account" );
+ a1.addElement( "balance" ).setText( "12.67" );
+ a1.addAttribute( "id", "lkj345" );
+ a1.addAttribute("acnum", "0");
+ Element a2 = cust.element( "accounts" ).addElement( "account" );
+ a2.addElement( "balance" ).setText( "10000.00" );
+ a2.addAttribute( "id", "hsh987" );
+ a2.addAttribute("acnum", "1");
+ print( cust );
+ t.commit();
+ s.close();
+
+ System.out.println();
+
+ s = openSession();
+ t = s.beginTransaction();
+ cust = (Element) s.createQuery( "from Customer c left join fetch c.accounts" ).uniqueResult();
+ print( cust );
+ t.commit();
+ s.close();
+
+ // clean up
+ s = openSession();
+ t = s.beginTransaction();
+ s.delete( "Account", acct );
+ s.delete( "Location", loc );
+ s.createQuery( "delete from Account" ).executeUpdate();
+ t.commit();
+ s.close();
+ }
+
+ public void testMapIndexEmision() throws Throwable {
+ Element acct = DocumentFactory.getInstance().createElement( "account" );
+ acct.addAttribute( "id", "abc123" );
+ acct.addElement( "balance" ).setText( "123.45" );
+ Element cust = acct.addElement( "customer" );
+ cust.addAttribute( "id", "xyz123" );
+ Element foo1 = cust.addElement( "stuff" ).addElement( "foo" );
+ foo1.setText( "foo" );
+ foo1.addAttribute("bar", "x");
+ Element foo2 = cust.element( "stuff" ).addElement( "foo" );
+ foo2.setText( "bar" );
+ foo2.addAttribute("bar", "y");
+ cust.addElement( "amount" ).setText( "45" );
+ cust.setText( "An example customer" );
+ Element name = cust.addElement( "name" );
+ name.addElement( "first" ).setText( "Gavin" );
+ name.addElement( "last" ).setText( "King" );
+
+ print( acct );
+
+ Element loc = DocumentFactory.getInstance().createElement( "location" );
+ loc.addElement( "address" ).setText( "Karbarook Avenue" );
+
+ Session s = openSession();
+ Transaction t = s.beginTransaction();
+ s.persist( "Location", loc );
+ cust.addElement( "location" ).addAttribute( "id", loc.attributeValue( "id" ) );
+ s.persist( "Account", acct );
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ cust = ( Element ) s.get( "Customer", "xyz123" );
+ print( cust );
+ assertEquals( "Incorrect stuff-map size", 2, cust.element( "stuff" ).elements( "foo" ).size() );
+ Element stuffElement = ( Element ) cust.element( "stuff" ).elements( "foo" ).get( 0 );
+ assertNotNull( "No map-key value present", stuffElement.attribute( "bar" ) );
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ s.delete( "Account", acct );
+ s.delete( "Location", loc );
+ t.commit();
+ s.close();
+ }
+
+ public static void print(Element elt) throws Exception {
+ XMLHelper.dump( elt );
+ }
+}
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/basic/Employer.hbm.xml
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/basic/Employer.hbm.xml 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/basic/Employer.hbm.xml 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,36 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<hibernate-mapping>
+
+ <class entity-name="Employer" node="employer">
+ <id name="id" node="@id" type="long">
+ <generator class="increment"/>
+ </id>
+ <property name="name" node="@name" type="string"/>
+ <set name="employees" node="." cascade="all,delete-orphan" fetch="join" lazy="false">
+ <key not-null="true" column="employerId"/>
+ <one-to-many entity-name="Employee" />
+ </set>
+ </class>
+
+ <class entity-name="Employee" node="employee">
+ <id name="id" node="@id" type="long">
+ <generator class="increment"/>
+ </id>
+ <discriminator column="role" type="string" length="10"/>
+ <property name="name" node="@name" type="string"/>
+ <subclass entity-name="Techie" node="techie" />
+ <subclass entity-name="Salesdude" node="sales-dude"/>
+ </class>
+
+ <class entity-name="Department" node="department">
+ <id name="id" node="@id" type="long">
+ <generator class="increment"/>
+ </id>
+ <property name="name" node="@name" type="string"/>
+ <many-to-one name="manager" entity-name="Employee" cascade="all" fetch="join" lazy="false" embed-xml="true" node="manager" />
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/many2one/Car.hbm.xml
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/many2one/Car.hbm.xml 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/many2one/Car.hbm.xml 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,34 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="org.hibernate.test.entitymode.dom4j.many2one">
+
+ <class name="Car" lazy="false" node="car">
+ <id name="id" node="@id" type="long">
+ <generator class="increment"/>
+ </id>
+ <property name="model" type="string" node="model"/>
+ <many-to-one name="carType" node="carType" class="CarType"/>
+ <set name="carParts" node="." cascade="all">
+ <key column="car" not-null="true"/>
+ <one-to-many class="CarPart" node="carPart" embed-xml="false"/>
+ </set>
+ </class>
+
+ <class name="CarType" lazy="true" node="carType">
+ <id name="id" node="@id" type="long">
+ <generator class="increment"/>
+ </id>
+ <property name="typeName" type="string" node="typeName"/>
+ </class>
+
+ <class name="CarPart" node="carPart">
+ <id name="id" node="@id" type="long">
+ <generator class="increment"/>
+ </id>
+ <property name="partName" type="string" node="partName"/>
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/many2one/Car.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/many2one/Car.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/many2one/Car.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,58 @@
+package org.hibernate.test.entitymode.dom4j.many2one;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author Paco Hern�ndez
+ */
+public class Car implements java.io.Serializable {
+
+ private long id;
+ private String model;
+ private CarType carType;
+ private Set carParts = new HashSet();
+
+ /**
+ * @return Returns the carType.
+ */
+ public CarType getCarType() {
+ return carType;
+ }
+ /**
+ * @param carType The carType to set.
+ */
+ public void setCarType(CarType carType) {
+ this.carType = carType;
+ }
+ /**
+ * @return Returns the id.
+ */
+ public long getId() {
+ return id;
+ }
+ /**
+ * @param id The id to set.
+ */
+ public void setId(long id) {
+ this.id = id;
+ }
+ /**
+ * @return Returns the model.
+ */
+ public String getModel() {
+ return model;
+ }
+ /**
+ * @param model The model to set.
+ */
+ public void setModel(String model) {
+ this.model = model;
+ }
+ public Set getCarParts() {
+ return carParts;
+ }
+ public void setCarParts(Set carParts) {
+ this.carParts = carParts;
+ }
+}
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/many2one/CarPart.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/many2one/CarPart.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/many2one/CarPart.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,35 @@
+package org.hibernate.test.entitymode.dom4j.many2one;
+
+/**
+ * @author Paco Hern�ndez
+ */
+public class CarPart implements java.io.Serializable {
+
+ private long id;
+ private String partName;
+
+ /**
+ * @return Returns the id.
+ */
+ public long getId() {
+ return id;
+ }
+ /**
+ * @param id The id to set.
+ */
+ public void setId(long id) {
+ this.id = id;
+ }
+ /**
+ * @return Returns the typeName.
+ */
+ public String getPartName() {
+ return partName;
+ }
+ /**
+ * @param typeName The typeName to set.
+ */
+ public void setPartName(String typeName) {
+ this.partName = typeName;
+ }
+}
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/many2one/CarType.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/many2one/CarType.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/many2one/CarType.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,35 @@
+package org.hibernate.test.entitymode.dom4j.many2one;
+
+/**
+ * @author Paco Hern�ndez
+ */
+public class CarType implements java.io.Serializable {
+
+ private long id;
+ private String typeName;
+
+ /**
+ * @return Returns the id.
+ */
+ public long getId() {
+ return id;
+ }
+ /**
+ * @param id The id to set.
+ */
+ public void setId(long id) {
+ this.id = id;
+ }
+ /**
+ * @return Returns the typeName.
+ */
+ public String getTypeName() {
+ return typeName;
+ }
+ /**
+ * @param typeName The typeName to set.
+ */
+ public void setTypeName(String typeName) {
+ this.typeName = typeName;
+ }
+}
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/many2one/Dom4jManyToOneTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/many2one/Dom4jManyToOneTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/dom4j/many2one/Dom4jManyToOneTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,141 @@
+package org.hibernate.test.entitymode.dom4j.many2one;
+
+import java.util.List;
+
+import junit.framework.Test;
+import org.dom4j.Element;
+import org.dom4j.io.OutputFormat;
+import org.dom4j.io.XMLWriter;
+
+import org.hibernate.EntityMode;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+
+/**
+ * @author Paco Hern�ndez
+ */
+public class Dom4jManyToOneTest extends FunctionalTestCase {
+
+ public Dom4jManyToOneTest(String str) {
+ super( str );
+ }
+
+ public String[] getMappings() {
+ return new String[] { "entitymode/dom4j/many2one/Car.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( Dom4jManyToOneTest.class );
+ }
+
+ public void testDom4jOneToMany() throws Exception {
+ Session s = openSession();
+ Transaction t = s.beginTransaction();
+
+ CarType carType = new CarType();
+ carType.setTypeName("Type 1");
+ s.save(carType);
+
+ Car car = new Car();
+ car.setCarType(carType);
+ car.setModel("Model 1");
+ s.save(car);
+
+ CarPart carPart1 = new CarPart();
+ carPart1.setPartName("chassis");
+ car.getCarParts().add(carPart1);
+
+ t.commit();
+ s.close();
+
+ s = openSession();
+ Session dom4jSession = s.getSession( EntityMode.DOM4J );
+ t = s.beginTransaction();
+
+ Element element = (Element) dom4jSession.createQuery( "from Car c join fetch c.carParts" ).uniqueResult();
+
+ String expectedResult = "<car id=\"" +
+ car.getId() +
+ "\"><carPart>" +
+ carPart1.getId() +
+ "</carPart><model>Model 1</model><carType id=\"" +
+ carType.getId() +
+ "\"><typeName>Type 1</typeName></carType></car>";
+
+ print(element);
+ assertTrue(element.asXML().equals(expectedResult));
+
+ s.createQuery("delete from CarPart").executeUpdate();
+ s.createQuery("delete from Car").executeUpdate();
+ s.createQuery("delete from CarType").executeUpdate();
+
+ t.commit();
+ s.close();
+ }
+
+ public void testDom4jManyToOne() throws Exception {
+
+ Session s = openSession();
+ Transaction t = s.beginTransaction();
+
+ CarType carType = new CarType();
+ carType.setTypeName("Type 1");
+ s.save(carType);
+
+ Car car1 = new Car();
+ car1.setCarType(carType);
+ car1.setModel("Model 1");
+ s.save(car1);
+
+ Car car2 = new Car();
+ car2.setCarType(carType);
+ car2.setModel("Model 2");
+ s.save(car2);
+
+ t.commit();
+ s.close();
+
+ s = openSession();
+ Session dom4jSession = s.getSession( EntityMode.DOM4J );
+ t = s.beginTransaction();
+
+ List list = dom4jSession.createQuery( "from Car c join fetch c.carType order by c.model asc" ).list();
+
+ String[] expectedResults = new String[] {
+ "<car id=\"" +
+ car1.getId() +
+ "\"><model>Model 1</model><carType id=\"" +
+ carType.getId() +
+ "\"><typeName>Type 1</typeName></carType></car>",
+ "<car id=\"" +
+ car2.getId() +
+ "\"><model>Model 2</model><carType id=\"" +
+ carType.getId() +
+ "\"><typeName>Type 1</typeName></carType></car>"
+ };
+
+ for (int i = 0; i < list.size(); i++) {
+ Element element = (Element) list.get(i);
+
+ print(element);
+ assertTrue(element.asXML().equals(expectedResults[i]));
+ }
+
+ s.createQuery("delete from Car").executeUpdate();
+ s.createQuery("delete from CarType").executeUpdate();
+
+ t.commit();
+ s.close();
+ }
+
+ public static void print(Element elt) throws Exception {
+ OutputFormat outformat = OutputFormat.createPrettyPrint();
+ // outformat.setEncoding(aEncodingScheme);
+ XMLWriter writer = new XMLWriter( System.out, outformat );
+ writer.write( elt );
+ writer.flush();
+ // System.out.println( elt.asXML() );
+ }
+}
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/map/MapSuite.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/map/MapSuite.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/map/MapSuite.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,19 @@
+package org.hibernate.test.entitymode.map;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.hibernate.test.entitymode.map.basic.DynamicClassTest;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class MapSuite {
+ public static Test suite() {
+ TestSuite suite = new TestSuite( "map entity-mode suite");
+ suite.addTest( DynamicClassTest.suite() );
+ return suite;
+ }
+}
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/map/basic/DynamicClassTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/map/basic/DynamicClassTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/map/basic/DynamicClassTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,109 @@
+//$Id: DynamicClassTest.java 9024 2006-01-11 22:38:24Z steveebersole $
+package org.hibernate.test.entitymode.map.basic;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.Test;
+
+import org.hibernate.EntityMode;
+import org.hibernate.Hibernate;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+
+/**
+ * @author Gavin King
+ */
+public class DynamicClassTest extends FunctionalTestCase {
+
+ public DynamicClassTest(String str) {
+ super(str);
+ }
+
+ public String[] getMappings() {
+ return new String[] { "entitymode/map/basic/ProductLine.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty(Environment.DEFAULT_ENTITY_MODE, EntityMode.MAP.toString());
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( DynamicClassTest.class );
+ }
+
+ public void testLazyDynamicClass() {
+ Session s = openSession();
+ assertTrue( "Incorrectly handled default_entity_mode", s.getEntityMode() == EntityMode.MAP );
+ Session other = s.getSession( EntityMode.MAP );
+ assertEquals( "openSession() using same entity-mode returned new session", s, other );
+
+ other = s.getSession( EntityMode.POJO );
+ other.close();
+ assertTrue( !other.isOpen() );
+// this is no longer allowed since the session does much more up-front closed checking
+// assertTrue( other.isConnected() ); // because it is linked to the "root" session's connection
+
+ s.close();
+
+ s = openSession();
+ Transaction t = s.beginTransaction();
+
+ Map cars = new HashMap();
+ cars.put("description", "Cars");
+ Map monaro = new HashMap();
+ monaro.put("productLine", cars);
+ monaro.put("name", "monaro");
+ monaro.put("description", "Holden Monaro");
+ Map hsv = new HashMap();
+ hsv.put("productLine", cars);
+ hsv.put("name", "hsv");
+ hsv.put("description", "Holden Commodore HSV");
+ List models = new ArrayList();
+ cars.put("models", models);
+ models.add(hsv);
+ models.add(monaro);
+ s.save("ProductLine", cars);
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+
+ cars = (Map) s.createQuery("from ProductLine pl order by pl.description").uniqueResult();
+ models = (List) cars.get("models");
+ assertFalse( Hibernate.isInitialized(models) );
+ assertEquals( models.size(), 2);
+ assertTrue( Hibernate.isInitialized(models) );
+
+ s.clear();
+
+ List list = s.createQuery("from Model m").list();
+ for ( Iterator i=list.iterator(); i.hasNext(); ) {
+ assertFalse( Hibernate.isInitialized( ( (Map) i.next() ).get("productLine") ) );
+ }
+ Map model = (Map) list.get(0);
+ assertTrue( ( (List) ( (Map) model.get("productLine") ).get("models") ).contains(model) );
+ s.clear();
+
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ cars = (Map) s.createQuery("from ProductLine pl order by pl.description").uniqueResult();
+ s.delete(cars);
+ t.commit();
+ s.close();
+ }
+
+
+}
+
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/map/basic/ProductLine.hbm.xml
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/map/basic/ProductLine.hbm.xml 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/map/basic/ProductLine.hbm.xml 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,38 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping>
+
+<!--
+ This mapping demonstrates "dynamic" entities.
+-->
+
+ <class entity-name="ProductLine">
+ <id name="id" column="productId" length="32" type="string">
+ <generator class="uuid.hex"/>
+ </id>
+
+ <property name="description" not-null="true" length="200" type="string"/>
+
+ <!-- don't use sets for associations, unless you want stack overflows! -->
+ <bag name="models" cascade="all" inverse="true">
+ <key column="productId"/>
+ <one-to-many class="Model"/>
+ </bag>
+
+ </class>
+
+ <class entity-name="Model">
+ <id name="id" column="modelId" length="32" type="string">
+ <generator class="uuid.hex"/>
+ </id>
+
+ <property name="name" not-null="true" length="25" type="string"/>
+ <property name="description" not-null="true" length="200" type="string"/>
+ <many-to-one name="productLine" column="productId" not-null="true" class="ProductLine"/>
+
+ </class>
+
+</hibernate-mapping>
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/multi/MultiRepresentationTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/multi/MultiRepresentationTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/multi/MultiRepresentationTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,194 @@
+// $Id: MultiRepresentationTest.java 6300 2005-04-03 04:24:23Z oneovthafew $
+package org.hibernate.test.entitymode.multi;
+
+import java.sql.Date;
+import java.util.Iterator;
+import java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.dom4j.DocumentFactory;
+import org.dom4j.Element;
+import org.dom4j.io.OutputFormat;
+import org.dom4j.io.XMLWriter;
+
+import org.hibernate.EntityMode;
+import org.hibernate.Transaction;
+import org.hibernate.classic.Session;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+
+/**
+ * Implementation of MultiRepresentationTest.
+ *
+ * @author Steve Ebersole
+ */
+public class MultiRepresentationTest extends FunctionalTestCase {
+
+
+ public MultiRepresentationTest(String name) {
+ super( name );
+ }
+
+ public String[] getMappings() {
+ return new String[] { "entitymode/multi/Stock.hbm.xml", "entitymode/multi/Valuation.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( MultiRepresentationTest.class );
+ }
+
+ public void testPojoRetreival() {
+ TestData testData = new TestData();
+ testData.create();
+
+ Session session = openSession();
+ Transaction txn = session.beginTransaction();
+
+ Stock stock = ( Stock ) session.get( Stock.class, new Long( 1 ) );
+ assertEquals( "Something wrong!", new Long( 1 ), stock.getId() );
+
+ txn.commit();
+ session.close();
+
+ testData.destroy();
+ }
+
+ public void testDom4jRetreival() {
+ TestData testData = new TestData();
+ testData.create();
+
+ Session session = openSession();
+ Transaction txn = session.beginTransaction();
+ org.hibernate.Session dom4j = session.getSession( EntityMode.DOM4J );
+
+ Object rtn = dom4j.get( Stock.class.getName(), testData.stockId );
+ Element element = ( Element ) rtn;
+
+ assertEquals( "Something wrong!", testData.stockId, Long.valueOf( element.attributeValue( "id" ) ) );
+
+ System.out.println( "**** XML: ****************************************************" );
+ prettyPrint( element );
+ System.out.println( "**************************************************************" );
+
+ Element currVal = element.element( "currentValuation" );
+
+ System.out.println( "**** XML: ****************************************************" );
+ prettyPrint( currVal );
+ System.out.println( "**************************************************************" );
+
+ txn.rollback();
+ session.close();
+
+ testData.destroy();
+ }
+
+ public void testDom4jSave() {
+ TestData testData = new TestData();
+ testData.create();
+
+ Session pojos = openSession();
+ Transaction txn = pojos.beginTransaction();
+ org.hibernate.Session dom4j = pojos.getSession( EntityMode.DOM4J );
+
+ Element stock = DocumentFactory.getInstance().createElement( "stock" );
+ stock.addElement( "tradeSymbol" ).setText( "IBM" );
+
+ Element val = stock.addElement( "currentValuation" ).addElement( "valuation" );
+ val.appendContent( stock );
+ val.addElement( "valuationDate" ).setText( new java.util.Date().toString() );
+ val.addElement( "value" ).setText( "121.00" );
+
+ dom4j.save( Stock.class.getName(), stock );
+ dom4j.flush();
+
+ txn.rollback();
+ pojos.close();
+
+ assertTrue( !pojos.isOpen() );
+ assertTrue( !dom4j.isOpen() );
+
+ prettyPrint( stock );
+
+ testData.destroy();
+ }
+
+ public void testDom4jHQL() {
+ TestData testData = new TestData();
+ testData.create();
+
+ Session session = openSession();
+ Transaction txn = session.beginTransaction();
+ org.hibernate.Session dom4j = session.getSession( EntityMode.DOM4J );
+
+ List result = dom4j.createQuery( "from Stock" ).list();
+
+ assertEquals( "Incorrect result size", 1, result.size() );
+ Element element = ( Element ) result.get( 0 );
+ assertEquals( "Something wrong!", testData.stockId, Long.valueOf( element.attributeValue( "id" ) ) );
+
+ System.out.println( "**** XML: ****************************************************" );
+ prettyPrint( element );
+ System.out.println( "**************************************************************" );
+
+ txn.rollback();
+ session.close();
+
+ testData.destroy();
+ }
+
+ private class TestData {
+ private Long stockId;
+
+ private void create() {
+ Session session = getSessions().openSession();
+ session.beginTransaction();
+ Stock stock = new Stock();
+ stock.setTradeSymbol( "JBOSS" );
+ Valuation valuation = new Valuation();
+ valuation.setStock( stock );
+ valuation.setValuationDate( new Date( new java.util.Date().getTime() ) );
+ valuation.setValue( new Double( 200.0 ) );
+ stock.setCurrentValuation( valuation );
+ stock.getValuations().add( valuation );
+
+ session.save( stock );
+ session.save( valuation );
+
+ session.getTransaction().commit();
+ session.close();
+
+ stockId = stock.getId();
+ }
+
+ private void destroy() {
+ Session session = getSessions().openSession();
+ session.beginTransaction();
+ Iterator stocks = session.createQuery( "from Stock" ).list().iterator();
+ while ( stocks.hasNext() ) {
+ final Stock stock = ( Stock ) stocks.next();
+ stock.setCurrentValuation( null );
+ session.flush();
+ Iterator valuations = stock.getValuations().iterator();
+ while ( valuations.hasNext() ) {
+ session.delete( valuations.next() );
+ }
+ session.delete( stock );
+ }
+ session.getTransaction().commit();
+ session.close();
+ }
+ }
+
+ private void prettyPrint(Element element) {
+ //System.out.println( element.asXML() );
+ try {
+ OutputFormat format = OutputFormat.createPrettyPrint();
+ new XMLWriter( System.out, format ).write( element );
+ System.out.println();
+ }
+ catch ( Throwable t ) {
+ System.err.println( "Unable to pretty print element : " + t );
+ }
+ }
+}
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/multi/Stock.hbm.xml
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/multi/Stock.hbm.xml 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/multi/Stock.hbm.xml 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping
+ SYSTEM
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
+
+<hibernate-mapping package="org.hibernate.test.entitymode.multi">
+
+ <class table="STOCK" name="Stock" node="stock">
+
+ <id name="id" column="STOCK_ID" node="@id">
+ <generator class="increment"/>
+ </id>
+
+ <property name="tradeSymbol" type="string" column="SYMBOL"/>
+
+ <many-to-one name="currentValuation" class="Valuation" column="CURR_VAL_ID" cascade="all" />
+
+ <set name="valuations" cascade="all" lazy="true">
+ <key column="STOCK_ID"/>
+ <one-to-many class="Valuation"/>
+ </set>
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/multi/Stock.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/multi/Stock.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/multi/Stock.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,49 @@
+// $Id: Stock.java 5686 2005-02-12 07:27:32Z steveebersole $
+package org.hibernate.test.entitymode.multi;
+
+import java.util.Set;
+import java.util.HashSet;
+
+/**
+ * POJO implementation of Stock entity.
+ *
+ * @author Steve Ebersole
+ */
+public class Stock {
+ private Long id;
+ private String tradeSymbol;
+ private Valuation currentValuation;
+ private Set valuations = new HashSet();
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getTradeSymbol() {
+ return tradeSymbol;
+ }
+
+ public void setTradeSymbol(String tradeSymbol) {
+ this.tradeSymbol = tradeSymbol;
+ }
+
+ public Valuation getCurrentValuation() {
+ return currentValuation;
+ }
+
+ public void setCurrentValuation(Valuation currentValuation) {
+ this.currentValuation = currentValuation;
+ }
+
+ public Set getValuations() {
+ return valuations;
+ }
+
+ public void setValuations(Set valuations) {
+ this.valuations = valuations;
+ }
+}
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/multi/Valuation.hbm.xml
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/multi/Valuation.hbm.xml 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/multi/Valuation.hbm.xml 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping
+ SYSTEM
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
+
+<hibernate-mapping package="org.hibernate.test.entitymode.multi">
+
+ <class table="STOCK_VAL" name="Valuation" node="valuation">
+
+ <id name="id" column="VAL_ID" node="@id">
+ <generator class="increment"/>
+ </id>
+
+ <many-to-one name="stock" embed-xml="false"
+ class="Stock" column="STOCK_ID" cascade="none" />
+
+ <property name="valuationDate" type="date" column="DT"/>
+ <property name="value" type="double" column="VAL"/>
+
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/multi/Valuation.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/multi/Valuation.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/entitymode/multi/Valuation.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,48 @@
+// $Id: Valuation.java 5686 2005-02-12 07:27:32Z steveebersole $
+package org.hibernate.test.entitymode.multi;
+
+import java.util.Date;
+
+/**
+ * Implementation of Valuation.
+ *
+ * @author Steve Ebersole
+ */
+public class Valuation {
+ private Long id;
+ private Stock stock;
+ private Date valuationDate;
+ private Double value;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public Stock getStock() {
+ return stock;
+ }
+
+ public void setStock(Stock stock) {
+ this.stock = stock;
+ }
+
+ public Date getValuationDate() {
+ return valuationDate;
+ }
+
+ public void setValuationDate(Date valuationDate) {
+ this.valuationDate = valuationDate;
+ }
+
+ public Double getValue() {
+ return value;
+ }
+
+ public void setValue(Double value) {
+ this.value = value;
+ }
+}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/exception/SQLExceptionConversionTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/exception/SQLExceptionConversionTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/exception/SQLExceptionConversionTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -6,7 +6,6 @@
import java.sql.SQLException;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.JDBCException;
import org.hibernate.Session;
@@ -14,7 +13,8 @@
import org.hibernate.exception.ConstraintViolationException;
import org.hibernate.exception.SQLExceptionConverter;
import org.hibernate.exception.SQLGrammarException;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.util.JDBCExceptionReporter;
/**
@@ -22,18 +22,25 @@
*
* @author Steve Ebersole
*/
-public class SQLExceptionConversionTest extends TestCase {
+public class SQLExceptionConversionTest extends FunctionalTestCase {
public SQLExceptionConversionTest(String name) {
super(name);
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] {"exception/User.hbm.xml", "exception/Group.hbm.xml"};
}
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite(SQLExceptionConversionTest.class);
+ }
+
public void testIntegrityViolation() throws Exception {
- if ( getDialect() instanceof MySQLMyISAMDialect ) return;
+ if ( getDialect() instanceof MySQLMyISAMDialect ) {
+ reportSkip( "MySQL (ISAM) does not support FK violation checking", "exception conversion" );
+ return;
+ }
SQLExceptionConverter converter = getDialect().buildSQLExceptionConverter();
@@ -82,8 +89,4 @@
session.close();
}
-
- public static Test suite() {
- return new TestSuite(SQLExceptionConversionTest.class);
- }
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/extendshbm/ExtendsTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/extendshbm/ExtendsTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/extendshbm/ExtendsTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -6,168 +6,186 @@
import org.hibernate.HibernateException;
import org.hibernate.cfg.Configuration;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.UnitTestCase;
/**
* @author Gavin King
*/
-public class ExtendsTest extends TestCase {
-
+public class ExtendsTest extends UnitTestCase {
+
public ExtendsTest(String str) {
- super(str);
+ super( str );
}
-
- public void testAllInOne() {
- Configuration cfg = new Configuration();
-
- cfg.addResource(getBaseForMappings() + "extendshbm/allinone.hbm.xml");
- assertNotNull(cfg.getClassMapping("org.hibernate.test.extendshbm.Customer"));
- assertNotNull(cfg.getClassMapping("org.hibernate.test.extendshbm.Person"));
- assertNotNull(cfg.getClassMapping("org.hibernate.test.extendshbm.Employee"));
- }
-
+
+ public static Test suite() {
+ return new TestSuite( ExtendsTest.class );
+ }
+
+ private String getBaseForMappings() {
+ return "org/hibernate/test/";
+ }
+
+ public void testAllInOne() {
+ Configuration cfg = new Configuration();
+
+ cfg.addResource( getBaseForMappings() + "extendshbm/allinone.hbm.xml" );
+ assertNotNull( cfg.getClassMapping( "org.hibernate.test.extendshbm.Customer" ) );
+ assertNotNull( cfg.getClassMapping( "org.hibernate.test.extendshbm.Person" ) );
+ assertNotNull( cfg.getClassMapping( "org.hibernate.test.extendshbm.Employee" ) );
+ }
+
public void testOutOfOrder() {
- Configuration cfg = new Configuration();
-
- try {
- cfg.addResource(getBaseForMappings() + "extendshbm/Customer.hbm.xml");
- assertNull("cannot be in the configuration yet!", cfg.getClassMapping("org.hibernate.test.extendshbm.Customer"));
- cfg.addResource(getBaseForMappings() + "extendshbm/Person.hbm.xml");
- cfg.addResource(getBaseForMappings() + "extendshbm/Employee.hbm.xml");
-
- cfg.buildSessionFactory();
-
- assertNotNull(cfg.getClassMapping("org.hibernate.test.extendshbm.Customer"));
- assertNotNull(cfg.getClassMapping("org.hibernate.test.extendshbm.Person"));
- assertNotNull(cfg.getClassMapping("org.hibernate.test.extendshbm.Employee"));
-
- } catch(HibernateException e) {
- fail("should not fail with exception! " + e);
- }
-
+ Configuration cfg = new Configuration();
+
+ try {
+ cfg.addResource( getBaseForMappings() + "extendshbm/Customer.hbm.xml" );
+ assertNull(
+ "cannot be in the configuration yet!",
+ cfg.getClassMapping( "org.hibernate.test.extendshbm.Customer" )
+ );
+ cfg.addResource( getBaseForMappings() + "extendshbm/Person.hbm.xml" );
+ cfg.addResource( getBaseForMappings() + "extendshbm/Employee.hbm.xml" );
+
+ cfg.buildSessionFactory();
+
+ assertNotNull( cfg.getClassMapping( "org.hibernate.test.extendshbm.Customer" ) );
+ assertNotNull( cfg.getClassMapping( "org.hibernate.test.extendshbm.Person" ) );
+ assertNotNull( cfg.getClassMapping( "org.hibernate.test.extendshbm.Employee" ) );
+
+ }
+ catch ( HibernateException e ) {
+ fail( "should not fail with exception! " + e );
+ }
+
}
public void testNwaitingForSuper() {
- Configuration cfg = new Configuration();
-
- try {
- cfg.addResource(getBaseForMappings() + "extendshbm/Customer.hbm.xml");
- assertNull("cannot be in the configuration yet!", cfg.getClassMapping("org.hibernate.test.extendshbm.Customer"));
- cfg.addResource(getBaseForMappings() + "extendshbm/Employee.hbm.xml");
- assertNull("cannot be in the configuration yet!", cfg.getClassMapping("org.hibernate.test.extendshbm.Employee"));
- cfg.addResource(getBaseForMappings() + "extendshbm/Person.hbm.xml");
-
- cfg.buildMappings();
-
- assertNotNull(cfg.getClassMapping("org.hibernate.test.extendshbm.Person"));
- assertNotNull(cfg.getClassMapping("org.hibernate.test.extendshbm.Employee"));
- assertNotNull(cfg.getClassMapping("org.hibernate.test.extendshbm.Customer"));
-
-
- } catch(HibernateException e) {
+ Configuration cfg = new Configuration();
+
+ try {
+ cfg.addResource( getBaseForMappings() + "extendshbm/Customer.hbm.xml" );
+ assertNull(
+ "cannot be in the configuration yet!",
+ cfg.getClassMapping( "org.hibernate.test.extendshbm.Customer" )
+ );
+ cfg.addResource( getBaseForMappings() + "extendshbm/Employee.hbm.xml" );
+ assertNull(
+ "cannot be in the configuration yet!",
+ cfg.getClassMapping( "org.hibernate.test.extendshbm.Employee" )
+ );
+ cfg.addResource( getBaseForMappings() + "extendshbm/Person.hbm.xml" );
+
+ cfg.buildMappings();
+
+ assertNotNull( cfg.getClassMapping( "org.hibernate.test.extendshbm.Person" ) );
+ assertNotNull( cfg.getClassMapping( "org.hibernate.test.extendshbm.Employee" ) );
+ assertNotNull( cfg.getClassMapping( "org.hibernate.test.extendshbm.Customer" ) );
+
+
+ }
+ catch ( HibernateException e ) {
e.printStackTrace();
- fail("should not fail with exception! " + e);
-
- }
-
+ fail( "should not fail with exception! " + e );
+
+ }
+
}
-
- public void testMissingSuper() {
- Configuration cfg = new Configuration();
-
- try {
- cfg.addResource(getBaseForMappings() + "extendshbm/Customer.hbm.xml");
- assertNull("cannot be in the configuration yet!", cfg.getClassMapping("org.hibernate.test.extendshbm.Customer"));
- cfg.addResource(getBaseForMappings() + "extendshbm/Employee.hbm.xml");
-
- cfg.buildSessionFactory();
-
- fail("Should not be able to build sessionfactory without a Person");
- } catch(HibernateException e) {
-
- }
-
- }
-
- public void testAllSeparateInOne() {
- Configuration cfg = new Configuration();
-
- try {
- cfg.addResource(getBaseForMappings() + "extendshbm/allseparateinone.hbm.xml");
-
- cfg.buildSessionFactory();
-
- assertNotNull(cfg.getClassMapping("org.hibernate.test.extendshbm.Customer"));
- assertNotNull(cfg.getClassMapping("org.hibernate.test.extendshbm.Person"));
- assertNotNull(cfg.getClassMapping("org.hibernate.test.extendshbm.Employee"));
-
- } catch(HibernateException e) {
- fail("should not fail with exception! " + e);
- }
-
- }
-
- public void testJoinedSubclassAndEntityNamesOnly() {
- Configuration cfg = new Configuration();
-
+
+ public void testMissingSuper() {
+ Configuration cfg = new Configuration();
+
try {
- cfg.addResource(getBaseForMappings() + "extendshbm/entitynames.hbm.xml");
-
- cfg.buildMappings();
-
- assertNotNull(cfg.getClassMapping("EntityHasName"));
- assertNotNull(cfg.getClassMapping("EntityCompany"));
-
- } catch(HibernateException e) {
+ cfg.addResource( getBaseForMappings() + "extendshbm/Customer.hbm.xml" );
+ assertNull(
+ "cannot be in the configuration yet!",
+ cfg.getClassMapping( "org.hibernate.test.extendshbm.Customer" )
+ );
+ cfg.addResource( getBaseForMappings() + "extendshbm/Employee.hbm.xml" );
+
+ cfg.buildSessionFactory();
+
+ fail( "Should not be able to build sessionfactory without a Person" );
+ }
+ catch ( HibernateException e ) {
+
+ }
+
+ }
+
+ public void testAllSeparateInOne() {
+ Configuration cfg = new Configuration();
+
+ try {
+ cfg.addResource( getBaseForMappings() + "extendshbm/allseparateinone.hbm.xml" );
+
+ cfg.buildSessionFactory();
+
+ assertNotNull( cfg.getClassMapping( "org.hibernate.test.extendshbm.Customer" ) );
+ assertNotNull( cfg.getClassMapping( "org.hibernate.test.extendshbm.Person" ) );
+ assertNotNull( cfg.getClassMapping( "org.hibernate.test.extendshbm.Employee" ) );
+
+ }
+ catch ( HibernateException e ) {
+ fail( "should not fail with exception! " + e );
+ }
+
+ }
+
+ public void testJoinedSubclassAndEntityNamesOnly() {
+ Configuration cfg = new Configuration();
+
+ try {
+ cfg.addResource( getBaseForMappings() + "extendshbm/entitynames.hbm.xml" );
+
+ cfg.buildMappings();
+
+ assertNotNull( cfg.getClassMapping( "EntityHasName" ) );
+ assertNotNull( cfg.getClassMapping( "EntityCompany" ) );
+
+ }
+ catch ( HibernateException e ) {
e.printStackTrace();
- fail("should not fail with exception! " + e);
-
- }
+ fail( "should not fail with exception! " + e );
+
+ }
}
-
+
public void testEntityNamesWithPackageFailureExpected() {
Configuration cfg = new Configuration();
try {
- cfg.addResource(getBaseForMappings() + "extendshbm/packageentitynames.hbm.xml");
-
- cfg.buildMappings();
-
- assertNotNull(cfg.getClassMapping("EntityHasName"));
- assertNotNull(cfg.getClassMapping("EntityCompany"));
-
- } catch(HibernateException e) {
+ cfg.addResource( getBaseForMappings() + "extendshbm/packageentitynames.hbm.xml" );
+
+ cfg.buildMappings();
+
+ assertNotNull( cfg.getClassMapping( "EntityHasName" ) );
+ assertNotNull( cfg.getClassMapping( "EntityCompany" ) );
+
+ }
+ catch ( HibernateException e ) {
e.printStackTrace();
- fail("should not fail with exception! " + e);
-
- }
+ fail( "should not fail with exception! " + e );
+
+ }
}
-
- public void testUnionSubclass() {
- Configuration cfg = new Configuration();
-
+
+ public void testUnionSubclass() {
+ Configuration cfg = new Configuration();
+
try {
- cfg.addResource(getBaseForMappings() + "extendshbm/unionsubclass.hbm.xml");
-
- cfg.buildMappings();
-
- assertNotNull(cfg.getClassMapping("org.hibernate.test.extendshbm.Person"));
- assertNotNull(cfg.getClassMapping("org.hibernate.test.extendshbm.Customer"));
-
- } catch(HibernateException e) {
+ cfg.addResource( getBaseForMappings() + "extendshbm/unionsubclass.hbm.xml" );
+
+ cfg.buildMappings();
+
+ assertNotNull( cfg.getClassMapping( "org.hibernate.test.extendshbm.Person" ) );
+ assertNotNull( cfg.getClassMapping( "org.hibernate.test.extendshbm.Customer" ) );
+
+ }
+ catch ( HibernateException e ) {
e.printStackTrace();
- fail("should not fail with exception! " + e);
-
- }
- }
-
-
- protected String[] getMappings() {
- return new String[] { };
- }
+ fail( "should not fail with exception! " + e );
- public static Test suite() {
- return new TestSuite(ExtendsTest.class);
+ }
}
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/extralazy/ExtraLazyTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/extralazy/ExtraLazyTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/extralazy/ExtraLazyTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,27 +1,34 @@
//$Id$
package org.hibernate.test.extralazy;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class ExtraLazyTest extends TestCase {
-
+public class ExtraLazyTest extends FunctionalTestCase {
+
public ExtraLazyTest(String str) {
super(str);
}
-
+
+ public String[] getMappings() {
+ return new String[] { "extralazy/UserGroup.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( ExtraLazyTest.class );
+ }
+
public void testOrphanDelete() {
Session s = openSession();
Transaction t = s.beginTransaction();
@@ -209,41 +216,6 @@
s.close();
}
-
- public void testExtraLazySetFailureExpected() {
- Session s = openSession();
- Transaction t = s.beginTransaction();
- User gavin = new User("gavin", "secret");
- new Document( "Hia", "something", gavin );
- new Document( "Seam", "seamy", gavin );
- s.persist(gavin);
- t.commit();
- s.close();
-
- s = openSession();
- t = s.beginTransaction();
-
- User person = (User) s.get(User.class, gavin.getName());
-
- new Document( "Fresh", "word", person );
- System.out.println("Writing out the persons documentes (Set). Expected to find 3 but it only contains 2.");
-
- for (Iterator iter = person.getDocuments().iterator(); iter.hasNext();) {
- Document doc = (Document) iter.next();
- System.out.println("phoneNumber: " + doc);
- }
-
- assertEquals(person.getDocuments().size(),3);
- s.close();
- }
-
- protected String[] getMappings() {
- return new String[] { "extralazy/UserGroup.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(ExtraLazyTest.class);
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/filter/DynamicFilterTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/filter/DynamicFilterTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/filter/DynamicFilterTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -19,6 +19,8 @@
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.cache.CacheKey;
import org.hibernate.cache.entry.CollectionCacheEntry;
import org.hibernate.cfg.Configuration;
@@ -35,15 +37,36 @@
*
* @author Steve
*/
-public class DynamicFilterTest extends TestCase {
+public class DynamicFilterTest extends FunctionalTestCase {
private Log log = LogFactory.getLog( DynamicFilterTest.class );
-
public DynamicFilterTest(String testName) {
super( testName );
}
+ public String[] getMappings() {
+ return new String[]{
+ "filter/defs.hbm.xml",
+ "filter/LineItem.hbm.xml",
+ "filter/Order.hbm.xml",
+ "filter/Product.hbm.xml",
+ "filter/Salesperson.hbm.xml",
+ "filter/Department.hbm.xml",
+ "filter/Category.hbm.xml"
+ };
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty( Environment.MAX_FETCH_DEPTH, "1" );
+ cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
+ cfg.setProperty( Environment.USE_QUERY_CACHE, "true" );
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( DynamicFilterTest.class );
+ }
+
public void testSecondLevelCachedCollectionsFiltering() {
TestData testData = new TestData();
testData.prepare();
@@ -428,35 +451,6 @@
testData.release();
}
-
- /**
- * Define the mappings needed for these tests.
- *
- * @return Mappings for these tests.
- */
- protected String[] getMappings() {
- return new String[]{
- "filter/defs.hbm.xml",
- "filter/LineItem.hbm.xml",
- "filter/Order.hbm.xml",
- "filter/Product.hbm.xml",
- "filter/Salesperson.hbm.xml",
- "filter/Department.hbm.xml",
- "filter/Category.hbm.xml"
- };
- }
-
- protected void configure(Configuration cfg) {
- cfg.setProperty( Environment.MAX_FETCH_DEPTH, "1" );
-// cfg.setProperty( Environment.MAX_FETCH_DEPTH, "2" );
- cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
- cfg.setProperty( Environment.USE_QUERY_CACHE, "true" );
- }
-
- public static Test suite() {
- return new TestSuite( DynamicFilterTest.class );
- }
-
private class TestData {
private Long steveId;
private Long deptId;
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/formulajoin/FormulaJoinTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/formulajoin/FormulaJoinTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/formulajoin/FormulaJoinTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -4,21 +4,29 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.dialect.PostgreSQLDialect;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class FormulaJoinTest extends TestCase {
+public class FormulaJoinTest extends FunctionalTestCase {
public FormulaJoinTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "formulajoin/Master.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( FormulaJoinTest.class );
+ }
public void testFormulaJoin() {
Session s = openSession();
@@ -88,14 +96,5 @@
}
-
- protected String[] getMappings() {
- return new String[] { "formulajoin/Master.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(FormulaJoinTest.class);
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/generated/AbstractGeneratedPropertyTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/generated/AbstractGeneratedPropertyTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/generated/AbstractGeneratedPropertyTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,17 +1,17 @@
// $Id$
package org.hibernate.test.generated;
-import org.hibernate.test.DatabaseSpecificTestCase;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.Hibernate;
+import org.hibernate.junit.functional.DatabaseSpecificFunctionalTestCase;
/**
* Implementation of AbstractGeneratedPropertyTest.
*
* @author Steve Ebersole
*/
-public abstract class AbstractGeneratedPropertyTest extends DatabaseSpecificTestCase {
+public abstract class AbstractGeneratedPropertyTest extends DatabaseSpecificFunctionalTestCase {
public AbstractGeneratedPropertyTest(String x) {
super( x );
}
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/generated/GeneratedPropertySuite.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/generated/GeneratedPropertySuite.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/generated/GeneratedPropertySuite.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,19 @@
+package org.hibernate.test.generated;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class GeneratedPropertySuite {
+ public static Test suite() {
+ TestSuite suite = new TestSuite( "generated property suite" );
+ suite.addTest( TimestampGeneratedValuesWithCachingTest.suite() );
+ suite.addTest( TriggerGeneratedValuesWithCachingTest.suite() );
+ suite.addTest( TriggerGeneratedValuesWithoutCachingTest.suite() );
+ return suite;
+ }
+}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/generated/TimestampGeneratedValuesWithCachingTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/generated/TimestampGeneratedValuesWithCachingTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/generated/TimestampGeneratedValuesWithCachingTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,12 +1,12 @@
// $Id$
package org.hibernate.test.generated;
+import junit.framework.Test;
+
+import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.SybaseDialect;
-import org.hibernate.dialect.Dialect;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
-import junit.framework.TestSuite;
-import junit.framework.Test;
-
/**
* Implementation of TimestampGeneratedValuesWithCachingTest.
*
@@ -18,7 +18,7 @@
super( x );
}
- protected final String[] getMappings() {
+ public final String[] getMappings() {
return new String[] { "generated/MSSQLGeneratedPropertyEntity.hbm.xml" };
}
@@ -29,6 +29,6 @@
}
public static Test suite() {
- return new TestSuite( TimestampGeneratedValuesWithCachingTest.class );
+ return new FunctionalTestClassTestSuite( TimestampGeneratedValuesWithCachingTest.class );
}
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/generated/TriggerGeneratedValuesWithCachingTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/generated/TriggerGeneratedValuesWithCachingTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/generated/TriggerGeneratedValuesWithCachingTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -3,6 +3,7 @@
import org.hibernate.dialect.Oracle9Dialect;
import org.hibernate.dialect.Dialect;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -18,7 +19,7 @@
super( x );
}
- protected final String[] getMappings() {
+ public final String[] getMappings() {
return new String[] { "generated/GeneratedPropertyEntity.hbm.xml" };
}
@@ -29,6 +30,6 @@
}
public static Test suite() {
- return new TestSuite( TriggerGeneratedValuesWithCachingTest.class );
+ return new FunctionalTestClassTestSuite( TriggerGeneratedValuesWithCachingTest.class );
}
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/generated/TriggerGeneratedValuesWithoutCachingTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/generated/TriggerGeneratedValuesWithoutCachingTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/generated/TriggerGeneratedValuesWithoutCachingTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,12 +1,12 @@
// $Id$
package org.hibernate.test.generated;
+import junit.framework.Test;
+
+import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.Oracle9Dialect;
-import org.hibernate.dialect.Dialect;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
/**
* Implementation of TriggerGeneratedValuesWithoutCachingTest.
*
@@ -18,7 +18,7 @@
super( x );
}
- protected final String[] getMappings() {
+ public final String[] getMappings() {
return new String[] { "generated/GeneratedPropertyEntity.hbm.xml" };
}
@@ -33,6 +33,6 @@
}
public static Test suite() {
- return new TestSuite( TriggerGeneratedValuesWithoutCachingTest.class );
+ return new FunctionalTestClassTestSuite( TriggerGeneratedValuesWithoutCachingTest.class );
}
}
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/generatedkeys/GeneratedKeysSuite.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/generatedkeys/GeneratedKeysSuite.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/generatedkeys/GeneratedKeysSuite.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,23 @@
+package org.hibernate.test.generatedkeys;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.hibernate.test.generatedkeys.identity.IdentityGeneratedKeysTest;
+import org.hibernate.test.generatedkeys.select.SelectGeneratorTest;
+import org.hibernate.test.generatedkeys.seqidentity.SequenceIdentityTest;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class GeneratedKeysSuite {
+ public static Test suite() {
+ TestSuite suite = new TestSuite( "generated keys suite" );
+ suite.addTest( IdentityGeneratedKeysTest.suite() );
+ suite.addTest( SelectGeneratorTest.suite() );
+ suite.addTest( SequenceIdentityTest.suite() );
+ return suite;
+ }
+}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/generatedkeys/identity/IdentityGeneratedKeysTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/generatedkeys/identity/IdentityGeneratedKeysTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/generatedkeys/identity/IdentityGeneratedKeysTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,27 +1,28 @@
package org.hibernate.test.generatedkeys.identity;
-import org.hibernate.test.DatabaseSpecificTestCase;
-import org.hibernate.dialect.Dialect;
+import junit.framework.Test;
+
import org.hibernate.Session;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.junit.functional.DatabaseSpecificFunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Steve Ebersole
*/
-public class IdentityGeneratedKeysTest extends DatabaseSpecificTestCase {
+public class IdentityGeneratedKeysTest extends DatabaseSpecificFunctionalTestCase {
public IdentityGeneratedKeysTest(String name) {
super( name );
}
- protected void configure(Configuration cfg) {
+ public void configure(Configuration cfg) {
super.configure( cfg );
cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "generatedkeys/identity/MyEntity.hbm.xml" };
}
@@ -30,7 +31,7 @@
}
public static Test suite() {
- return new TestSuite( IdentityGeneratedKeysTest.class );
+ return new FunctionalTestClassTestSuite( IdentityGeneratedKeysTest.class );
}
public void testIdentityColumnGeneratedIds() {
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/generatedkeys/select/SelectGeneratorTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/generatedkeys/select/SelectGeneratorTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/generatedkeys/select/SelectGeneratorTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,40 +1,34 @@
package org.hibernate.test.generatedkeys.select;
-import org.hibernate.test.DatabaseSpecificTestCase;
+import junit.framework.Test;
+
import org.hibernate.Session;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.dialect.Oracle9Dialect;
-import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.DataDirectOracle9Dialect;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.dialect.Oracle9Dialect;
+import org.hibernate.junit.functional.DatabaseSpecificFunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Steve Ebersole
*/
-public class SelectGeneratorTest extends DatabaseSpecificTestCase {
+public class SelectGeneratorTest extends DatabaseSpecificFunctionalTestCase {
public SelectGeneratorTest(String x) {
super( x );
}
// TODO : need to determine appropriate physical generation strategies for select-generator testing on other databases...
- protected void configure(Configuration cfg) {
- super.configure( cfg );
+ public String[] getMappings() {
+ return new String[] { "generatedkeys/select/MyEntity.hbm.xml" };
}
public boolean appliesTo(Dialect dialect) {
return ( dialect instanceof Oracle9Dialect );
}
- protected String[] getMappings() {
- return new String[] {
- "generatedkeys/select/MyEntity.hbm.xml"
- };
- }
-
public static Test suite() {
- return new TestSuite( SelectGeneratorTest.class );
+ return new FunctionalTestClassTestSuite( SelectGeneratorTest.class );
}
public void testJDBC3GetGeneratedKeysSupportOnOracle() {
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/generatedkeys/seqidentity/SequenceIdentityTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/generatedkeys/seqidentity/SequenceIdentityTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/generatedkeys/seqidentity/SequenceIdentityTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,23 +1,24 @@
package org.hibernate.test.generatedkeys.seqidentity;
-import org.hibernate.test.DatabaseSpecificTestCase;
+import junit.framework.Test;
+
import org.hibernate.Session;
import org.hibernate.cfg.Configuration;
-import org.hibernate.dialect.Oracle9Dialect;
-import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.DataDirectOracle9Dialect;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.dialect.Oracle9Dialect;
+import org.hibernate.junit.functional.DatabaseSpecificFunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Steve Ebersole
*/
-public class SequenceIdentityTest extends DatabaseSpecificTestCase {
+public class SequenceIdentityTest extends DatabaseSpecificFunctionalTestCase {
public SequenceIdentityTest(String x) {
super( x );
}
- protected void configure(Configuration cfg) {
+ public void configure(Configuration cfg) {
super.configure( cfg );
}
@@ -27,14 +28,12 @@
return ( dialect instanceof Oracle9Dialect ) && ( ! ( dialect instanceof DataDirectOracle9Dialect ) ) ;
}
- protected String[] getMappings() {
- return new String[] {
- "generatedkeys/seqidentity/MyEntity.hbm.xml"
- };
+ public String[] getMappings() {
+ return new String[] { "generatedkeys/seqidentity/MyEntity.hbm.xml" };
}
public static Test suite() {
- return new TestSuite( SequenceIdentityTest.class );
+ return new FunctionalTestClassTestSuite( SequenceIdentityTest.class );
}
public void testSequenceIdentityGenerator() {
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/ASTParserLoadingTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/ASTParserLoadingTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/ASTParserLoadingTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -13,7 +13,6 @@
import java.util.Map;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.HibernateException;
@@ -23,31 +22,32 @@
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.TypeMismatchException;
-import org.hibernate.hql.ast.tree.DotNode;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.DB2Dialect;
import org.hibernate.dialect.HSQLDialect;
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.dialect.Oracle9Dialect;
+import org.hibernate.dialect.PostgreSQLDialect;
import org.hibernate.dialect.SQLServerDialect;
import org.hibernate.dialect.SybaseDialect;
-import org.hibernate.dialect.PostgreSQLDialect;
+import org.hibernate.hql.ast.ASTQueryTranslatorFactory;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.stat.QueryStatistics;
-import org.hibernate.test.TestCase;
+import org.hibernate.test.any.IntegerPropertyValue;
+import org.hibernate.test.any.PropertySet;
import org.hibernate.test.any.PropertyValue;
import org.hibernate.test.any.StringPropertyValue;
-import org.hibernate.test.any.IntegerPropertyValue;
-import org.hibernate.test.any.PropertySet;
import org.hibernate.test.cid.Customer;
import org.hibernate.test.cid.LineItem;
import org.hibernate.test.cid.Order;
import org.hibernate.test.cid.Product;
import org.hibernate.transform.DistinctRootEntityResultTransformer;
import org.hibernate.transform.Transformers;
+import org.hibernate.type.ComponentType;
import org.hibernate.type.ManyToOneType;
import org.hibernate.type.Type;
-import org.hibernate.type.ComponentType;
import org.hibernate.util.StringHelper;
/**
@@ -60,21 +60,15 @@
*
* @author Steve
*/
-public class ASTParserLoadingTest extends TestCase {
+public class ASTParserLoadingTest extends FunctionalTestCase {
+ private List createdAnimalIds = new ArrayList();
+
public ASTParserLoadingTest(String name) {
super( name );
}
- private List createdAnimalIds = new ArrayList();
-
- public static Test suite() {
- return new TestSuite( ASTParserLoadingTest.class );
- }
-
- protected String[] getMappings() {
- // Make sure we are using the new AST parser translator...
- System.setProperty( Environment.QUERY_TRANSLATOR, "org.hibernate.hql.ast.ASTQueryTranslatorFactory" );
+ public String[] getMappings() {
return new String[] {
"hql/Animal.hbm.xml",
"hql/FooBarCopy.hbm.xml",
@@ -91,12 +85,17 @@
};
}
- protected void configure(Configuration cfg) {
+ public void configure(Configuration cfg) {
super.configure( cfg );
cfg.setProperty( Environment.USE_QUERY_CACHE, "true" );
cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
+ cfg.setProperty( Environment.QUERY_TRANSLATOR, ASTQueryTranslatorFactory.class.getName() );
}
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( ASTParserLoadingTest.class );
+ }
+
/**
* Copied from {@link HQLTest#testConcatenation}
*/
@@ -117,7 +116,10 @@
s.beginTransaction();
s.createQuery( "from Animal a where abs(a.bodyWeight-:param) < 2.0" ).setLong( "param", 1 ).list();
s.createQuery( "from Animal a where abs(:param - a.bodyWeight) < 2.0" ).setLong( "param", 1 ).list();
- s.createQuery( "from Animal where abs(:x - :y) < 2.0" ).setLong( "x", 1 ).setLong( "y", 1 ).list();
+ if ( ! ( getDialect() instanceof HSQLDialect ) ) {
+ // HSQLDB does not like the abs(? - ?) syntax...
+ s.createQuery( "from Animal where abs(:x - :y) < 2.0" ).setLong( "x", 1 ).setLong( "y", 1 ).list();
+ }
s.createQuery( "from Animal where lower(upper(:foo)) like 'f%'" ).setString( "foo", "foo" ).list();
s.createQuery( "from Animal a where abs(abs(a.bodyWeight - 1.0 + :param) * abs(length('ffobar')-3)) = 3.0" ).setLong( "param", 1 ).list();
s.createQuery( "from Animal where lower(upper('foo') || upper(:bar)) like 'f%'" ).setString( "bar", "xyz" ).list();
@@ -155,7 +157,7 @@
results = s.createQuery( "select e.heresAnotherCrazyIdFieldName from MoreCrazyIdFieldNameStuffEntity e" ).list();
assertEquals( 1, results.size() );
Iterator itr = s.createQuery( "select e.heresAnotherCrazyIdFieldName from MoreCrazyIdFieldNameStuffEntity e" ).iterate();
- assertEquals( 1, determineCount( itr ) );
+ assertTrue( itr.hasNext() ); itr.next(); assertFalse( itr.hasNext() );
s.delete( top );
s.delete( next );
@@ -760,7 +762,7 @@
t.commit();
s.close();
}
-
+
public void testSelectClauseSubselect() {
Session s = openSession();
Transaction t = s.beginTransaction();
@@ -777,7 +779,7 @@
zoo.getAnimals().put("plat123", plat);
s.persist( plat );
s.persist(zoo);
-
+
s.createQuery("select (select max(z.id) from a.zoo z) from Animal a").list();
s.createQuery("select (select max(z.id) from a.zoo z where z.name=:name) from Animal a")
.setParameter("name", "Melbourne Zoo").list();
@@ -920,7 +922,7 @@
bw.toString();
s.delete(a);
t.commit();
- s.close();
+ s.close();
}
public void testAliases() {
@@ -938,7 +940,7 @@
assertEquals(aliases2[1], "avg");
s.delete(a);
t.commit();
- s.close();
+ s.close();
}
public void testParameterMixing() {
@@ -995,9 +997,9 @@
.setParameter("country", "Australia")
.list();*/
t.commit();
- s.close();
+ s.close();
}
-
+
public void testAggregation() {
Session s = openSession();
Transaction t = s.beginTransaction();
@@ -1017,7 +1019,7 @@
t.commit();
s.close();
}
-
+
public void testSelectClauseCase() {
Session s = openSession();
Transaction t = s.beginTransaction();
@@ -1050,28 +1052,28 @@
List list = s.createQuery("from java.lang.Comparable").list();
assertEquals( list.size(), 0 );
-
+
list = s.createQuery("from java.lang.Object").list();
assertEquals( list.size(), 1 );
-
+
s.delete(product);
-
+
list = s.createQuery("from java.lang.Object").list();
assertEquals( list.size(), 0 );
-
+
t.commit();
s.close();
}
-
+
public void testCoalesce() {
Session session = openSession();
Transaction txn = session.beginTransaction();
session.createQuery("from Human h where coalesce(h.nickName, h.name.first, h.name.last) = 'max'").list();
session.createQuery("select nullif(nickName, '1e1') from Human").list();
txn.commit();
- session.close();
+ session.close();
}
-
+
public void testStr() {
Session session = openSession();
Transaction txn = session.beginTransaction();
@@ -1108,9 +1110,9 @@
}
session.delete(an);
txn.commit();
- session.close();
+ session.close();
}
-
+
public void testCast() {
if ( ( getDialect() instanceof MySQLDialect ) || ( getDialect() instanceof DB2Dialect ) ) {
return;
@@ -1121,9 +1123,9 @@
session.createQuery("from Animal a where cast(a.bodyWeight as string) like '1.%'").list();
session.createQuery("from Animal a where cast(a.bodyWeight as integer) = 1").list();
txn.commit();
- session.close();
+ session.close();
}
-
+
public void testExtract() {
Session session = openSession();
Transaction txn = session.beginTransaction();
@@ -1134,7 +1136,7 @@
session.createQuery("select extract(day from m.birthdate), extract(month from m.birthdate), extract(year from m.birthdate) from Mammal m").list();
}
txn.commit();
- session.close();
+ session.close();
}
public void testOneToManyFilter() throws Throwable {
@@ -1166,7 +1168,7 @@
assertEquals( session.createFilter( order.getLineItems(), "" ).list().size(), 1 );
assertEquals( session.createFilter( order.getLineItems(), "where this.quantity > :quantity" ).setInteger( "quantity", 5 ).list().size(), 0 );
-
+
session.delete(li);
session.delete(order);
session.delete(product);
@@ -1204,14 +1206,14 @@
assertEquals( session.createFilter( human.getFriends(), "" ).list().size(), 1 );
assertEquals( session.createFilter( human.getFriends(), "where this.bodyWeight > ?" ).setFloat( 0, 10f ).list().size(), 1 );
assertEquals( session.createFilter( human.getFriends(), "where this.bodyWeight < ?" ).setFloat( 0, 10f ).list().size(), 0 );
-
+
session.delete(human);
session.delete(friend);
-
+
txn.commit();
session.close();
}
-
+
public void testSelectExpressions() {
createTestBaseData();
Session session = openSession();
@@ -1281,7 +1283,7 @@
txn.commit();
session.close();
}
-
+
public void testImplicitJoin() throws Exception {
Session session = openSession();
Transaction t = session.beginTransaction();
@@ -1444,7 +1446,7 @@
destroyTestBaseData();
}
-
+
public void testStandardFunctions() throws Exception {
Session session = openSession();
Transaction t = session.beginTransaction();
@@ -1465,7 +1467,7 @@
session.delete(p);
t.commit();
session.close();
-
+
}
public void testDynamicInstantiationQueries() throws Exception {
@@ -1477,11 +1479,11 @@
List results = session.createQuery( "select new Animal(an.description, an.bodyWeight) from Animal an" ).list();
assertEquals( "Incorrect result size", 2, results.size() );
assertClassAssignability( results.get( 0 ).getClass(), Animal.class );
-
+
Iterator iter = session.createQuery( "select new Animal(an.description, an.bodyWeight) from Animal an" ).iterate();
assertTrue( "Incorrect result size", iter.hasNext() );
- assertTrue( "Incorrect return type", iter.next() instanceof Animal );
-
+ assertTrue( "Incorrect return type", iter.next() instanceof Animal );
+
results = session.createQuery( "select new list(an.description, an.bodyWeight) from Animal an" ).list();
assertEquals( "Incorrect result size", 2, results.size() );
assertTrue( "Incorrect return type", results.get( 0 ) instanceof List );
@@ -1497,13 +1499,13 @@
Object obj = iter.next();
assertTrue( "Incorrect return type", obj instanceof List );
assertEquals( "Incorrect return type", ( (List) obj ).size(), 2 );
-
+
iter = ((org.hibernate.classic.Session)session).iterate( "select new list(an.description, an.bodyWeight) from Animal an" );
assertTrue( "Incorrect result size", iter.hasNext() );
obj = iter.next();
assertTrue( "Incorrect return type", obj instanceof List );
assertEquals( "Incorrect return type", ( (List) obj ).size(), 2 );
-
+
results = session.createQuery( "select new map(an.description, an.bodyWeight) from Animal an" ).list();
assertEquals( "Incorrect result size", 2, results.size() );
assertTrue( "Incorrect return type", results.get( 0 ) instanceof Map );
@@ -1523,19 +1525,19 @@
obj = iter.next();
assertTrue( "Incorrect return type", obj instanceof Map );
assertEquals( "Incorrect return type", ( (Map) obj ).size(), 2 );
-
+
ScrollableResults sr = session.createQuery( "select new map(an.description, an.bodyWeight) from Animal an" ).scroll();
assertTrue( "Incorrect result size", sr.next() );
obj = sr.get(0);
assertTrue( "Incorrect return type", obj instanceof Map );
assertEquals( "Incorrect return type", ( (Map) obj ).size(), 2 );
sr.close();
-
+
sr = session.createQuery( "select new Animal(an.description, an.bodyWeight) from Animal an" ).scroll();
assertTrue( "Incorrect result size", sr.next() );
assertTrue( "Incorrect return type", sr.get(0) instanceof Animal );
sr.close();
-
+
// caching...
QueryStatistics stats = getSessions().getStatistics().getQueryStatistics( "select new Animal(an.description, an.bodyWeight) from Animal an" );
results = session.createQuery( "select new Animal(an.description, an.bodyWeight) from Animal an" )
@@ -1558,28 +1560,28 @@
public void testIllegalMixedTransformerQueries() {
Session session = openSession();
-
+
try {
getSelectNewQuery( session ).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP).list();
fail("'select new' together with a resulttransformer should result in error!");
} catch(QueryException he) {
assertTrue(he.getMessage().indexOf("ResultTransformer")==0);
}
-
+
try {
getSelectNewQuery( session ).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP).iterate();
fail("'select new' together with a resulttransformer should result in error!");
} catch(HibernateException he) {
assertTrue(he.getMessage().indexOf("ResultTransformer")==0);
}
-
+
try {
getSelectNewQuery( session ).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP).scroll();
fail("'select new' together with a resulttransformer should result in error!");
} catch(HibernateException he) {
assertTrue(he.getMessage().indexOf("ResultTransformer")==0);
}
-
+
session.close();
}
@@ -1593,10 +1595,10 @@
String query = "select an.description as description, an.bodyWeight as bodyWeight from Animal an order by bodyWeight desc";
Session session = openSession();
-
+
List results = session.createQuery( query )
.setResultTransformer(Transformers.aliasToBean(Animal.class)).list();
- assertEquals( "Incorrect result size", results.size(), 2 );
+ assertEquals( "Incorrect result size", results.size(), 2 );
assertTrue( "Incorrect return type", results.get(0) instanceof Animal );
Animal firstAnimal = (Animal) results.get(0);
Animal secondAnimal = (Animal) results.get(1);
@@ -1604,41 +1606,41 @@
assertEquals("Mammal #2", secondAnimal.getDescription());
assertFalse(session.contains(firstAnimal));
session.close();
-
+
session = openSession();
-
+
Iterator iter = session.createQuery( query )
.setResultTransformer(Transformers.aliasToBean(Animal.class)).iterate();
assertTrue( "Incorrect result size", iter.hasNext() );
- assertTrue( "Incorrect return type", iter.next() instanceof Animal );
+ assertTrue( "Incorrect return type", iter.next() instanceof Animal );
session.close();
-
+
session = openSession();
-
+
ScrollableResults sr = session.createQuery( query )
.setResultTransformer(Transformers.aliasToBean(Animal.class)).scroll();
assertTrue( "Incorrect result size", sr.next() );
assertTrue( "Incorrect return type", sr.get(0) instanceof Animal );
assertFalse(session.contains(sr.get(0)));
sr.close();
-
+
session.close();
-
+
session = openSession();
results = session.createQuery( "select a from Animal a, Animal b order by a.id" )
.setResultTransformer(new DistinctRootEntityResultTransformer())
.list();
- assertEquals( "Incorrect result size", 2, results.size());
+ assertEquals( "Incorrect result size", 2, results.size());
assertTrue( "Incorrect return type", results.get(0) instanceof Animal );
firstAnimal = (Animal) results.get(0);
secondAnimal = (Animal) results.get(1);
assertEquals("Mammal #1", firstAnimal.getDescription());
assertEquals("Mammal #2", secondAnimal.getDescription());
-
+
session.close();
-
+
destroyTestBaseData();
}
@@ -1649,10 +1651,10 @@
String query = "select an as an from Animal an order by bodyWeight desc";
Session session = openSession();
-
+
List results = session.createQuery( query )
.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP).list();
- assertEquals( "Incorrect result size", results.size(), 2 );
+ assertEquals( "Incorrect result size", results.size(), 2 );
assertTrue( "Incorrect return type", results.get(0) instanceof Map );
Map map = ((Map) results.get(0));
assertEquals(1, map.size());
@@ -1664,9 +1666,9 @@
assertTrue(session.contains(firstAnimal));
assertSame(firstAnimal, session.get(Animal.class,firstAnimal.getId()));
session.close();
-
+
session = openSession();
-
+
Iterator iter = session.createQuery( query )
.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP).iterate();
assertTrue( "Incorrect result size", iter.hasNext() );
@@ -1674,20 +1676,20 @@
firstAnimal = (Animal) map.get("an");
assertEquals("Mammal #1", firstAnimal.getDescription());
assertTrue( "Incorrect result size", iter.hasNext() );
-
+
session.close();
-
+
session = openSession();
-
+
ScrollableResults sr = session.createQuery( query )
.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP).scroll();
assertTrue( "Incorrect result size", sr.next() );
assertTrue( "Incorrect return type", sr.get(0) instanceof Map );
assertFalse(session.contains(sr.get(0)));
sr.close();
-
+
session.close();
-
+
destroyTestBaseData();
}
@@ -1720,7 +1722,7 @@
hql = "select length(a.description) from Animal a";
session.createQuery(hql).list();
-
+
//note: postgres and db2 don't have a 3-arg form, it gets transformed to 2-args
hql = "from Animal a where locate('abc', a.description, 2) = 2";
session.createQuery(hql).list();
@@ -1730,7 +1732,7 @@
hql = "select locate('cat', a.description, 2) from Animal a";
session.createQuery(hql).list();
-
+
if ( !( getDialect() instanceof DB2Dialect ) ) {
hql = "from Animal a where trim(trailing '_' from a.description) = 'cat'";
session.createQuery(hql).list();
@@ -1778,20 +1780,20 @@
hql = "from Animal a where a.description like 'x%ax%' escape 'x'";
session.createQuery(hql).list();
-
+
session.close();
}
public void testSubselectBetween() {
- if(supportsSubselectOnLeftSideIn()) {
- assertResultSize("from Animal x where (select max(a.bodyWeight) from Animal a) in (1,2,3)", 0);
- assertResultSize("from Animal x where (select max(a.bodyWeight) from Animal a) between 0 and 100", 0);
- assertResultSize("from Animal x where (select max(a.description) from Animal a) like 'big%'", 0);
- assertResultSize("from Animal x where (select max(a.bodyWeight) from Animal a) is not null", 0);
+ if ( supportsSubselectOnLeftSideIn() ) {
+ assertResultSize( "from Animal x where (select max(a.bodyWeight) from Animal a) in (1,2,3)", 0 );
+ assertResultSize( "from Animal x where (select max(a.bodyWeight) from Animal a) between 0 and 100", 0 );
+ assertResultSize( "from Animal x where (select max(a.description) from Animal a) like 'big%'", 0 );
+ assertResultSize( "from Animal x where (select max(a.bodyWeight) from Animal a) is not null", 0 );
}
- assertResultSize("from Animal x where exists (select max(a.bodyWeight) from Animal a)", 0);
+ assertResultSize( "from Animal x where exists (select max(a.bodyWeight) from Animal a)", 0 );
}
-
+
private void assertResultSize(String hql, int size) {
Session session = openSession();
Transaction txn = session.beginTransaction();
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/BulkManipulationTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/BulkManipulationTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/BulkManipulationTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,12 +1,11 @@
// $Id$
package org.hibernate.test.hql;
+import java.util.ArrayList;
import java.util.Date;
import java.util.List;
-import java.util.ArrayList;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.QueryException;
import org.hibernate.Transaction;
@@ -14,8 +13,9 @@
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.hql.ast.HqlSqlWalker;
import org.hibernate.id.IdentifierGenerator;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.persister.entity.EntityPersister;
-import org.hibernate.test.TestCase;
/**
@@ -23,17 +23,17 @@
*
* @author Steve Ebersole
*/
-public class BulkManipulationTest extends TestCase {
+public class BulkManipulationTest extends FunctionalTestCase {
public BulkManipulationTest(String name) {
super( name );
}
public static Test suite() {
- return new TestSuite( BulkManipulationTest.class );
+ return new FunctionalTestClassTestSuite( BulkManipulationTest.class );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] {
"hql/Animal.hbm.xml",
"hql/Vehicle.hbm.xml",
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/ClassicTranslatorTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/ClassicTranslatorTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/ClassicTranslatorTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,11 +1,12 @@
package org.hibernate.test.hql;
+import junit.framework.Test;
+
+import org.hibernate.Session;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.hql.classic.ClassicQueryTranslatorFactory;
-import org.hibernate.Session;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* Some simple test queries using the classic translator explicitly
@@ -13,7 +14,7 @@
* <p/>
* Only really checking translation and syntax, not results.
*
- * @author <a href="mailto:steve@hibernate.org">Steve Ebersole </a>
+ * @author Steve Ebersole
*/
public class ClassicTranslatorTest extends QueryTranslatorTestCase {
@@ -22,15 +23,21 @@
}
public static Test suite() {
- return new TestSuite( ClassicTranslatorTest.class );
+ return new FunctionalTestClassTestSuite( ClassicTranslatorTest.class );
}
- protected boolean recreateSchema() {
+ public void configure(Configuration cfg) {
+ super.configure( cfg );
+ cfg.setProperty( Environment.QUERY_TRANSLATOR, ClassicQueryTranslatorFactory.class.getName() );
+ }
+
+
+ public boolean createSchema() {
return true;
}
- protected void configure(Configuration cfg) {
- cfg.setProperty( Environment.QUERY_TRANSLATOR, ClassicQueryTranslatorFactory.class.getName() );
+ public boolean recreateSchemaAfterFailure() {
+ return true;
}
public void testQueries() {
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/CriteriaClassicAggregationReturnTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/CriteriaClassicAggregationReturnTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/CriteriaClassicAggregationReturnTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,107 @@
+package org.hibernate.test.hql;
+
+import java.util.Collections;
+
+import junit.framework.Test;
+
+import org.hibernate.cfg.Configuration;
+import org.hibernate.dialect.function.ClassicCountFunction;
+import org.hibernate.dialect.function.ClassicAvgFunction;
+import org.hibernate.dialect.function.ClassicSumFunction;
+import org.hibernate.hql.ast.QueryTranslatorImpl;
+import org.hibernate.hql.QueryTranslator;
+import org.hibernate.hql.QueryTranslatorFactory;
+import org.hibernate.hql.classic.ClassicQueryTranslatorFactory;
+import org.hibernate.Hibernate;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class CriteriaClassicAggregationReturnTest extends QueryTranslatorTestCase {
+
+ public CriteriaClassicAggregationReturnTest(String x) {
+ super( x );
+ }
+
+ public void configure(Configuration cfg) {
+ super.configure( cfg );
+ cfg.addSqlFunction( "count", new ClassicCountFunction() );
+ cfg.addSqlFunction( "avg", new ClassicAvgFunction() );
+ cfg.addSqlFunction( "sum", new ClassicSumFunction() );
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( CriteriaClassicAggregationReturnTest.class );
+ }
+
+ public void testClassicHQLAggregationReturnTypes() {
+ // EJB3: COUNT returns Long
+ QueryTranslatorImpl translator = createNewQueryTranslator( "select count(*) from Human h", sfi() );
+ assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
+ assertEquals( "incorrect return type", Hibernate.INTEGER, translator.getReturnTypes()[0] );
+
+ translator = createNewQueryTranslator( "select count(h.height) from Human h", sfi() );
+ assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
+ assertEquals( "incorrect return type", Hibernate.INTEGER, translator.getReturnTypes()[0] );
+
+ // MAX, MIN return the type of the state-field to which they are applied.
+ translator = createNewQueryTranslator( "select max(h.height) from Human h", sfi() );
+ assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
+ assertEquals( "incorrect return type", Hibernate.DOUBLE, translator.getReturnTypes()[0] );
+
+ translator = createNewQueryTranslator( "select max(h.id) from Human h", sfi() );
+ assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
+ assertEquals( "incorrect return type", Hibernate.LONG, translator.getReturnTypes()[0] );
+
+ // AVG returns Float integrals, and otherwise the field type.
+ translator = createNewQueryTranslator( "select avg(h.height) from Human h", sfi() );
+ assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
+ assertEquals( "incorrect return type", Hibernate.DOUBLE, translator.getReturnTypes()[0] );
+
+ translator = createNewQueryTranslator( "select avg(h.id) from Human h", sfi() );
+ assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
+ assertEquals( "incorrect return type", Hibernate.FLOAT, translator.getReturnTypes()[0] );
+
+ translator = createNewQueryTranslator( "select avg(h.bigIntegerValue) from Human h", sfi() );
+ assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
+ assertEquals( "incorrect return type", Hibernate.BIG_INTEGER, translator.getReturnTypes()[0] );
+
+ // SUM returns underlying type sum
+ translator = createNewQueryTranslator( "select sum(h.id) from Human h", sfi() );
+ assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
+ assertEquals( "incorrect return type", Hibernate.LONG, translator.getReturnTypes()[0] );
+
+ translator = createNewQueryTranslator( "select sum(h.intValue) from Human h", sfi() );
+ assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
+ assertEquals( "incorrect return type", Hibernate.INTEGER, translator.getReturnTypes()[0] );
+
+ translator = createNewQueryTranslator( "select sum(h.height) from Human h", sfi() );
+ assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
+ assertEquals( "incorrect return type", Hibernate.DOUBLE, translator.getReturnTypes()[0] );
+
+ translator = createNewQueryTranslator( "select sum(h.floatValue) from Human h", sfi() );
+ assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
+ assertEquals( "incorrect return type", Hibernate.FLOAT, translator.getReturnTypes()[0] );
+
+ translator = createNewQueryTranslator( "select sum(h.bigIntegerValue) from Human h", sfi() );
+ assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
+ assertEquals( "incorrect return type", Hibernate.BIG_INTEGER, translator.getReturnTypes()[0] );
+
+ translator = createNewQueryTranslator( "select sum(h.bigDecimalValue) from Human h", sfi() );
+ assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
+ assertEquals( "incorrect return type", Hibernate.BIG_DECIMAL, translator.getReturnTypes()[0] );
+
+ // special case to test classicquery special case handling of count(*)
+ QueryTranslator oldQueryTranslator = null;
+ String hql = "select count(*) from Human h";
+ QueryTranslatorFactory classic = new ClassicQueryTranslatorFactory();
+ oldQueryTranslator = classic.createQueryTranslator( hql, hql, Collections.EMPTY_MAP, sfi() );
+ oldQueryTranslator.compile( Collections.EMPTY_MAP, true);
+ assertEquals( "incorrect return type count", 1, oldQueryTranslator.getReturnTypes().length );
+ assertEquals( "incorrect return type", Hibernate.INTEGER, oldQueryTranslator.getReturnTypes()[0] );
+
+ }
+}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/CriteriaHQLAlignmentTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/CriteriaHQLAlignmentTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/CriteriaHQLAlignmentTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -6,18 +6,11 @@
import java.util.Collections;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
-import org.hibernate.MappingException;
-import org.hibernate.QueryException;
-import org.hibernate.cfg.Configuration;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.classic.Session;
import org.hibernate.criterion.Projections;
-import org.hibernate.dialect.function.ClassicAvgFunction;
-import org.hibernate.dialect.function.ClassicCountFunction;
-import org.hibernate.dialect.function.ClassicSumFunction;
-import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.hql.QueryTranslator;
import org.hibernate.hql.QueryTranslatorFactory;
import org.hibernate.hql.ast.QueryTranslatorImpl;
@@ -36,14 +29,18 @@
SelectClause.VERSION2_SQL = true;
}
- protected boolean dropAfterFailure() {
+ public boolean createSchema() {
+ return true; // needed for the Criteria return type test
+ }
+
+ public boolean recreateSchemaAfterFailure() {
return true;
}
- protected boolean recreateSchema() {
- return true; // needed for the Criteria return type test
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( CriteriaHQLAlignmentTest.class );
}
-
+
public void testHQLAggregationReturnType() {
// EJB3: COUNT returns Long
QueryTranslatorImpl translator = createNewQueryTranslator( "select count(*) from Human h" );
@@ -173,84 +170,4 @@
s.close();
}
- public void testClassicHQLAggregationReturnTypes() {
- Configuration classicCfg = new Configuration();
- classicCfg.addSqlFunction( "count", new ClassicCountFunction());
- classicCfg.addSqlFunction( "avg", new ClassicAvgFunction());
- classicCfg.addSqlFunction( "sum", new ClassicSumFunction());
-
- addMappings(getMappings(), classicCfg);
- SessionFactoryImplementor factory = (SessionFactoryImplementor) classicCfg.buildSessionFactory();
-
- // EJB3: COUNT returns Long
- QueryTranslatorImpl translator = createNewQueryTranslator( "select count(*) from Human h", factory );
- assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
- assertEquals( "incorrect return type", Hibernate.INTEGER, translator.getReturnTypes()[0] );
-
- translator = createNewQueryTranslator( "select count(h.height) from Human h", factory );
- assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
- assertEquals( "incorrect return type", Hibernate.INTEGER, translator.getReturnTypes()[0] );
-
- // MAX, MIN return the type of the state-field to which they are applied.
- translator = createNewQueryTranslator( "select max(h.height) from Human h", factory );
- assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
- assertEquals( "incorrect return type", Hibernate.DOUBLE, translator.getReturnTypes()[0] );
-
- translator = createNewQueryTranslator( "select max(h.id) from Human h", factory );
- assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
- assertEquals( "incorrect return type", Hibernate.LONG, translator.getReturnTypes()[0] );
-
- // AVG returns Float integrals, and otherwise the field type.
- translator = createNewQueryTranslator( "select avg(h.height) from Human h", factory );
- assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
- assertEquals( "incorrect return type", Hibernate.DOUBLE, translator.getReturnTypes()[0] );
-
- translator = createNewQueryTranslator( "select avg(h.id) from Human h", factory );
- assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
- assertEquals( "incorrect return type", Hibernate.FLOAT, translator.getReturnTypes()[0] );
-
- translator = createNewQueryTranslator( "select avg(h.bigIntegerValue) from Human h", factory );
- assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
- assertEquals( "incorrect return type", Hibernate.BIG_INTEGER, translator.getReturnTypes()[0] );
-
- // SUM returns underlying type sum
- translator = createNewQueryTranslator( "select sum(h.id) from Human h", factory );
- assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
- assertEquals( "incorrect return type", Hibernate.LONG, translator.getReturnTypes()[0] );
-
- translator = createNewQueryTranslator( "select sum(h.intValue) from Human h", factory );
- assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
- assertEquals( "incorrect return type", Hibernate.INTEGER, translator.getReturnTypes()[0] );
-
- translator = createNewQueryTranslator( "select sum(h.height) from Human h", factory );
- assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
- assertEquals( "incorrect return type", Hibernate.DOUBLE, translator.getReturnTypes()[0] );
-
- translator = createNewQueryTranslator( "select sum(h.floatValue) from Human h", factory );
- assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
- assertEquals( "incorrect return type", Hibernate.FLOAT, translator.getReturnTypes()[0] );
-
- translator = createNewQueryTranslator( "select sum(h.bigIntegerValue) from Human h", factory );
- assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
- assertEquals( "incorrect return type", Hibernate.BIG_INTEGER, translator.getReturnTypes()[0] );
-
- translator = createNewQueryTranslator( "select sum(h.bigDecimalValue) from Human h", factory );
- assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
- assertEquals( "incorrect return type", Hibernate.BIG_DECIMAL, translator.getReturnTypes()[0] );
-
- // special case to test classicquery special case handling of count(*)
- QueryTranslator oldQueryTranslator = null;
- String hql = "select count(*) from Human h";
- QueryTranslatorFactory classic = new ClassicQueryTranslatorFactory();
- oldQueryTranslator = classic.createQueryTranslator( hql, hql, Collections.EMPTY_MAP, factory );
- oldQueryTranslator.compile( Collections.EMPTY_MAP, true);
- assertEquals( "incorrect return type count", 1, oldQueryTranslator.getReturnTypes().length );
- assertEquals( "incorrect return type", Hibernate.INTEGER, oldQueryTranslator.getReturnTypes()[0] );
-
- }
-
- public static Test suite() {
- return new TestSuite( CriteriaHQLAlignmentTest.class );
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/EJBQLTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/EJBQLTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/EJBQLTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -18,6 +18,8 @@
import org.hibernate.hql.ast.QueryTranslatorImpl;
import org.hibernate.hql.ast.util.ASTUtil;
import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import antlr.RecognitionException;
import antlr.TokenStreamException;
@@ -27,13 +29,49 @@
/**
* @author <a href="mailto:alex@jboss.org">Alexey Loubyansky</a>
*/
-public class EJBQLTest
- extends TestCase {
+public class EJBQLTest extends FunctionalTestCase {
public EJBQLTest(String x) {
super( x );
}
+ public String[] getMappings() {
+ return new String[]{
+ "hql/Animal.hbm.xml",
+ "batchfetch/ProductLine.hbm.xml",
+ "cid/Customer.hbm.xml",
+ "cid/Order.hbm.xml",
+ "cid/LineItem.hbm.xml",
+ "cid/Product.hbm.xml",
+ "legacy/Glarch.hbm.xml",
+ "legacy/Fee.hbm.xml",
+ "legacy/Qux.hbm.xml",
+ "legacy/Fum.hbm.xml",
+ "legacy/Holder.hbm.xml",
+ "legacy/One.hbm.xml",
+ "legacy/FooBar.hbm.xml",
+ "legacy/Many.hbm.xml",
+ "legacy/Baz.hbm.xml",
+ "legacy/Simple.hbm.xml",
+ "legacy/Middle.hbm.xml",
+ "legacy/Category.hbm.xml",
+ "legacy/Multi.hbm.xml",
+ "legacy/Commento.hbm.xml",
+ "legacy/Marelo.hbm.xml",
+ "compositeelement/Parent.hbm.xml",
+ "legacy/Container.hbm.xml",
+ };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( EJBQLTest.class );
+ }
+
+
+ public boolean createSchema() {
+ return false;
+ }
+
public void testEjb3PositionalParameters() throws Exception {
QueryTranslatorImpl qt = compile( "from Animal a where a.bodyWeight = ?1" );
AST ast = ( AST ) qt.getSqlAST();
@@ -79,7 +117,7 @@
//parse(hql);
//parse(ejbql);
assertEjbqlEqualsHql(ejbql, hql);
-
+
hql = "from Animal a where exists (from a.mother.father.offspring)";
ejbql = "select object(a) from Animal a where a.mother.father.offspring is not empty";
assertEjbqlEqualsHql( ejbql, hql );
@@ -217,35 +255,26 @@
assertEjbqlEqualsHql( "from Human h where not(h.pregnant is true)", "from Human h where not( h.pregnant=true )" );
}
+
// Private
private void assertEjbqlEqualsHql(String ejbql, String hql) {
- SessionFactoryImplementor factory = getSessionFactoryImplementor();
QueryTranslatorFactory ast = new ASTQueryTranslatorFactory();
- QueryTranslator queryTranslator = ast.createQueryTranslator( hql, hql, Collections.EMPTY_MAP, factory );
+ QueryTranslator queryTranslator = ast.createQueryTranslator( hql, hql, Collections.EMPTY_MAP, sfi() );
queryTranslator.compile( Collections.EMPTY_MAP, true );
String hqlSql = queryTranslator.getSQLString();
- queryTranslator = ast.createQueryTranslator( ejbql, ejbql, Collections.EMPTY_MAP, factory );
+ queryTranslator = ast.createQueryTranslator( ejbql, ejbql, Collections.EMPTY_MAP, sfi() );
queryTranslator.compile( Collections.EMPTY_MAP, true );
String ejbqlSql = queryTranslator.getSQLString();
assertEquals( hqlSql, ejbqlSql );
}
- private void assertEjbqlEqualsSql(String sql, String hql) {
- SessionFactoryImplementor factory = getSessionFactoryImplementor();
- QueryTranslatorFactory ast = new ASTQueryTranslatorFactory();
- QueryTranslator queryTranslator = ast.createQueryTranslator( hql, hql, Collections.EMPTY_MAP, factory );
- queryTranslator.compile( Collections.EMPTY_MAP, true );
- assertEquals( sql, queryTranslator.getSQLString() );
- }
-
private QueryTranslatorImpl compile(String input) {
- SessionFactoryImplementor factory = getSessionFactoryImplementor();
QueryTranslatorFactory ast = new ASTQueryTranslatorFactory();
- QueryTranslator queryTranslator = ast.createQueryTranslator( input, input, Collections.EMPTY_MAP, factory );
+ QueryTranslator queryTranslator = ast.createQueryTranslator( input, input, Collections.EMPTY_MAP, sfi() );
queryTranslator.compile( Collections.EMPTY_MAP, true );
return ( QueryTranslatorImpl ) queryTranslator;
@@ -274,50 +303,9 @@
}
private String toSql(String hql) {
- SessionFactoryImplementor factory = getSessionFactoryImplementor();
QueryTranslatorFactory ast = new ASTQueryTranslatorFactory();
- QueryTranslator queryTranslator = ast.createQueryTranslator( hql, hql, Collections.EMPTY_MAP, factory );
+ QueryTranslator queryTranslator = ast.createQueryTranslator( hql, hql, Collections.EMPTY_MAP, sfi() );
queryTranslator.compile( Collections.EMPTY_MAP, true );
return queryTranslator.getSQLString();
}
-
- private SessionFactoryImplementor getSessionFactoryImplementor() {
- SessionFactoryImplementor factory = ( SessionFactoryImplementor ) getSessions();
- if ( factory == null ) {
- throw new NullPointerException( "Unable to create factory!" );
- }
- return factory;
- }
-
- protected String[] getMappings() {
- return new String[]{
- "hql/Animal.hbm.xml",
- "batchfetch/ProductLine.hbm.xml",
- "cid/Customer.hbm.xml",
- "cid/Order.hbm.xml",
- "cid/LineItem.hbm.xml",
- "cid/Product.hbm.xml",
- "legacy/Glarch.hbm.xml",
- "legacy/Fee.hbm.xml",
- "legacy/Qux.hbm.xml",
- "legacy/Fum.hbm.xml",
- "legacy/Holder.hbm.xml",
- "legacy/One.hbm.xml",
- "legacy/FooBar.hbm.xml",
- "legacy/Many.hbm.xml",
- "legacy/Baz.hbm.xml",
- "legacy/Simple.hbm.xml",
- "legacy/Middle.hbm.xml",
- "legacy/Category.hbm.xml",
- "legacy/Multi.hbm.xml",
- "legacy/Commento.hbm.xml",
- "legacy/Marelo.hbm.xml",
- "compositeelement/Parent.hbm.xml",
- "legacy/Container.hbm.xml",
- };
- }
-
- public static Test suite() {
- return new TestSuite( EJBQLTest.class );
- }
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/FooBarCopy.hbm.xml
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/FooBarCopy.hbm.xml 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/FooBarCopy.hbm.xml 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
+<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping default-lazy="false" package="org.hibernate.test.legacy">
@@ -66,9 +66,9 @@
<property name="nullBlob" type="serializable"/>
<property name="binary" column="bin_"/>
<property name="theLocale" access="field" column="`localeayzabc123`"/>
-
+
<property name="formula" formula="int_/2"/>
-
+
<property name="custom" type="org.hibernate.test.legacy.DoubleStringType" access="field">
<column name="first_name" length="66"/>
<column name="surname" length="66"/>
@@ -76,29 +76,29 @@
<component name="nullComponent">
<property name="name" column="null_cmpnt_"/>
</component>
-
+
<join table="jointable">
<key column="fooid" on-delete="cascade"/>
<property name="joinedProp"/>
</join>
-
+
<subclass
name="Trivial"
- proxy="FooProxy"
+ proxy="FooProxy"
discriminator-value="T"/>
-
- <subclass
- name="Abstract"
- proxy="AbstractProxy"
+
+ <subclass
+ name="Abstract"
+ proxy="AbstractProxy"
discriminator-value="null">
<set name="abstracts" batch-size="2">
<key column="abstract_id"/>
<one-to-many class="Abstract"/>
</set>
<property name="time" column="the_time"/>
-
- <subclass
- name="Bar"
+
+ <subclass
+ name="Bar"
proxy="BarProxy"
discriminator-value="B">
<property name="barString">
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/HQLSuite.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/HQLSuite.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/HQLSuite.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -23,6 +23,7 @@
suite.addTest( ScrollableCollectionFetchingTest.suite() );
suite.addTest( ClassicTranslatorTest.suite() );
suite.addTest( CriteriaHQLAlignmentTest.suite() );
+ suite.addTest( CriteriaClassicAggregationReturnTest.suite() );
return suite;
}
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/HQLTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/HQLTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/HQLTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -14,6 +14,7 @@
import junit.framework.TestSuite;
import org.hibernate.Hibernate;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.dialect.DB2Dialect;
import org.hibernate.dialect.HSQLDialect;
import org.hibernate.dialect.MySQLDialect;
@@ -50,16 +51,20 @@
return false;
}
- protected void setUp() throws Exception {
- super.setUp();
+ protected void prepareTest() throws Exception {
+ super.prepareTest();
SelectClause.VERSION2_SQL = true;
DotNode.REGRESSION_STYLE_JOIN_SUPPRESSION = true;
}
- protected void tearDown() throws Exception {
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( HQLTest.class );
+ }
+
+ protected void cleanupTest() throws Exception {
SelectClause.VERSION2_SQL = false;
DotNode.REGRESSION_STYLE_JOIN_SUPPRESSION = false;
- super.tearDown();
+ super.cleanupTest();
}
//FAILING TESTS:
@@ -181,7 +186,7 @@
assertTranslation("from Animal x where exists (select max(a.bodyWeight) from Animal a)");
assertTranslation("from Animal x where (select max(a.bodyWeight) from Animal a) in (1,2,3)");
}
-
+
public void testFetchOrderBy() {
assertTranslation("from Animal a left outer join fetch a.offspring where a.mother.id = :mid order by a.description");
}
@@ -192,7 +197,7 @@
assertTranslation("from Animal a join fetch a.offspring o order by o.description");
assertTranslation("from Animal a join a.offspring o order by a.description, o.description");
}
-
+
public void testExpressionWithParamInFunction() {
assertTranslation("from Animal a where abs(a.bodyWeight-:param) < 2.0");
assertTranslation("from Animal a where abs(:param - a.bodyWeight) < 2.0");
@@ -210,7 +215,7 @@
}
assertTranslation("from Animal where abs(cast(1 as float) - cast(:param as float)) = 1.0");
}
-
+
public void testCompositeKeysWithPropertyNamedId() {
assertTranslation( "select e.id.id from EntityWithCrazyCompositeKey e" );
assertTranslation( "select max(e.id.id) from EntityWithCrazyCompositeKey e" );
@@ -339,7 +344,7 @@
"select o.mother.bodyWeight, count(distinct o) " +
"from Animal an " +
" join an.offspring as o " +
- "group by o.mother.bodyWeight"
+ "group by o.mother.bodyWeight"
);
}
@@ -357,14 +362,14 @@
DotNode.useThetaStyleImplicitJoins = false;
}
-
+
public void testSizeFunctionAndProperty() {
assertTranslation("from Animal a where a.offspring.size > 0");
assertTranslation("from Animal a join a.offspring where a.offspring.size > 1");
assertTranslation("from Animal a where size(a.offspring) > 0");
assertTranslation("from Animal a join a.offspring o where size(a.offspring) > 1");
assertTranslation("from Animal a where size(a.offspring) > 1 and size(a.offspring) < 100");
-
+
assertTranslation("from Human a where a.family.size > 0");
assertTranslation("from Human a join a.family where a.family.size > 1");
assertTranslation("from Human a where size(a.family) > 0");
@@ -446,7 +451,7 @@
assertTranslation("select minelement(zoo.animals) from Zoo zoo");
assertTranslation("select elements(zoo.animals) from Zoo zoo");
}*/
-
+
public void testFetchCollectionOfValues() throws Exception {
assertTranslation( "from Baz baz left join fetch baz.stringSet" );
}
@@ -469,7 +474,7 @@
assertTranslation( "from User u where 'read' in elements(u.permissions)" );
assertTranslation( "from User u where 'write' <> all elements(u.permissions)" );
}
-
+
/*public void testManyToManyElementFunctionInSelect() throws Exception {
assertTranslation("select maxelement(human.friends) from Human human");
assertTranslation("select elements(human.friends) from Human human");
@@ -529,7 +534,7 @@
// 2004-06-27 [jsd] Recognize 'is null' properly. Generate 'and' and 'or' as well.
assertTranslation( "from Animal an where (an.bodyWeight > 10 and an.bodyWeight < 100) or an.bodyWeight is null" );
}
-
+
public void testEscapedQuote() throws Exception {
assertTranslation( "from Human h where h.nickName='1 ov''tha''few'");
}
@@ -537,7 +542,7 @@
public void testCaseWhenElse() {
assertTranslation( "from Human h where case when h.nickName='1ovthafew' then 'Gavin' when h.nickName='turin' then 'Christian' else h.nickName end = h.name.first" );
}
-
+
public void testCaseExprWhenElse() {
assertTranslation( "from Human h where case h.nickName when '1ovthafew' then 'Gavin' when 'turin' then 'Christian' else h.nickName end = h.name.first" );
}
@@ -578,7 +583,7 @@
// MySQL uses concat(x, y, z)
// SQL Server replaces '||' with '+'
//
- // this is syntax checked in {@link ASTParserLoadingTest#testConcatenation}
+ // this is syntax checked in {@link ASTParserLoadingTest#testConcatenation}
return;
}
assertTranslation("from Human h where h.nickName = '1' || 'ov' || 'tha' || 'few'");
@@ -656,7 +661,7 @@
assertTranslation( "select count(*) from Human h group by year(sysdate)" );
}
-
+
public void testPolymorphism() throws Exception {
HashMap replacements = new HashMap();
replacements.put( "false", "0" );
@@ -751,7 +756,7 @@
/**
* Test for HHH-559
- */
+ */
public void testMultibyteCharacterConstant() throws Exception {
assertTranslation( "from Zoo zoo join zoo.animals an where an.description like '%\u4e2d%'" );
}
@@ -841,8 +846,8 @@
assertTranslation( "select count(distinct an) from Animal an" );
assertTranslation( "select count(distinct an.id) from Animal an" );
assertTranslation( "select count(all an.id) from Animal an" );
- }
-
+ }
+
public void testSelectProperty() throws Exception {
assertTranslation( "select an.bodyWeight, mo.bodyWeight from Animal an inner join an.mother mo where an.bodyWeight < mo.bodyWeight" );
}
@@ -1169,7 +1174,7 @@
assertTranslation( "from Animal a where a in (select o from Animal an join an.offspring o)" );
DotNode.useThetaStyleImplicitJoins = false;
}
-
+
public void testJoinedSubclassImplicitJoin() throws Exception {
// From MultiTableTest.testQueries()
// TODO: This produces the proper from clause now, but the parens in the where clause are different.
@@ -1200,13 +1205,13 @@
public void testOneToManyElementFunctionInWhere() throws Exception {
assertTranslation( "from Zoo zoo where 'dog' in indices(zoo.mammals)" );
assertTranslation( "from Zoo zoo, Dog dog where dog in elements(zoo.mammals)" );
- }
+ }
/*public void testManyToManyElementFunctionInSelect() throws Exception {
assertTranslation("select elements(zoo.mammals) from Zoo zoo");
assertTranslation("select indices(zoo.mammals) from Zoo zoo");
}*/
-
+
public void testManyToManyInJoin() throws Exception {
assertTranslation( "select x.id from Human h1 join h1.family x" );
//assertTranslation("select index(h2) from Human h1 join h1.family h2");
@@ -1227,8 +1232,8 @@
assertTranslation( "from Zoo zoo join zoo.mammals m" );
assertTranslation( "from Zoo" );
assertTranslation( "from Zoo zoo join zoo.mammals" );
- }
-
+ }
+
public void testVectorSubselect() {
assertTranslation( "from Animal a where ('foo', 'bar') in (select m.description, m.bodyWeight from a.mother m)" );
}
@@ -1314,8 +1319,4 @@
compileWithAstQueryTranslator( "from Human where name.first = 'Gavin'", false);
}
- public static Test suite() {
- return new TestSuite( HQLTest.class );
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/HqlParserTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/HqlParserTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/HqlParserTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -2,20 +2,21 @@
package org.hibernate.test.hql;
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+
import antlr.RecognitionException;
import antlr.TokenStreamException;
import antlr.collections.AST;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
+
import org.hibernate.hql.ast.HqlParser;
import org.hibernate.hql.ast.tree.Node;
import org.hibernate.hql.ast.util.ASTIterator;
import org.hibernate.hql.ast.util.ASTPrinter;
-import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
-
/**
* Tests the HQL parser on various inputs, just makes sure that the first phase of the parser
* works properly (i.e. no unexpected syntax errors).
@@ -929,7 +930,7 @@
public void testEjbqlExtensions() throws Exception {
parse( "select object(a) from Animal a where a.mother member of a.offspring" );
- parse( "select object(a) from Animal a where a.mother member a.offspring" );
+ parse( "select object(a) from Animal a where a.mother member a.offspring" ); //no member of
parse( "select object(a) from Animal a where a.offspring is empty" );
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/QueryTranslatorTestCase.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/QueryTranslatorTestCase.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/QueryTranslatorTestCase.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -20,6 +20,7 @@
import org.hibernate.EntityMode;
import org.hibernate.MappingException;
import org.hibernate.QueryException;
+import org.hibernate.junit.functional.FunctionalTestCase;
import org.hibernate.classic.Session;
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.engine.query.HQLQueryPlan;
@@ -30,7 +31,6 @@
import org.hibernate.hql.ast.QueryTranslatorImpl;
import org.hibernate.hql.ast.util.ASTPrinter;
import org.hibernate.hql.classic.ClassicQueryTranslatorFactory;
-import org.hibernate.test.TestCase;
import org.hibernate.type.Type;
import org.hibernate.type.TypeFactory;
import org.hibernate.util.StringHelper;
@@ -40,7 +40,8 @@
*
* @author josh Dec 6, 2004 8:21:21 AM
*/
-public abstract class QueryTranslatorTestCase extends TestCase {
+public abstract class QueryTranslatorTestCase extends FunctionalTestCase {
+
public QueryTranslatorTestCase(String x) {
super( x );
// Create an instance of HqlToken, so that it will have an entry point outside the package. This
@@ -48,6 +49,55 @@
new HqlToken();
}
+ public String[] getMappings() {
+ return new String[] {
+ "hql/Animal.hbm.xml",
+ "hql/EntityWithCrazyCompositeKey.hbm.xml",
+ "hql/CrazyIdFieldNames.hbm.xml",
+ "hql/SimpleEntityWithAssociation.hbm.xml",
+ "hql/ComponentContainer.hbm.xml",
+ "batchfetch/ProductLine.hbm.xml",
+ "cid/Customer.hbm.xml",
+ "cid/Order.hbm.xml",
+ "cid/LineItem.hbm.xml",
+ "cid/Product.hbm.xml",
+ "legacy/Baz.hbm.xml",
+ "legacy/Category.hbm.xml",
+ "legacy/Commento.hbm.xml",
+ "legacy/Container.hbm.xml",
+ "legacy/Custom.hbm.xml",
+ "legacy/Eye.hbm.xml",
+ "legacy/Fee.hbm.xml",
+ "legacy/FooBar.hbm.xml",
+ "legacy/Fum.hbm.xml",
+ "legacy/Glarch.hbm.xml",
+ "legacy/Holder.hbm.xml",
+ "legacy/Many.hbm.xml",
+ "legacy/Marelo.hbm.xml",
+ "legacy/MasterDetail.hbm.xml",
+ "legacy/Middle.hbm.xml",
+ "legacy/Multi.hbm.xml",
+ "legacy/Nameable.hbm.xml",
+ "legacy/One.hbm.xml",
+ "legacy/Qux.hbm.xml",
+ "legacy/Simple.hbm.xml",
+ "legacy/SingleSeveral.hbm.xml",
+ "legacy/WZ.hbm.xml",
+ "legacy/UpDown.hbm.xml",
+ "compositeelement/Parent.hbm.xml",
+ "onetoone/joined/Person.hbm.xml",
+ "any/Properties.hbm.xml"
+ };
+ }
+
+ public boolean createSchema() {
+ return false;
+ }
+
+ public boolean recreateSchemaAfterFailure() {
+ return false;
+ }
+
public void assertTranslation(String hql) throws QueryException, MappingException {
assertTranslation( hql, null );
}
@@ -493,50 +543,4 @@
catch( Throwable t ) {}
}
}
-
- protected String[] getMappings() {
- return new String[] {
- "hql/Animal.hbm.xml",
- "hql/EntityWithCrazyCompositeKey.hbm.xml",
- "hql/CrazyIdFieldNames.hbm.xml",
- "hql/SimpleEntityWithAssociation.hbm.xml",
- "hql/ComponentContainer.hbm.xml",
- "batchfetch/ProductLine.hbm.xml",
- "cid/Customer.hbm.xml",
- "cid/Order.hbm.xml",
- "cid/LineItem.hbm.xml",
- "cid/Product.hbm.xml",
- "legacy/Baz.hbm.xml",
- "legacy/Category.hbm.xml",
- "legacy/Commento.hbm.xml",
- "legacy/Container.hbm.xml",
- "legacy/Custom.hbm.xml",
- "legacy/Eye.hbm.xml",
- "legacy/Fee.hbm.xml",
- "legacy/FooBar.hbm.xml",
- "legacy/Fum.hbm.xml",
- "legacy/Glarch.hbm.xml",
- "legacy/Holder.hbm.xml",
- "legacy/Many.hbm.xml",
- "legacy/Marelo.hbm.xml",
- "legacy/MasterDetail.hbm.xml",
- "legacy/Middle.hbm.xml",
- "legacy/Multi.hbm.xml",
- "legacy/Nameable.hbm.xml",
- "legacy/One.hbm.xml",
- "legacy/Qux.hbm.xml",
- "legacy/Simple.hbm.xml",
- "legacy/SingleSeveral.hbm.xml",
- "legacy/WZ.hbm.xml",
- "legacy/UpDown.hbm.xml",
- "compositeelement/Parent.hbm.xml",
- "onetoone/joined/Person.hbm.xml",
- "any/Properties.hbm.xml"
- };
- }
-
- protected boolean recreateSchema() {
- // we do not need to create the schema for these parser tests
- return false;
- }
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/ScrollableCollectionFetchingTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/ScrollableCollectionFetchingTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/ScrollableCollectionFetchingTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,14 +1,15 @@
// $Id$
package org.hibernate.test.hql;
-import org.hibernate.test.TestCase;
+import junit.framework.Test;
+
+import org.hibernate.HibernateException;
+import org.hibernate.ScrollMode;
+import org.hibernate.ScrollableResults;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.ScrollableResults;
-import org.hibernate.HibernateException;
-import org.hibernate.ScrollMode;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* Tests the new functionality of allowing scrolling of results which
@@ -16,17 +17,17 @@
*
* @author Steve Ebersole
*/
-public class ScrollableCollectionFetchingTest extends TestCase {
+public class ScrollableCollectionFetchingTest extends FunctionalTestCase {
public ScrollableCollectionFetchingTest(String name) {
super( name );
}
public static Test suite() {
- return new TestSuite( ScrollableCollectionFetchingTest.class );
+ return new FunctionalTestClassTestSuite( ScrollableCollectionFetchingTest.class );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "hql/Animal.hbm.xml" };
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/Zoo.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/Zoo.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/Zoo.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -54,7 +54,6 @@
this.address = address;
}
-
public Classification getClassification() {
return classification;
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/id/MultipleHiLoPerTableGeneratorTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/id/MultipleHiLoPerTableGeneratorTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/id/MultipleHiLoPerTableGeneratorTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,28 +1,29 @@
//$Id$
package org.hibernate.test.id;
-import org.hibernate.test.TestCase;
+import junit.framework.Test;
+
import org.hibernate.Session;
import org.hibernate.Transaction;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Emmanuel Bernard
*/
-public class MultipleHiLoPerTableGeneratorTest extends TestCase {
+public class MultipleHiLoPerTableGeneratorTest extends FunctionalTestCase {
public MultipleHiLoPerTableGeneratorTest(String x) {
super(x);
}
- protected String[] getMappings() {
- return new String[]{
- "id/Car.hbm.xml",
- "id/Plane.hbm.xml",
- "id/Radio.hbm.xml"
- };
+ public String[] getMappings() {
+ return new String[]{ "id/Car.hbm.xml", "id/Plane.hbm.xml", "id/Radio.hbm.xml" };
}
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( MultipleHiLoPerTableGeneratorTest.class );
+ }
+
public void testDistinctId() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@@ -103,8 +104,4 @@
tx.commit();
s.close();
}
-
- public static Test suite() {
- return new TestSuite(MultipleHiLoPerTableGeneratorTest.class);
- }
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/idbag/IdBagTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/idbag/IdBagTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/idbag/IdBagTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -5,23 +5,31 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class IdBagTest extends TestCase {
+public class IdBagTest extends FunctionalTestCase {
public IdBagTest(String str) {
super(str);
}
+ public String[] getMappings() {
+ return new String[] { "idbag/UserGroup.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( IdBagTest.class );
+ }
+
public void testUpdateIdBag() throws HibernateException, SQLException {
Session s = openSession();
Transaction t = s.beginTransaction();
@@ -88,14 +96,6 @@
t.commit();
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "idbag/UserGroup.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(IdBagTest.class);
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/idclass/IdClassTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/idclass/IdClassTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/idclass/IdClassTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -2,25 +2,30 @@
package org.hibernate.test.idclass;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
-import org.hibernate.type.Type;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class IdClassTest extends TestCase {
+public class IdClassTest extends FunctionalTestCase {
public IdClassTest(String str) {
super(str);
}
+ public String[] getMappings() {
+ return new String[] { "idclass/Customer.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( IdClassTest.class );
+ }
+
public void testIdClass() {
- Type type = getSessions().getClassMetadata(Customer.class).getIdentifierType();
- Type[] types = getSessions().getClassMetadata(Customer.class).getPropertyTypes();
Session s = openSession();
Transaction t = s.beginTransaction();
Customer cust = new FavoriteCustomer("JBoss", "RouteOne", "Detroit");
@@ -59,14 +64,6 @@
t.commit();
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "idclass/Customer.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(IdClassTest.class);
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/idprops/IdentifierPropertyReferencesTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/idprops/IdentifierPropertyReferencesTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/idprops/IdentifierPropertyReferencesTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,31 +1,31 @@
package org.hibernate.test.idprops;
import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.hibernate.test.TestCase;
+import org.hibernate.Criteria;
+import org.hibernate.Query;
import org.hibernate.Session;
-import org.hibernate.Query;
-import org.hibernate.Criteria;
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* {@inheritDoc}
*
* @author Steve Ebersole
*/
-public class IdentifierPropertyReferencesTest extends TestCase {
+public class IdentifierPropertyReferencesTest extends FunctionalTestCase {
public IdentifierPropertyReferencesTest(String name) {
super( name );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "idprops/Mapping.hbm.xml" };
}
public static Test suite() {
- return new TestSuite( IdentifierPropertyReferencesTest.class );
+ return new FunctionalTestClassTestSuite( IdentifierPropertyReferencesTest.class );
}
public void testHqlIdPropertyReferences() {
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/immutable/ImmutableTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/immutable/ImmutableTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/immutable/ImmutableTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -2,18 +2,30 @@
package org.hibernate.test.immutable;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.criterion.Projections;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class ImmutableTest extends TestCase {
-
+public class ImmutableTest extends FunctionalTestCase {
+
+ public ImmutableTest(String str) {
+ super(str);
+ }
+
+ public String[] getMappings() {
+ return new String[] { "immutable/ContractVariation.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( ImmutableTest.class );
+ }
+
public void testImmutable() {
Contract c = new Contract("gavin", "phone");
ContractVariation cv1 = new ContractVariation(1, c);
@@ -49,18 +61,6 @@
t.commit();
s.close();
}
-
- public ImmutableTest(String str) {
- super(str);
- }
- protected String[] getMappings() {
- return new String[] { "immutable/ContractVariation.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(ImmutableTest.class);
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/buildtime/InstrumentTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/buildtime/InstrumentTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/buildtime/InstrumentTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -5,7 +5,6 @@
import junit.framework.TestSuite;
import org.hibernate.intercept.FieldInterceptionHelper;
-import org.hibernate.test.TestCase;
import org.hibernate.test.instrument.domain.Document;
import org.hibernate.test.instrument.cases.TestDirtyCheckExecutable;
import org.hibernate.test.instrument.cases.TestFetchAllExecutable;
@@ -16,16 +15,21 @@
import org.hibernate.test.instrument.cases.TestLazyPropertyCustomTypeExecutable;
import org.hibernate.test.instrument.cases.TestManyToOneProxyExecutable;
import org.hibernate.test.instrument.cases.Executable;
+import org.hibernate.junit.UnitTestCase;
/**
* @author Gavin King
*/
-public class InstrumentTest extends TestCase {
+public class InstrumentTest extends UnitTestCase {
public InstrumentTest(String str) {
super(str);
}
+ public static Test suite() {
+ return new TestSuite( InstrumentTest.class );
+ }
+
public void testDirtyCheck() {
execute( new TestDirtyCheckExecutable() );
}
@@ -57,7 +61,7 @@
public void testLazyPropertyCustomTypeExecutable() {
execute( new TestLazyPropertyCustomTypeExecutable() );
}
-
+
private void execute(Executable executable) {
executable.prepare();
try {
@@ -68,10 +72,6 @@
}
}
- protected String[] getMappings() {
- return new String[] { "instrument/domain/Documents.hbm.xml" };
- }
-
protected void runTest() throws Throwable {
if ( isRunnable() ) {
super.runTest();
@@ -81,10 +81,6 @@
}
}
- public static Test suite() {
- return new TestSuite(InstrumentTest.class);
- }
-
public static boolean isRunnable() {
return FieldInterceptionHelper.isInstrumented( new Document() );
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/cases/AbstractExecutable.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/cases/AbstractExecutable.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/cases/AbstractExecutable.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,43 +1,42 @@
-package org.hibernate.test.instrument.cases;
-
-import org.hibernate.SessionFactory;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.cfg.Environment;
-
-/**
- * @author Steve Ebersole
- */
-public abstract class AbstractExecutable implements Executable {
-
- private SessionFactory factory;
-
- public final void prepare() {
- Configuration cfg = new Configuration()
- .setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
- String[] resources = getResources();
- for ( int i = 0; i < resources.length; i++ ) {
- cfg.addResource( resources[i] );
- }
- factory = cfg.buildSessionFactory();
- }
-
- public final void complete() {
- try {
- cleanup();
- }
- finally {
- factory.close();
- }
- }
-
- protected SessionFactory getFactory() {
- return factory;
- }
-
- protected void cleanup() {
- }
-
- protected String[] getResources() {
- return new String[] { "org/hibernate/test/instrument/domain/Documents.hbm.xml" };
- }
-}
+package org.hibernate.test.instrument.cases;
+
+import org.hibernate.SessionFactory;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
+
+/**
+ * @author Steve Ebersole
+ */
+public abstract class AbstractExecutable implements Executable {
+
+ private SessionFactory factory;
+
+ public final void prepare() {
+ Configuration cfg = new Configuration().setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
+ String[] resources = getResources();
+ for ( int i = 0; i < resources.length; i++ ) {
+ cfg.addResource( resources[i] );
+ }
+ factory = cfg.buildSessionFactory();
+ }
+
+ public final void complete() {
+ try {
+ cleanup();
+ }
+ finally {
+ factory.close();
+ }
+ }
+
+ protected SessionFactory getFactory() {
+ return factory;
+ }
+
+ protected void cleanup() {
+ }
+
+ protected String[] getResources() {
+ return new String[] { "org/hibernate/test/instrument/domain/Documents.hbm.xml" };
+ }
+}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/cases/TestDirtyCheckExecutable.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/cases/TestDirtyCheckExecutable.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/cases/TestDirtyCheckExecutable.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -2,7 +2,6 @@
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.instrument.cases.AbstractExecutable;
import org.hibernate.test.instrument.domain.Folder;
import java.util.List;
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/cases/TestFetchAllExecutable.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/cases/TestFetchAllExecutable.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/cases/TestFetchAllExecutable.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -6,7 +6,6 @@
import org.hibernate.test.instrument.domain.Owner;
import org.hibernate.test.instrument.domain.Document;
import org.hibernate.test.instrument.domain.Folder;
-import org.hibernate.test.instrument.cases.AbstractExecutable;
import junit.framework.Assert;
/**
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/cases/TestInjectFieldInterceptorExecutable.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/cases/TestInjectFieldInterceptorExecutable.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/cases/TestInjectFieldInterceptorExecutable.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,7 +1,6 @@
package org.hibernate.test.instrument.cases;
import org.hibernate.test.instrument.domain.Document;
-import org.hibernate.test.instrument.cases.AbstractExecutable;
import org.hibernate.intercept.FieldInterceptionHelper;
import java.util.HashSet;
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/cases/TestIsPropertyInitializedExecutable.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/cases/TestIsPropertyInitializedExecutable.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/cases/TestIsPropertyInitializedExecutable.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -7,7 +7,6 @@
import org.hibernate.test.instrument.domain.Owner;
import org.hibernate.test.instrument.domain.Document;
import org.hibernate.test.instrument.domain.Folder;
-import org.hibernate.test.instrument.cases.AbstractExecutable;
import junit.framework.Assert;
/**
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/domain/Documents.hbm.xml
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/domain/Documents.hbm.xml 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/domain/Documents.hbm.xml 2006-12-12 23:22:26 UTC (rev 10976)
@@ -16,39 +16,32 @@
(2) use of a formula to define a "derived property"
-->
+
<hibernate-mapping package="org.hibernate.test.instrument.domain" default-access="field">
<class name="Folder" table="folders">
<id name="id">
<generator class="increment"/>
</id>
- <property name="name"
- not-null="true"
- length="50"/>
+ <property name="name" not-null="true" length="50"/>
<many-to-one name="parent"/>
- <bag name="subfolders"
- inverse="true"
- cascade="save-update">
+ <bag name="subfolders" inverse="true" cascade="save-update">
<key column="parent"/>
<one-to-many class="Folder"/>
</bag>
- <bag name="documents"
- inverse="true"
- cascade="all-delete-orphan">
+ <bag name="documents" inverse="true" cascade="all-delete-orphan">
<key column="folder"/>
<one-to-many class="Document"/>
</bag>
</class>
-
+
<class name="Owner" table="owners" lazy="false">
<id name="id">
<generator class="increment"/>
</id>
- <property name="name"
- not-null="true"
- length="50"/>
+ <property name="name" not-null="true" length="50"/>
</class>
-
+
<class name="Document" table="documents">
<id name="id">
<generator class="increment"/>
@@ -71,4 +64,4 @@
<many-to-one name="sibling" column="RIGHT_ID" class="Entity" lazy="no-proxy" cascade="all" />
</class>
-</hibernate-mapping>
\ No newline at end of file
+</hibernate-mapping>
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/domain/Problematic.hbm.xml
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/domain/Problematic.hbm.xml 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/domain/Problematic.hbm.xml 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="org.hibernate.test.instrument.domain">
<class name="Problematic">
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/domain/Problematic.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/domain/Problematic.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/domain/Problematic.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,69 +1,69 @@
-package org.hibernate.test.instrument.domain;
-
-/**
- * {@inheritDoc}
- *
- * @author Steve Ebersole
- */
-public class Problematic {
- private Long id;
- private String name;
- private byte[] bytes;
-
- private Representation representation;
-
- public Long getId() {
- return id;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public byte[] getBytes() {
- return bytes;
- }
-
- public void setBytes(byte[] bytes) {
- this.bytes = bytes;
- }
-
- public Representation getRepresentation() {
- if ( representation == null ) {
- representation = ( ( bytes == null ) ? null : new Representation( bytes ) );
- }
- return representation;
- }
-
- public void setRepresentation(Representation rep) {
- bytes = rep.getBytes();
- }
-
- public static class Representation {
- private byte[] bytes;
-
- public Representation(byte[] bytes) {
- this.bytes = bytes;
- }
-
- public byte[] getBytes() {
- return bytes;
- }
-
- public String toString() {
- String result = "";
- for ( int i = 0; i < bytes.length; i++ ) {
- result += bytes[i];
- }
- return result;
- }
- }
-}
+package org.hibernate.test.instrument.domain;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class Problematic {
+ private Long id;
+ private String name;
+ private byte[] bytes;
+
+ private Representation representation;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public byte[] getBytes() {
+ return bytes;
+ }
+
+ public void setBytes(byte[] bytes) {
+ this.bytes = bytes;
+ }
+
+ public Representation getRepresentation() {
+ if ( representation == null ) {
+ representation = ( ( bytes == null ) ? null : new Representation( bytes ) );
+ }
+ return representation;
+ }
+
+ public void setRepresentation(Representation rep) {
+ bytes = rep.getBytes();
+ }
+
+ public static class Representation {
+ private byte[] bytes;
+
+ public Representation(byte[] bytes) {
+ this.bytes = bytes;
+ }
+
+ public byte[] getBytes() {
+ return bytes;
+ }
+
+ public String toString() {
+ String result = "";
+ for ( int i = 0; i < bytes.length; i++ ) {
+ result += bytes[i];
+ }
+ return result;
+ }
+ }
+}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/runtime/AbstractTransformingClassLoaderInstrumentTestCase.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/runtime/AbstractTransformingClassLoaderInstrumentTestCase.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/runtime/AbstractTransformingClassLoaderInstrumentTestCase.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -7,13 +7,17 @@
import org.hibernate.bytecode.InstrumentedClassLoader;
import org.hibernate.bytecode.util.BasicClassFilter;
import org.hibernate.bytecode.util.FieldFilter;
-import org.hibernate.test.AbstractClassLoaderIsolatedTestCase;
+import org.hibernate.junit.AbstractClassLoaderIsolatedTestCase;
/**
* @author Steve Ebersole
*/
public abstract class AbstractTransformingClassLoaderInstrumentTestCase extends AbstractClassLoaderIsolatedTestCase {
+ public AbstractTransformingClassLoaderInstrumentTestCase(String string) {
+ super( string );
+ }
+
protected ClassLoader buildIsolatedClassLoader(ClassLoader parent) {
BytecodeProvider provider = buildBytecodeProvider();
return new InstrumentedClassLoader(
@@ -75,6 +79,7 @@
}
+
// reflection code to ensure isolation into the created classloader ~~~~~~~
private static final Class[] SIG = new Class[] {};
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/runtime/CGLIBInstrumentationTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/runtime/CGLIBInstrumentationTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/runtime/CGLIBInstrumentationTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -9,6 +9,10 @@
* @author Steve Ebersole
*/
public class CGLIBInstrumentationTest extends AbstractTransformingClassLoaderInstrumentTestCase {
+ public CGLIBInstrumentationTest(String string) {
+ super( string );
+ }
+
protected BytecodeProvider buildBytecodeProvider() {
return new BytecodeProviderImpl();
}
@@ -16,4 +20,32 @@
public static Test suite() {
return new TestSuite( CGLIBInstrumentationTest.class );
}
+
+ public void testSetFieldInterceptor() {
+ super.testSetFieldInterceptor(); //To change body of overridden methods use File | Settings | File Templates.
+ }
+
+ public void testDirtyCheck() {
+ super.testDirtyCheck(); //To change body of overridden methods use File | Settings | File Templates.
+ }
+
+ public void testFetchAll() throws Exception {
+ super.testFetchAll(); //To change body of overridden methods use File | Settings | File Templates.
+ }
+
+ public void testLazy() {
+ super.testLazy(); //To change body of overridden methods use File | Settings | File Templates.
+ }
+
+ public void testLazyManyToOne() {
+ super.testLazyManyToOne(); //To change body of overridden methods use File | Settings | File Templates.
+ }
+
+ public void testPropertyInitialized() {
+ super.testPropertyInitialized(); //To change body of overridden methods use File | Settings | File Templates.
+ }
+
+ public void testManyToOneProxy() {
+ super.testManyToOneProxy(); //To change body of overridden methods use File | Settings | File Templates.
+ }
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/runtime/JavassistInstrumentationTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/runtime/JavassistInstrumentationTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/runtime/JavassistInstrumentationTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -10,6 +10,10 @@
* @author Steve Ebersole
*/
public class JavassistInstrumentationTest extends AbstractTransformingClassLoaderInstrumentTestCase {
+ public JavassistInstrumentationTest(String string) {
+ super( string );
+ }
+
protected BytecodeProvider buildBytecodeProvider() {
return new BytecodeProviderImpl();
}
@@ -17,4 +21,32 @@
public static Test suite() {
return new TestSuite( JavassistInstrumentationTest.class );
}
+
+ public void testSetFieldInterceptor() {
+ super.testSetFieldInterceptor();
+ }
+
+ public void testDirtyCheck() {
+ super.testDirtyCheck();
+ }
+
+ public void testFetchAll() throws Exception {
+ super.testFetchAll();
+ }
+
+ public void testLazy() {
+ super.testLazy();
+ }
+
+ public void testLazyManyToOne() {
+ super.testLazyManyToOne();
+ }
+
+ public void testPropertyInitialized() {
+ super.testPropertyInitialized();
+ }
+
+ public void testManyToOneProxy() {
+ super.testManyToOneProxy();
+ }
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/interceptor/InterceptorTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/interceptor/InterceptorTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/interceptor/InterceptorTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,27 +1,35 @@
//$Id$
package org.hibernate.test.interceptor;
+import java.io.Serializable;
import java.util.List;
-import java.io.Serializable;
import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.EmptyInterceptor;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.EmptyInterceptor;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.type.Type;
-import org.hibernate.test.TestCase;
/**
* @author Gavin King
*/
-public class InterceptorTest extends TestCase {
-
+public class InterceptorTest extends FunctionalTestCase {
+
public InterceptorTest(String str) {
super(str);
}
+ public String[] getMappings() {
+ return new String[] { "interceptor/User.hbm.xml", "interceptor/Image.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( InterceptorTest.class );
+ }
+
public void testCollectionIntercept() {
Session s = openSession( new CollectionInterceptor() );
Transaction t = s.beginTransaction();
@@ -30,7 +38,7 @@
u.setPassword("vagni");
t.commit();
s.close();
-
+
s = openSession();
t = s.beginTransaction();
u = (User) s.get(User.class, "Gavin");
@@ -38,8 +46,8 @@
s.delete(u);
t.commit();
s.close();
- }
-
+ }
+
public void testPropertyIntercept() {
Session s = openSession( new PropertyInterceptor() );
Transaction t = s.beginTransaction();
@@ -48,7 +56,7 @@
u.setPassword("vagni");
t.commit();
s.close();
-
+
s = openSession();
t = s.beginTransaction();
u = (User) s.get(User.class, "Gavin");
@@ -138,14 +146,14 @@
final StatefulInterceptor statefulInterceptor = new StatefulInterceptor();
Session s = openSession( statefulInterceptor );
statefulInterceptor.setSession(s);
-
+
Transaction t = s.beginTransaction();
User u = new User("Gavin", "nivag");
s.persist(u);
u.setPassword("vagni");
t.commit();
s.close();
-
+
s = openSession();
t = s.beginTransaction();
List logs = s.createCriteria(Log.class).list();
@@ -155,14 +163,6 @@
t.commit();
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "interceptor/User.hbm.xml", "interceptor/Image.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(InterceptorTest.class);
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/interfaceproxy/InterfaceProxyTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/interfaceproxy/InterfaceProxyTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/interfaceproxy/InterfaceProxyTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -2,26 +2,41 @@
package org.hibernate.test.interfaceproxy;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.dialect.PostgreSQLDialect;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class InterfaceProxyTest extends TestCase {
+public class InterfaceProxyTest extends FunctionalTestCase {
public InterfaceProxyTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "interfaceproxy/Item.hbm.xml" };
+ }
+
+ public String getCacheConcurrencyStrategy() {
+ return null;
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( InterfaceProxyTest.class );
+ }
public void testInterfaceProxies() {
- if ( getDialect() instanceof PostgreSQLDialect ) return;
+ if ( getDialect() instanceof PostgreSQLDialect ) {
+ // TODO : why?
+ return;
+ }
Session s = openSession( new DocumentInterceptor() );
Transaction t = s.beginTransaction();
@@ -82,18 +97,5 @@
t.commit();
s.close();
}
-
-
- protected String[] getMappings() {
- return new String[] { "interfaceproxy/Item.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(InterfaceProxyTest.class);
- }
-
- public String getCacheConcurrencyStrategy() {
- return null;
- }
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/iterate/IterateTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/iterate/IterateTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/iterate/IterateTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -4,7 +4,6 @@
import java.util.Iterator;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.ScrollableResults;
@@ -12,16 +11,33 @@
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class IterateTest extends TestCase {
+public class IterateTest extends FunctionalTestCase {
public IterateTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "iterate/Item.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ super.configure( cfg );
+ cfg.setProperty( Environment.USE_QUERY_CACHE, "true" );
+ cfg.setProperty( Environment.CACHE_REGION_PREFIX, "foo" );
+ cfg.setProperty( Environment.USE_SECOND_LEVEL_CACHE, "true" );
+ cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( IterateTest.class );
+ }
public void testIterate() throws Exception {
getSessions().getStatistics().clear();
@@ -85,21 +101,5 @@
s.close();
assertEquals( getSessions().getStatistics().getEntityFetchCount(), 0 );
}
-
- protected String[] getMappings() {
- return new String[] { "iterate/Item.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(IterateTest.class);
- }
-
- protected void configure(Configuration cfg) {
- super.configure( cfg );
- cfg.setProperty( Environment.USE_QUERY_CACHE, "true" );
- cfg.setProperty( Environment.CACHE_REGION_PREFIX, "foo" );
- cfg.setProperty( Environment.USE_SECOND_LEVEL_CACHE, "true" );
- cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
- }
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/join/JoinTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/join/JoinTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/join/JoinTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -5,21 +5,29 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class JoinTest extends TestCase {
+public class JoinTest extends FunctionalTestCase {
public JoinTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "join/Person.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( JoinTest.class );
+ }
public void testSequentialSelects() {
Session s = openSession();
@@ -123,14 +131,5 @@
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "join/Person.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(JoinTest.class);
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/join/Person.hbm.xml
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/join/Person.hbm.xml 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/join/Person.hbm.xml 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,78 +1,78 @@
<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-
-<!--
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
- This mapping demonstrates
+<!--
+ This mapping demonstrates
+
(1) a table-per-subclass mapping strategy where subclass data is
retrieved by sequential select instead of a join (we do NOT
recommend you do this, since it is very vulnerable to N+1
problems; users porting applications from TopLink might find
this useful for reproducing old behavior)
-
+
(2) spreading data from a single class across multiple tables
(again, we do not recommend you do this; use finer grained
classes instead)
-
+
(3) use of null as a discriminator value
-
+
(4) recursive associations withing an inheritance tree
-
+
-->
<hibernate-mapping package="org.hibernate.test.join" default-access="field">
- <class name="Person" table="person" lazy="true" discriminator-value="null">
+ <class name="Person" table="person" lazy="true" discriminator-value="null">
- <id name="id" column="person_id" unsaved-value="0">
- <generator class="native"/>
- </id>
+ <id name="id" column="person_id" unsaved-value="0">
+ <generator class="native"/>
+ </id>
<!-- force is unnecessary, in case we had other unknown discriminator values -->
- <discriminator column="person_type" type="string" length="1" not-null="false" force="true"/>
+ <discriminator column="person_type" type="string" length="1" not-null="false" force="true"/>
- <property name="name" not-null="true" length="80"/>
- <property name="sex" not-null="true" update="false"/>
+ <property name="name" not-null="true" length="80"/>
+ <property name="sex" not-null="true" update="false"/>
- <join table="address">
- <key column="address_id"/>
- <property name="address"/>
- <property name="zip"/>
- <property name="country"/>
- </join>
+ <join table="address">
+ <key column="address_id"/>
+ <property name="address"/>
+ <property name="zip"/>
+ <property name="country"/>
+ </join>
- <subclass name="Employee" lazy="true" discriminator-value="E">
- <join table="employee" fetch="select">
- <key column="person_id"/>
- <property name="title" not-null="true" length="20"/>
- <property name="salary" length="0"/>
- <many-to-one name="manager"/>
- </join>
- </subclass>
+ <subclass name="Employee" lazy="true" discriminator-value="E">
+ <join table="employee" fetch="select">
+ <key column="person_id"/>
+ <property name="title" not-null="true" length="20"/>
+ <property name="salary" length="0"/>
+ <many-to-one name="manager"/>
+ </join>
+ </subclass>
- <subclass name="Customer" lazy="true" discriminator-value="C">
- <join table="customer" fetch="select">
- <key column="person_id"/>
- <property name="comments"/>
- <many-to-one name="salesperson"/>
- </join>
- </subclass>
+ <subclass name="Customer" lazy="true" discriminator-value="C">
+ <join table="customer" fetch="select">
+ <key column="person_id"/>
+ <property name="comments"/>
+ <many-to-one name="salesperson"/>
+ </join>
+ </subclass>
- <subclass name="User" lazy="true" discriminator-value="U">
- <join table="t_user" fetch="select" optional="true">
- <key column="person_id"/>
- <property name="login" column="u_login"/>
- </join>
- <join table="t_silly" fetch="select" optional="true" >
+ <subclass name="User" lazy="true" discriminator-value="U">
+ <join table="t_user" fetch="select" optional="true">
<key column="person_id"/>
+ <property name="login" column="u_login"/>
+ </join>
+ <join table="t_silly" fetch="select" optional="true">
+ <key column="person_id"/>
<property name="silly"/>
</join>
</subclass>
- </class>
+ </class>
</hibernate-mapping>
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/joinedsubclass/JoinedSubclassTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/joinedsubclass/JoinedSubclassTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/joinedsubclass/JoinedSubclassTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -6,25 +6,33 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
+import org.hibernate.LockMode;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.LockMode;
import org.hibernate.criterion.Expression;
import org.hibernate.criterion.Property;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class JoinedSubclassTest extends TestCase {
-
+public class JoinedSubclassTest extends FunctionalTestCase {
+
public JoinedSubclassTest(String str) {
super(str);
}
+ public String[] getMappings() {
+ return new String[] { "joinedsubclass/Person.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( JoinedSubclassTest.class );
+ }
+
public void testJoinedSubclass() {
Session s = openSession();
Transaction t = s.beginTransaction();
@@ -133,7 +141,7 @@
s.getTransaction().commit();
s.close();
}
-
+
public void testQuerySubclassAttribute() {
Session s = openSession();
Transaction t = s.beginTransaction();
@@ -151,9 +159,9 @@
List result = s.createQuery("from Person where salary > 100").list();
assertEquals( result.size(), 1 );
assertSame( result.get(0), q );
-
+
result = s.createQuery("from Person where salary > 100 or name like 'E%'").list();
- assertEquals( result.size(), 2 );
+ assertEquals( result.size(), 2 );
result = s.createCriteria(Person.class)
.add( Property.forName("salary").gt( new BigDecimal(100) ) )
@@ -165,7 +173,7 @@
/*result = s.createQuery("select salary from Person where salary > 100").list();
assertEquals( result.size(), 1 );
assertEquals( result.get(0), new BigDecimal(1000) );*/
-
+
s.delete(p);
s.delete(q);
t.commit();
@@ -199,14 +207,5 @@
}
-
- protected String[] getMappings() {
- return new String[] { "joinedsubclass/Person.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(JoinedSubclassTest.class);
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/joinfetch/JoinFetchTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/joinfetch/JoinFetchTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/joinfetch/JoinFetchTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -4,7 +4,6 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.FetchMode;
import org.hibernate.Hibernate;
@@ -14,16 +13,30 @@
import org.hibernate.cfg.Environment;
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class JoinFetchTest extends TestCase {
+public class JoinFetchTest extends FunctionalTestCase {
public JoinFetchTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "joinfetch/ItemBid.hbm.xml", "joinfetch/UserGroup.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty(Environment.MAX_FETCH_DEPTH, "10");
+ cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "false");
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( JoinFetchTest.class );
+ }
public void testProjection() {
Session s = openSession();
@@ -249,19 +262,6 @@
t.commit();
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "joinfetch/ItemBid.hbm.xml", "joinfetch/UserGroup.hbm.xml" };
- }
- protected void configure(Configuration cfg) {
- cfg.setProperty(Environment.MAX_FETCH_DEPTH, "10");
- cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "false");
- }
-
- public static Test suite() {
- return new TestSuite(JoinFetchTest.class);
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/AbstractJPATest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/AbstractJPATest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/AbstractJPATest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -14,6 +14,7 @@
import org.hibernate.event.FlushEntityEventListener;
import org.hibernate.engine.CascadingAction;
import org.hibernate.util.IdentityMap;
+import org.hibernate.junit.functional.FunctionalTestCase;
import java.io.Serializable;
@@ -22,16 +23,16 @@
*
* @author Steve Ebersole
*/
-public class AbstractJPATest extends TestCase {
+public class AbstractJPATest extends FunctionalTestCase {
public AbstractJPATest(String name) {
super( name );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "jpa/Part.hbm.xml", "jpa/Item.hbm.xml", "jpa/MyEntity.hbm.xml" };
}
- protected void configure(Configuration cfg) {
+ public void configure(Configuration cfg) {
super.configure( cfg );
cfg.setProperty( Environment.JPAQL_STRICT_COMPLIANCE, "true" );
cfg.setProperty( Environment.USE_SECOND_LEVEL_CACHE, "false" );
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/JPAComplianceSuite.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/JPAComplianceSuite.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/JPAComplianceSuite.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -2,12 +2,14 @@
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.hibernate.test.jpa.lock.EJB3LockTest;
+import org.hibernate.test.jpa.lock.JPALockTest;
import org.hibernate.test.jpa.lock.RepeatableReadTest;
import org.hibernate.test.jpa.removed.RemovedEntityTest;
import org.hibernate.test.jpa.proxy.JPAProxyTest;
import org.hibernate.test.jpa.fetch.FetchingTest;
import org.hibernate.test.jpa.ql.JPAQLComplianceTest;
+import org.hibernate.test.jpa.ql.NativeQueryTest;
+import org.hibernate.test.jpa.cascade.CascadeTest;
/**
* @author Steve Ebersole
@@ -15,11 +17,13 @@
public class JPAComplianceSuite {
public static Test suite() {
TestSuite suite = new TestSuite( "JPA-compliance tests");
- suite.addTest( EJB3LockTest.suite() );
+ suite.addTest( CascadeTest.suite() );
+ suite.addTest( FetchingTest.suite() );
+ suite.addTest( JPALockTest.suite() );
suite.addTest( RepeatableReadTest.suite() );
suite.addTest( JPAProxyTest.suite() );
- suite.addTest( FetchingTest.suite() );
suite.addTest( JPAQLComplianceTest.suite() );
+ suite.addTest( NativeQueryTest.suite() );
suite.addTest( RemovedEntityTest.suite() );
return suite;
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/cascade/CascadeTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/cascade/CascadeTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/cascade/CascadeTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -5,6 +5,7 @@
import org.hibernate.TransientObjectException;
import org.hibernate.EntityMode;
import org.hibernate.HibernateException;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.engine.Status;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.event.FlushEntityEventListener;
@@ -12,6 +13,7 @@
import org.hibernate.cfg.Configuration;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import junit.framework.Test;
/**
* According to the JPA spec, persist()ing an entity should throw an exception
@@ -34,13 +36,12 @@
super( name );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "jpa/cascade/ParentChild.hbm.xml" };
}
- protected void configure(Configuration cfg) {
- super.configure( cfg );
-
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( CascadeTest.class );
}
public void testManyToOneGeneratedIdsOnSave() {
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/fetch/FetchingTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/fetch/FetchingTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/fetch/FetchingTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,20 +1,32 @@
package org.hibernate.test.jpa.fetch;
-import org.hibernate.test.jpa.AbstractJPATest;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.hibernate.Hibernate;
-
import java.util.Date;
import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.Hibernate;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.test.jpa.AbstractJPATest;
+
/**
* @author Emmanuel Bernard
*/
public class FetchingTest extends AbstractJPATest {
+ public FetchingTest(String x) {
+ super( x );
+ }
+
+ public String[] getMappings() {
+ return new String[] { "jpa/fetch/Person.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( FetchingTest.class );
+ }
+
public void testLazy() throws Exception {
Session s;
Transaction tx;
@@ -69,16 +81,4 @@
tx.commit();
s.close();
}
-
- public FetchingTest(String x) {
- super( x );
- }
-
- protected String[] getMappings() {
- return new String[] { "jpa/fetch/Person.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite( FetchingTest.class );
- }
}
Deleted: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/lock/EJB3LockTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/lock/EJB3LockTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/lock/EJB3LockTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,179 +0,0 @@
-package org.hibernate.test.jpa.lock;
-
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.hibernate.LockMode;
-import org.hibernate.test.jpa.AbstractJPATest;
-import org.hibernate.test.jpa.Item;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * Tests specifically relating to section 3.3.5.3 [Lock Modes] of the
- * JPA persistence specification (as of the <i>Proposed Final Draft</i>).
- *
- * @author Steve Ebersole
- */
-public class EJB3LockTest extends AbstractJPATest {
- public EJB3LockTest(String name) {
- super( name );
- }
-
- public static Test suite() {
- return new TestSuite( EJB3LockTest.class );
- }
-
- /**
- * Test the equivalent of EJB3 LockModeType.READ
- * <p/>
- * From the spec:
- * <p/>
- * If transaction T1 calls lock(entity, LockModeType.READ) on a versioned object, the entity
- * manager must ensure that neither of the following phenomena can occur:<ul>
- * <li>P1 (Dirty read): Transaction T1 modifies a row. Another transaction T2 then reads that row and
- * obtains the modified value, before T1 has committed or rolled back. Transaction T2 eventually
- * commits successfully; it does not matter whether T1 commits or rolls back and whether it does
- * so before or after T2 commits.
- * <li>P2 (Non-repeatable read): Transaction T1 reads a row. Another transaction T2 then modifies or
- * deletes that row, before T1 has committed. Both transactions eventually commit successfully.
- * <p/>
- * This will generally be achieved by the entity manager acquiring a lock on the underlying database row.
- * Any such lock may be obtained immediately (so long as it is retained until commit completes), or the
- * lock may be deferred until commit time (although even then it must be retained until the commit completes).
- * Any implementation that supports repeatable reads in a way that prevents the above phenomena
- * is permissible.
- * <p/>
- * The persistence implementation is not required to support calling lock(entity, LockMode-Type.READ)
- * on a non-versioned object. When it cannot support such a lock call, it must throw the
- * PersistenceException. When supported, whether for versioned or non-versioned objects, LockMode-Type.READ
- * must always prevent the phenomena P1 and P2. Applications that call lock(entity, LockModeType.READ)
- * on non-versioned objects will not be portable.
- * <p/>
- * Odd as it may sound, EJB3 LockModeType.READ actually maps to the Hibernate LockMode.UPGRADE
- */
- public void testLockModeTypeRead() {
- if ( ! readCommittedIsolationMaintained( "ejb3 lock tests" ) ) {
- return;
- }
-
- final String initialName = "lock test";
- // set up some test data
- Session s1 = getSessions().openSession();
- Transaction t1 = s1.beginTransaction();
- Item item = new Item();
- item.setName( initialName );
- s1.save( item );
- t1.commit();
- s1.close();
-
- Long itemId = item.getId();
-
- // perform the isolated update
- s1 = getSessions().openSession();
- t1 = s1.beginTransaction();
- item = ( Item ) s1.get( Item.class, itemId );
- s1.lock( item, LockMode.UPGRADE );
- item.setName( "updated" );
- s1.flush();
-
- Session s2 = getSessions().openSession();
- Transaction t2 = s2.beginTransaction();
- Item item2 = ( Item ) s2.get( Item.class, itemId );
- assertEquals( "isolation not maintained", initialName, item2.getName() );
-
- t1.commit();
- s1.close();
-
- item2 = ( Item ) s2.get( Item.class, itemId );
- assertEquals( "repeatable read not maintained", initialName, item2.getName() );
- t2.commit();
- s2.close();
-
- s1 = getSessions().openSession();
- t1 = s1.beginTransaction();
- s1.delete( item );
- t1.commit();
- s1.close();
- }
-
- /**
- * Test the equivalent of EJB3 LockModeType.WRITE
- * <p/>
- * From the spec:
- * <p/>
- * If transaction T1 calls lock(entity, LockModeType.WRITE) on a versioned object, the entity
- * manager must avoid the phenomena P1 and P2 (as with LockModeType.READ) and must also force
- * an update (increment) to the entity's version column. A forced version update may be performed immediately,
- * or may be deferred until a flush or commit. If an entity is removed before a deferred version
- * update was to have been applied, the forced version update is omitted, since the underlying database
- * row no longer exists.
- * <p/>
- * The persistence implementation is not required to support calling lock(entity, LockMode-Type.WRITE)
- * on a non-versioned object. When it cannot support a such lock call, it must throw the
- * PersistenceException. When supported, whether for versioned or non-versioned objects, LockMode-Type.WRITE
- * must always prevent the phenomena P1 and P2. For non-versioned objects, whether or
- * not LockModeType.WRITE has any additional behaviour is vendor-specific. Applications that call
- * lock(entity, LockModeType.WRITE) on non-versioned objects will not be portable.
- * <p/>
- * Due to the requirement that LockModeType.WRITE needs to force a version increment,
- * a new Hibernate LockMode was added to support this behavior: {@link org.hibernate.LockMode#FORCE}.
- */
- public void testLockModeTypeWrite() {
- if ( ! readCommittedIsolationMaintained( "ejb3 lock tests" ) ) {
- return;
- }
- final String initialName = "lock test";
- // set up some test data
- Session s1 = getSessions().openSession();
- Transaction t1 = s1.beginTransaction();
- Item item = new Item();
- item.setName( initialName );
- s1.save( item );
- t1.commit();
- s1.close();
-
- Long itemId = item.getId();
- long initialVersion = item.getVersion();
-
- s1 = getSessions().openSession();
- t1 = s1.beginTransaction();
- item = ( Item ) s1.get( Item.class, itemId );
- s1.lock( item, LockMode.FORCE );
- assertEquals( "no forced version increment", initialVersion + 1, item.getVersion() );
-
- s1.lock( item, LockMode.FORCE );
- assertEquals( "subsequent LockMode.FORCE did not no-op", initialVersion + 1, item.getVersion() );
-
- Session s2 = getSessions().openSession();
- Transaction t2 = s2.beginTransaction();
- Item item2 = ( Item ) s2.get( Item.class, itemId );
- assertEquals( "isolation not maintained", initialName, item2.getName() );
-
- item.setName( "updated-1" );
- s1.flush();
- // currently an unfortunate side effect...
- assertEquals( initialVersion + 2, item.getVersion() );
-
- t1.commit();
- s1.close();
-
- item2.setName( "updated" );
- try {
- t2.commit();
- fail( "optimisitc lock should have failed" );
- }
- catch( Throwable ignore ) {
- // expected behavior
- t2.rollback();
- }
- finally {
- s2.close();
- }
-
- s1 = getSessions().openSession();
- t1 = s1.beginTransaction();
- s1.delete( item );
- t1.commit();
- s1.close();
- }
-}
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/lock/JPALockTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/lock/JPALockTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/lock/JPALockTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,180 @@
+package org.hibernate.test.jpa.lock;
+
+import junit.framework.Test;
+
+import org.hibernate.LockMode;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.test.jpa.AbstractJPATest;
+import org.hibernate.test.jpa.Item;
+
+/**
+ * Tests specifically relating to section 3.3.5.3 [Lock Modes] of the
+ * JPA persistence specification (as of the <i>Proposed Final Draft</i>).
+ *
+ * @author Steve Ebersole
+ */
+public class JPALockTest extends AbstractJPATest {
+ public JPALockTest(String name) {
+ super( name );
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( JPALockTest.class );
+ }
+
+ /**
+ * Test the equivalent of EJB3 LockModeType.READ
+ * <p/>
+ * From the spec:
+ * <p/>
+ * If transaction T1 calls lock(entity, LockModeType.READ) on a versioned object, the entity
+ * manager must ensure that neither of the following phenomena can occur:<ul>
+ * <li>P1 (Dirty read): Transaction T1 modifies a row. Another transaction T2 then reads that row and
+ * obtains the modified value, before T1 has committed or rolled back. Transaction T2 eventually
+ * commits successfully; it does not matter whether T1 commits or rolls back and whether it does
+ * so before or after T2 commits.
+ * <li>P2 (Non-repeatable read): Transaction T1 reads a row. Another transaction T2 then modifies or
+ * deletes that row, before T1 has committed. Both transactions eventually commit successfully.
+ * <p/>
+ * This will generally be achieved by the entity manager acquiring a lock on the underlying database row.
+ * Any such lock may be obtained immediately (so long as it is retained until commit completes), or the
+ * lock may be deferred until commit time (although even then it must be retained until the commit completes).
+ * Any implementation that supports repeatable reads in a way that prevents the above phenomena
+ * is permissible.
+ * <p/>
+ * The persistence implementation is not required to support calling lock(entity, LockMode-Type.READ)
+ * on a non-versioned object. When it cannot support such a lock call, it must throw the
+ * PersistenceException. When supported, whether for versioned or non-versioned objects, LockMode-Type.READ
+ * must always prevent the phenomena P1 and P2. Applications that call lock(entity, LockModeType.READ)
+ * on non-versioned objects will not be portable.
+ * <p/>
+ * Odd as it may sound, EJB3 LockModeType.READ actually maps to the Hibernate LockMode.UPGRADE
+ */
+ public void testLockModeTypeRead() {
+ if ( ! readCommittedIsolationMaintained( "ejb3 lock tests" ) ) {
+ return;
+ }
+
+ final String initialName = "lock test";
+ // set up some test data
+ Session s1 = getSessions().openSession();
+ Transaction t1 = s1.beginTransaction();
+ Item item = new Item();
+ item.setName( initialName );
+ s1.save( item );
+ t1.commit();
+ s1.close();
+
+ Long itemId = item.getId();
+
+ // perform the isolated update
+ s1 = getSessions().openSession();
+ t1 = s1.beginTransaction();
+ item = ( Item ) s1.get( Item.class, itemId );
+ s1.lock( item, LockMode.UPGRADE );
+ item.setName( "updated" );
+ s1.flush();
+
+ Session s2 = getSessions().openSession();
+ Transaction t2 = s2.beginTransaction();
+ Item item2 = ( Item ) s2.get( Item.class, itemId );
+ assertEquals( "isolation not maintained", initialName, item2.getName() );
+
+ t1.commit();
+ s1.close();
+
+ item2 = ( Item ) s2.get( Item.class, itemId );
+ assertEquals( "repeatable read not maintained", initialName, item2.getName() );
+ t2.commit();
+ s2.close();
+
+ s1 = getSessions().openSession();
+ t1 = s1.beginTransaction();
+ s1.delete( item );
+ t1.commit();
+ s1.close();
+ }
+
+ /**
+ * Test the equivalent of EJB3 LockModeType.WRITE
+ * <p/>
+ * From the spec:
+ * <p/>
+ * If transaction T1 calls lock(entity, LockModeType.WRITE) on a versioned object, the entity
+ * manager must avoid the phenomena P1 and P2 (as with LockModeType.READ) and must also force
+ * an update (increment) to the entity's version column. A forced version update may be performed immediately,
+ * or may be deferred until a flush or commit. If an entity is removed before a deferred version
+ * update was to have been applied, the forced version update is omitted, since the underlying database
+ * row no longer exists.
+ * <p/>
+ * The persistence implementation is not required to support calling lock(entity, LockMode-Type.WRITE)
+ * on a non-versioned object. When it cannot support a such lock call, it must throw the
+ * PersistenceException. When supported, whether for versioned or non-versioned objects, LockMode-Type.WRITE
+ * must always prevent the phenomena P1 and P2. For non-versioned objects, whether or
+ * not LockModeType.WRITE has any additional behaviour is vendor-specific. Applications that call
+ * lock(entity, LockModeType.WRITE) on non-versioned objects will not be portable.
+ * <p/>
+ * Due to the requirement that LockModeType.WRITE needs to force a version increment,
+ * a new Hibernate LockMode was added to support this behavior: {@link org.hibernate.LockMode#FORCE}.
+ */
+ public void testLockModeTypeWrite() {
+ if ( ! readCommittedIsolationMaintained( "ejb3 lock tests" ) ) {
+ return;
+ }
+ final String initialName = "lock test";
+ // set up some test data
+ Session s1 = getSessions().openSession();
+ Transaction t1 = s1.beginTransaction();
+ Item item = new Item();
+ item.setName( initialName );
+ s1.save( item );
+ t1.commit();
+ s1.close();
+
+ Long itemId = item.getId();
+ long initialVersion = item.getVersion();
+
+ s1 = getSessions().openSession();
+ t1 = s1.beginTransaction();
+ item = ( Item ) s1.get( Item.class, itemId );
+ s1.lock( item, LockMode.FORCE );
+ assertEquals( "no forced version increment", initialVersion + 1, item.getVersion() );
+
+ s1.lock( item, LockMode.FORCE );
+ assertEquals( "subsequent LockMode.FORCE did not no-op", initialVersion + 1, item.getVersion() );
+
+ Session s2 = getSessions().openSession();
+ Transaction t2 = s2.beginTransaction();
+ Item item2 = ( Item ) s2.get( Item.class, itemId );
+ assertEquals( "isolation not maintained", initialName, item2.getName() );
+
+ item.setName( "updated-1" );
+ s1.flush();
+ // currently an unfortunate side effect...
+ assertEquals( initialVersion + 2, item.getVersion() );
+
+ t1.commit();
+ s1.close();
+
+ item2.setName( "updated" );
+ try {
+ t2.commit();
+ fail( "optimisitc lock should have failed" );
+ }
+ catch( Throwable ignore ) {
+ // expected behavior
+ t2.rollback();
+ }
+ finally {
+ s2.close();
+ }
+
+ s1 = getSessions().openSession();
+ t1 = s1.beginTransaction();
+ s1.delete( item );
+ t1.commit();
+ s1.close();
+ }
+}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/lock/RepeatableReadTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/lock/RepeatableReadTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/lock/RepeatableReadTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,19 +1,20 @@
package org.hibernate.test.jpa.lock;
+import java.math.BigDecimal;
+
+import junit.framework.Test;
+
+import org.hibernate.LockMode;
import org.hibernate.Session;
+import org.hibernate.StaleObjectStateException;
import org.hibernate.Transaction;
-import org.hibernate.LockMode;
-import org.hibernate.StaleObjectStateException;
+import org.hibernate.dialect.SQLServerDialect;
import org.hibernate.exception.SQLGrammarException;
-import org.hibernate.dialect.SQLServerDialect;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.test.jpa.AbstractJPATest;
import org.hibernate.test.jpa.Item;
import org.hibernate.test.jpa.Part;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import java.math.BigDecimal;
-
/**
* Test that the Hibernate Session complies with REPEATABLE_READ isolation
* semantics.
@@ -27,7 +28,7 @@
}
public static Test suite() {
- return new TestSuite( org.hibernate.test.jpa.lock.RepeatableReadTest.class );
+ return new FunctionalTestClassTestSuite( RepeatableReadTest.class );
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/proxy/JPAProxyTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/proxy/JPAProxyTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/proxy/JPAProxyTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,13 +1,14 @@
package org.hibernate.test.jpa.proxy;
+import junit.framework.AssertionFailedError;
+import junit.framework.Test;
+
+import org.hibernate.Hibernate;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.test.jpa.AbstractJPATest;
import org.hibernate.test.jpa.Item;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.hibernate.Hibernate;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.framework.AssertionFailedError;
/**
* Test relation between proxies and get()/load() processing
@@ -21,7 +22,7 @@
}
public static Test suite() {
- return new TestSuite( JPAProxyTest.class );
+ return new FunctionalTestClassTestSuite( JPAProxyTest.class );
}
public void testEjb3ProxyUsage() {
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/ql/JPAQLComplianceTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/ql/JPAQLComplianceTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/ql/JPAQLComplianceTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,10 +1,11 @@
package org.hibernate.test.jpa.ql;
-import org.hibernate.test.jpa.AbstractJPATest;
-import org.hibernate.Session;
import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.Session;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.test.jpa.AbstractJPATest;
+
/**
* Tests for various JPAQL compliance issues
*
@@ -16,7 +17,7 @@
}
public static Test suite() {
- return new TestSuite( JPAQLComplianceTest.class );
+ return new FunctionalTestClassTestSuite( JPAQLComplianceTest.class );
}
public void testAliasNameSameAsUnqualifiedEntityName() {
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/ql/NativeQueryTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/ql/NativeQueryTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/ql/NativeQueryTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,30 @@
+package org.hibernate.test.jpa.ql;
+
+import junit.framework.Test;
+
+import org.hibernate.Session;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.test.jpa.AbstractJPATest;
+
+/**
+ * todo: describe NativeQueryTest
+ *
+ * @author Steve Ebersole
+ */
+public class NativeQueryTest extends AbstractJPATest {
+ public NativeQueryTest(String name) {
+ super( name );
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( NativeQueryTest.class );
+ }
+
+ public void testJpaStylePositionalParametersInNativeSql() {
+ Session s = openSession();
+ s.beginTransaction();
+ s.createSQLQuery( "select NAME from EJB3_ITEM where ITEM_ID = ?1" ).setParameter( "1", "123" ).list();
+ s.getTransaction().commit();
+ s.close();
+ }
+}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/removed/RemovedEntityTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/removed/RemovedEntityTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/removed/RemovedEntityTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,10 +1,11 @@
package org.hibernate.test.jpa.removed;
+import junit.framework.Test;
+
+import org.hibernate.Session;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.test.jpa.AbstractJPATest;
import org.hibernate.test.jpa.Item;
-import org.hibernate.Session;
-import junit.framework.Test;
-import junit.framework.TestSuite;
/**
*
@@ -16,7 +17,7 @@
}
public static Test suite() {
- return new TestSuite( RemovedEntityTest.class );
+ return new FunctionalTestClassTestSuite( RemovedEntityTest.class );
}
public void testRemoveThenContains() {
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/lazycache/InstrumentCacheTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/lazycache/InstrumentCacheTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/lazycache/InstrumentCacheTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -2,29 +2,46 @@
package org.hibernate.test.lazycache;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.intercept.FieldInterceptionHelper;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
-import org.hibernate.test.TestCase;
+import org.hibernate.intercept.FieldInterceptionHelper;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class InstrumentCacheTest extends TestCase {
+public class InstrumentCacheTest extends FunctionalTestCase {
public InstrumentCacheTest(String str) {
super(str);
}
- protected boolean overrideCacheStrategy() {
+ public String[] getMappings() {
+ return new String[] { "lazycache/Documents.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
+ }
+
+ public boolean overrideCacheStrategy() {
return false;
}
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( InstrumentCacheTest.class );
+ }
+
+ public static boolean isRunnable() {
+ // TODO : this could be handled via appliesTo()...
+ return FieldInterceptionHelper.isInstrumented( new Document() );
+ }
+
public void testInitFromCache() {
Session s;
Transaction tx;
@@ -65,21 +82,5 @@
s.close();
}
- protected String[] getMappings() {
- return new String[] { "lazycache/Documents.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(InstrumentCacheTest.class);
- }
-
- public static boolean isRunnable() {
- return FieldInterceptionHelper.isInstrumented( new Document() );
- }
-
- protected void configure(Configuration cfg) {
- cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/lazycache/InstrumentCacheTest2.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/lazycache/InstrumentCacheTest2.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/lazycache/InstrumentCacheTest2.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -2,25 +2,41 @@
package org.hibernate.test.lazycache;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.intercept.FieldInterceptionHelper;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
-import org.hibernate.test.TestCase;
+import org.hibernate.intercept.FieldInterceptionHelper;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class InstrumentCacheTest2 extends TestCase {
+public class InstrumentCacheTest2 extends FunctionalTestCase {
public InstrumentCacheTest2(String str) {
super(str);
}
+ public String[] getMappings() {
+ return new String[] { "lazycache/Documents.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( InstrumentCacheTest2.class );
+ }
+
+ public static boolean isRunnable() {
+ return FieldInterceptionHelper.isInstrumented( new Document() );
+ }
+
public void testInitFromCache() {
Session s;
Transaction tx;
@@ -60,22 +76,6 @@
tx.commit();
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "lazycache/Documents.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(InstrumentCacheTest2.class);
- }
-
- public static boolean isRunnable() {
- return FieldInterceptionHelper.isInstrumented( new Document() );
- }
-
- protected void configure(Configuration cfg) {
- cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/lazyonetoone/LazyOneToOneTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/lazyonetoone/LazyOneToOneTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/lazyonetoone/LazyOneToOneTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -4,25 +4,42 @@
import java.util.Date;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.intercept.FieldInterceptionHelper;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
-import org.hibernate.test.TestCase;
+import org.hibernate.intercept.FieldInterceptionHelper;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class LazyOneToOneTest extends TestCase {
+public class LazyOneToOneTest extends FunctionalTestCase {
public LazyOneToOneTest(String str) {
super(str);
}
+ public String[] getMappings() {
+ return new String[] { "lazyonetoone/Person.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty(Environment.MAX_FETCH_DEPTH, "2");
+ cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "false");
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( LazyOneToOneTest.class );
+ }
+
+ public static boolean isRunnable() {
+ return FieldInterceptionHelper.isInstrumented( new Person() );
+ }
+
public void testLazy() throws Exception {
Session s = openSession();
Transaction t = s.beginTransaction();
@@ -64,21 +81,5 @@
t.commit();
s.close();
}
-
- protected void configure(Configuration cfg) {
- cfg.setProperty(Environment.MAX_FETCH_DEPTH, "2");
- cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "false");
- }
- protected String[] getMappings() {
- return new String[] { "lazyonetoone/Person.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(LazyOneToOneTest.class);
- }
-
- public static boolean isRunnable() {
- return FieldInterceptionHelper.isInstrumented( new Person() );
- }
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/ABCProxyTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/ABCProxyTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/ABCProxyTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -7,13 +7,14 @@
import java.util.Map;
import junit.framework.Test;
-import junit.framework.TestSuite;
import junit.textui.TestRunner;
+
import org.hibernate.Hibernate;
import org.hibernate.LockMode;
+import org.hibernate.Transaction;
import org.hibernate.classic.Session;
import org.hibernate.dialect.HSQLDialect;
-import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
public class ABCProxyTest extends LegacyTestCase {
@@ -293,7 +294,7 @@
}
public static Test suite() {
- return new TestSuite(ABCProxyTest.class);
+ return new FunctionalTestClassTestSuite( ABCProxyTest.class );
}
public static void main(String[] args) throws Exception {
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/ABCTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/ABCTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/ABCTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -8,6 +8,7 @@
import junit.textui.TestRunner;
import org.hibernate.classic.Session;
import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
public class ABCTest extends LegacyTestCase {
@@ -153,7 +154,7 @@
}
public static Test suite() {
- return new TestSuite(ABCTest.class);
+ return new FunctionalTestClassTestSuite( ABCTest.class );
}
public static void main(String[] args) throws Exception {
@@ -162,6 +163,3 @@
}
-
-
-
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/CacheTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/CacheTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/CacheTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -2,29 +2,28 @@
package org.hibernate.test.legacy;
import junit.framework.Test;
-import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.hibernate.cache.Cache;
import org.hibernate.cache.CacheConcurrencyStrategy;
import org.hibernate.cache.CacheProvider;
import org.hibernate.cache.ReadWriteCache;
+import org.hibernate.cache.HashtableCacheProvider;
import org.hibernate.cache.CacheConcurrencyStrategy.SoftLock;
+import org.hibernate.junit.UnitTestCase;
-public class CacheTest extends TestCase {
+public class CacheTest extends UnitTestCase {
- public CacheTest(String arg0) {
- super(arg0);
+ public CacheTest(String name) {
+ super( name );
}
public static Test suite() {
- return new TestSuite(CacheTest.class);
+ return new TestSuite( CacheTest.class );
}
public void testCaches() throws Exception {
- //doTestCache( new CoherenceCacheProvider() );
-// steve - commented this out becuase it is breaking the build after the package rename
- //doTestCache( new Provider() );
+ doTestCache( new HashtableCacheProvider() );
}
public void doTestCache(CacheProvider cacheProvider) throws Exception {
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/ComponentNotNullTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/ComponentNotNullTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/ComponentNotNullTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -4,11 +4,12 @@
import java.util.ArrayList;
import junit.framework.Test;
-import junit.framework.TestSuite;
import junit.textui.TestRunner;
+
import org.hibernate.PropertyValueException;
import org.hibernate.Session;
import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* Test some cases of not-null properties inside components.
@@ -21,10 +22,7 @@
super(x);
}
- /**
- * @see org.hibernate.test.TestCase#getMappings()
- */
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] {
"legacy/ComponentNotNullMaster.hbm.xml",
"legacy/One.hbm.xml",
@@ -33,7 +31,7 @@
}
public static Test suite() {
- return new TestSuite(ComponentNotNullTest.class);
+ return new FunctionalTestClassTestSuite( ComponentNotNullTest.class );
}
public static void main(String[] args) throws Exception {
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/ConfigurationPerformanceTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/ConfigurationPerformanceTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/ConfigurationPerformanceTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -16,12 +16,12 @@
import java.io.PrintWriter;
import junit.framework.Test;
-import junit.framework.TestCase;
import junit.framework.TestSuite;
import junit.textui.TestRunner;
import org.hibernate.HibernateException;
import org.hibernate.SessionFactory;
+import org.hibernate.junit.UnitTestCase;
import org.hibernate.cfg.Configuration;
import org.hibernate.classic.Session;
@@ -29,7 +29,7 @@
* @author MAX
*
*/
-public class ConfigurationPerformanceTest extends TestCase /** purposely not extending hibernate test case to manage the configuration loading 100% on it's own */ {
+public class ConfigurationPerformanceTest extends UnitTestCase {
String[] files = new String[] {
"legacy/ABC.hbm.xml",
@@ -76,7 +76,11 @@
};
boolean keepFilesAround = false ; // set to true to be able to "coldstart" start.
-
+
+ public ConfigurationPerformanceTest(String string) {
+ super( string );
+ }
+
public void testLoadingAndSerializationOfConfiguration() throws HibernateException, FileNotFoundException, IOException, ClassNotFoundException {
String prefix = "./test/org/hibernate/test/";
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/CustomPersister.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/CustomPersister.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/CustomPersister.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -77,7 +77,7 @@
public String getEntityName() {
return Custom.class.getName();
}
-
+
public boolean isSubclassEntityName(String entityName) {
return Custom.class.getName().equals(entityName);
}
@@ -621,4 +621,5 @@
public EntityMetamodel getEntityMetamodel() {
return null;
}
+
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/CustomSQLTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/CustomSQLTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/CustomSQLTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -5,7 +5,10 @@
import java.util.ArrayList;
import java.util.List;
+import junit.framework.Test;
+
import org.hibernate.HibernateException;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.classic.Session;
import org.hibernate.dialect.HSQLDialect;
import org.hibernate.dialect.MySQLDialect;
@@ -24,6 +27,10 @@
return new String[] { "legacy/CustomSQL.hbm.xml" };
}
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( CustomSQLTest.class );
+ }
+
public void testInsert() throws HibernateException, SQLException {
if ( getDialect() instanceof HSQLDialect ) return;
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/FooBar.hbm.xml
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/FooBar.hbm.xml 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/FooBar.hbm.xml 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,13 +1,13 @@
<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
+<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping default-lazy="false" package="org.hibernate.test.legacy">
<import class="Result"/>
<import class="Named"/>
-
- <class
+
+ <class
name="Foo"
table="`foos`"
proxy="FooProxy"
@@ -16,9 +16,9 @@
dynamic-insert="true"
dynamic-update="true"
select-before-update="true">
-
+
<!--cache-->
-
+
<id name="key" type="string">
<column name="`foo_idcolumnname123`" length="36"/>
<generator class="uuid.hex">
@@ -68,23 +68,23 @@
<property name="nullBlob" type="serializable"/>
<property name="binary" column="bin_"/>
<property name="theLocale" access="field" column="`localeayzabc123`"/>
-
+
<property name="formula" formula="int_/2"/>
-
+
<property name="custom" type="org.hibernate.test.legacy.DoubleStringType" access="field">
<column name="first_name" length="66"/>
<column name="surname" length="66"/>
</property>
-
+
<component name="component">
- <property name="count" column="count_" type="int" not-null="true"/>
+ <property name="count" column="count_" type="int" not-null="true"/>
<property name="name">
- <column name="name_" length="32" not-null="true"/>
+ <column name="name_" length="32" not-null="true"/>
</property>
- <many-to-one name="glarch"
- column="g__"
- cascade="all"
- class="org.hibernate.test.legacy.Glarch"
+ <many-to-one name="glarch"
+ column="g__"
+ cascade="all"
+ class="org.hibernate.test.legacy.Glarch"
lazy="proxy"
outer-join="true"/>
<property name="null" column="cmpnt_null_"/>
@@ -96,11 +96,11 @@
<index column="i"/>
<element column="date_" type="time"/>
</array>
- <many-to-one name="fee"
- column="fee_sub"
- cascade="all"
- class="Fee"
- outer-join="false"
+ <many-to-one name="fee"
+ column="fee_sub"
+ cascade="all"
+ class="Fee"
+ outer-join="false"
access="field"/>
</component>
<array name="importantDates" table="foo_dates">
@@ -112,37 +112,37 @@
<component name="nullComponent">
<property name="name" column="null_cmpnt_"/>
</component>
-
+
<join table="jointable">
<key column="fooid" on-delete="cascade"/>
<property name="joinedProp"/>
</join>
-
+
<join table="foo_dep_table">
<key column="fooid"/>
- <many-to-one name="dependent"
- class="org.hibernate.test.legacy.Fee"
- cascade="all"
+ <many-to-one name="dependent"
+ class="org.hibernate.test.legacy.Fee"
+ cascade="all"
not-null="true"/>
</join>
-
+
<subclass
name="Trivial"
- proxy="FooProxy"
+ proxy="FooProxy"
discriminator-value="T"/>
-
- <subclass
- name="Abstract"
- proxy="AbstractProxy"
+
+ <subclass
+ name="Abstract"
+ proxy="AbstractProxy"
discriminator-value="null">
<set name="abstracts" batch-size="2">
<key column="abstract_id"/>
<one-to-many class="Abstract"/>
</set>
<property name="time" column="the_time"/>
-
- <subclass
- name="Bar"
+
+ <subclass
+ name="Bar"
proxy="BarProxy"
discriminator-value="B">
<many-to-one name="baz"/>
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/FooBarTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/FooBarTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/FooBarTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -20,7 +20,6 @@
import java.util.TreeSet;
import junit.framework.Test;
-import junit.framework.TestSuite;
import junit.textui.TestRunner;
import org.hibernate.Criteria;
@@ -30,7 +29,6 @@
import org.hibernate.HibernateException;
import org.hibernate.LazyInitializationException;
import org.hibernate.LockMode;
-import org.hibernate.ObjectDeletedException;
import org.hibernate.ObjectNotFoundException;
import org.hibernate.Query;
import org.hibernate.QueryException;
@@ -56,14 +54,14 @@
import org.hibernate.dialect.PointbaseDialect;
import org.hibernate.dialect.PostgreSQLDialect;
import org.hibernate.dialect.SAPDBDialect;
-import org.hibernate.dialect.SQLServerDialect;
import org.hibernate.dialect.SybaseDialect;
import org.hibernate.dialect.TimesTenDialect;
+import org.hibernate.dialect.Dialect;
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.jmx.HibernateService;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.mapping.RootClass;
import org.hibernate.proxy.HibernateProxy;
-import org.hibernate.test.TestCase;
import org.hibernate.type.Type;
import org.hibernate.util.JoinedIterator;
import org.hibernate.util.SerializationHelper;
@@ -75,6 +73,44 @@
super(arg);
}
+ public String[] getMappings() {
+ return new String[] {
+ "legacy/FooBar.hbm.xml",
+ "legacy/Baz.hbm.xml",
+ "legacy/Qux.hbm.xml",
+ "legacy/Glarch.hbm.xml",
+ "legacy/Fum.hbm.xml",
+ "legacy/Fumm.hbm.xml",
+ "legacy/Fo.hbm.xml",
+ "legacy/One.hbm.xml",
+ "legacy/Many.hbm.xml",
+ "legacy/Immutable.hbm.xml",
+ "legacy/Fee.hbm.xml",
+ "legacy/Vetoer.hbm.xml",
+ "legacy/Holder.hbm.xml",
+ "legacy/Location.hbm.xml",
+ "legacy/Stuff.hbm.xml",
+ "legacy/Container.hbm.xml",
+ "legacy/Simple.hbm.xml",
+ "legacy/XY.hbm.xml"
+ };
+ }
+
+ public void configure(Configuration cfg) {
+ super.configure( cfg );
+ if ( Dialect.getDialect() instanceof OracleDialect ) {
+ ( (RootClass) cfg.getClassMapping("org.hibernate.test.legacy.Foo") ).setForceDiscriminator(false);
+ }
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( FooBarTest.class );
+ }
+
+ public static void main(String[] args) throws Exception {
+ TestRunner.run( suite() );
+ }
+
public void testSaveOrUpdateCopyAny() throws Exception {
Session s = openSession();
Bar bar = new Bar();
@@ -4742,42 +4778,4 @@
s.close();
}
- public static Test suite() {
- return new TestSuite(FooBarTest.class);
- }
-
- public static void main(String[] args) throws Exception {
- TestRunner.run( suite() );
- }
-
- protected void configure(Configuration cfg) {
- super.configure( cfg );
- if ( getDialect() instanceof OracleDialect ) {
- ( (RootClass) cfg.getClassMapping("org.hibernate.test.legacy.Foo") ).setForceDiscriminator(false);
- }
- }
-
- protected String[] getMappings() {
- return new String[] {
- "legacy/FooBar.hbm.xml",
- "legacy/Baz.hbm.xml",
- "legacy/Qux.hbm.xml",
- "legacy/Glarch.hbm.xml",
- "legacy/Fum.hbm.xml",
- "legacy/Fumm.hbm.xml",
- "legacy/Fo.hbm.xml",
- "legacy/One.hbm.xml",
- "legacy/Many.hbm.xml",
- "legacy/Immutable.hbm.xml",
- "legacy/Fee.hbm.xml",
- "legacy/Vetoer.hbm.xml",
- "legacy/Holder.hbm.xml",
- "legacy/Location.hbm.xml",
- "legacy/Stuff.hbm.xml",
- "legacy/Container.hbm.xml",
- "legacy/Simple.hbm.xml",
- "legacy/XY.hbm.xml"
- };
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/FumTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/FumTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/FumTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -20,7 +20,6 @@
import java.util.Set;
import junit.framework.Test;
-import junit.framework.TestSuite;
import junit.textui.TestRunner;
import org.hibernate.Criteria;
@@ -39,7 +38,8 @@
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.dialect.PointbaseDialect;
import org.hibernate.dialect.TimesTenDialect;
-import org.hibernate.transform.AliasToBeanResultTransformer;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.transform.Transformers;
import org.hibernate.type.DateType;
import org.hibernate.type.EntityType;
@@ -53,6 +53,37 @@
public FumTest(String arg) {
super(arg);
}
+
+ public String[] getMappings() {
+ return new String[] {
+ "legacy/FooBar.hbm.xml",
+ "legacy/Baz.hbm.xml",
+ "legacy/Qux.hbm.xml",
+ "legacy/Glarch.hbm.xml",
+ "legacy/Fum.hbm.xml",
+ "legacy/Fumm.hbm.xml",
+ "legacy/Fo.hbm.xml",
+ "legacy/One.hbm.xml",
+ "legacy/Many.hbm.xml",
+ "legacy/Immutable.hbm.xml",
+ "legacy/Fee.hbm.xml",
+ "legacy/Vetoer.hbm.xml",
+ "legacy/Holder.hbm.xml",
+ "legacy/Location.hbm.xml",
+ "legacy/Stuff.hbm.xml",
+ "legacy/Container.hbm.xml",
+ "legacy/Simple.hbm.xml",
+ "legacy/Middle.hbm.xml"
+ };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( FumTest.class );
+ }
+
+ public static void main(String[] args) throws Exception {
+ TestRunner.run( suite() );
+ }
public void testQuery() {
Session s = openSession();
@@ -278,7 +309,7 @@
private FumCompositeID fumKey(String str, boolean aCompositeQueryTest) {
FumCompositeID id = new FumCompositeID();
- if ( getDialect() instanceof MckoiDialect ) {
+ if ( Dialect.getDialect() instanceof MckoiDialect ) {
GregorianCalendar now = new GregorianCalendar();
GregorianCalendar cal = new GregorianCalendar(
now.get(java.util.Calendar.YEAR),
@@ -841,36 +872,6 @@
}
}
- public String[] getMappings() {
- return new String[] {
- "legacy/FooBar.hbm.xml",
- "legacy/Baz.hbm.xml",
- "legacy/Qux.hbm.xml",
- "legacy/Glarch.hbm.xml",
- "legacy/Fum.hbm.xml",
- "legacy/Fumm.hbm.xml",
- "legacy/Fo.hbm.xml",
- "legacy/One.hbm.xml",
- "legacy/Many.hbm.xml",
- "legacy/Immutable.hbm.xml",
- "legacy/Fee.hbm.xml",
- "legacy/Vetoer.hbm.xml",
- "legacy/Holder.hbm.xml",
- "legacy/Location.hbm.xml",
- "legacy/Stuff.hbm.xml",
- "legacy/Container.hbm.xml",
- "legacy/Simple.hbm.xml",
- "legacy/Middle.hbm.xml"
- };
- }
-
- public static Test suite() {
- return new TestSuite(FumTest.class);
- }
- public static void main(String[] args) throws Exception {
- TestRunner.run( suite() );
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/Glarch.hbm.xml
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/Glarch.hbm.xml 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/Glarch.hbm.xml 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,14 +1,14 @@
<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
+<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping default-lazy="false" package="org.hibernate.test.legacy">
- <class name="Glarch"
- table="`glarchez`"
+ <class name="Glarch"
+ table="`glarchez`"
proxy="GlarchProxy"
dynamic-update="true">
-
+
<!--cache-->
<id type="string" column="tha_key" length="32">
<generator class="uuid"/>
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/IJ2Test.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/IJ2Test.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/IJ2Test.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -3,27 +3,30 @@
import java.io.Serializable;
-
-
import junit.framework.Test;
-import junit.framework.TestSuite;
-
-
-
import org.hibernate.LockMode;
-
import org.hibernate.classic.Session;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
public class IJ2Test extends LegacyTestCase {
- public void testUnionSubclass() throws Exception {
+ public IJ2Test(String x) {
+ super(x);
+ }
- //if ( getDialect() instanceof MySQLDialect ) return;
+ public String[] getMappings() {
+ return new String[] { "legacy/IJ2.hbm.xml" };
+ }
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( IJ2Test.class );
+ }
+
+ public void testUnionSubclass() throws Exception {
Session s = getSessions().openSession();
I i = new I();
i.setName( "i" );
@@ -123,16 +126,4 @@
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "legacy/IJ2.hbm.xml" };
- }
-
- public IJ2Test(String x) {
- super(x);
- }
-
- public static Test suite() {
- return new TestSuite(IJ2Test.class);
- }
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/IJTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/IJTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/IJTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -4,18 +4,30 @@
import java.io.Serializable;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.LockMode;
import org.hibernate.classic.Session;
import org.hibernate.dialect.HSQLDialect;
import org.hibernate.dialect.OracleDialect;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
public class IJTest extends LegacyTestCase {
+ public IJTest(String x) {
+ super(x);
+ }
+
+ public String[] getMappings() {
+ return new String[] { "legacy/IJ.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( IJTest.class );
+ }
+
public void testFormulaDiscriminator() throws Exception {
if ( ( getDialect() instanceof OracleDialect ) || ( getDialect() instanceof HSQLDialect ) ) return;
Session s = getSessions().openSession();
@@ -69,16 +81,4 @@
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "legacy/IJ.hbm.xml" };
- }
-
- public IJTest(String x) {
- super(x);
- }
-
- public static Test suite() {
- return new TestSuite(IJTest.class);
- }
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/LegacyTestCase.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/LegacyTestCase.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/LegacyTestCase.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,15 +1,15 @@
package org.hibernate.test.legacy;
-import org.hibernate.test.TestCase;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.hql.classic.ClassicQueryTranslatorFactory;
import org.hibernate.util.StringHelper;
+import org.hibernate.junit.functional.FunctionalTestCase;
/**
* @author Steve Ebersole
*/
-public abstract class LegacyTestCase extends TestCase {
+public abstract class LegacyTestCase extends FunctionalTestCase {
public static final String USE_ANTLR_PARSER_PROP = "legacy.use_antlr_hql_parser";
private final boolean useAntlrParser;
@@ -28,7 +28,7 @@
}
}
- protected void configure(Configuration cfg) {
+ public void configure(Configuration cfg) {
super.configure( cfg );
if ( !useAntlrParser ) {
cfg.setProperty( Environment.QUERY_TRANSLATOR, ClassicQueryTranslatorFactory.class.getName() );
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/MapTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/MapTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/MapTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -6,24 +6,36 @@
import java.util.List;
import java.util.Map;
+import junit.framework.Test;
+
+import org.hibernate.EntityMode;
import org.hibernate.Session;
-import org.hibernate.criterion.Example;
-import org.hibernate.criterion.Expression;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
-import org.hibernate.EntityMode;
+import org.hibernate.criterion.Example;
+import org.hibernate.criterion.Expression;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
-
public class MapTest extends LegacyTestCase {
public MapTest(String x) {
super(x);
}
+ public String[] getMappings() {
+ return new String[] { "legacy/Map.hbm.xml", "legacy/Commento.hbm.xml", "legacy/Marelo.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ super.configure( cfg );
+ cfg.setProperty( Environment.DEFAULT_ENTITY_MODE, EntityMode.MAP.toString() );
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( MapTest.class );
+ }
+
public void testMap() throws Exception {
Session s = openSession().getSession(EntityMode.MAP);
@@ -148,28 +160,5 @@
s.close();
}
- public String[] getMappings() {
- return new String[] { "legacy/Map.hbm.xml", "legacy/Commento.hbm.xml", "legacy/Marelo.hbm.xml" };
- }
-
- protected void configure(Configuration cfg) {
- super.configure( cfg );
- cfg.setProperty(Environment.DEFAULT_ENTITY_MODE, EntityMode.MAP.toString());
- }
-
- public static Test suite() {
- return new TestSuite(MapTest.class);
- }
-
- public static void main(String[] args) throws Exception {
- TestRunner.run( suite() );
- }
-
}
-
-
-
-
-
-
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/MasterDetailTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/MasterDetailTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/MasterDetailTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -10,8 +10,6 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
import org.hibernate.Hibernate;
import org.hibernate.LockMode;
@@ -26,6 +24,7 @@
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.dialect.Oracle9Dialect;
import org.hibernate.dialect.SAPDBDialect;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.mapping.MetaAttribute;
import org.hibernate.mapping.PersistentClass;
@@ -36,6 +35,23 @@
super(arg);
}
+ public String[] getMappings() {
+ return new String[] {
+ "legacy/MasterDetail.hbm.xml",
+ "legacy/Custom.hbm.xml",
+ "legacy/Category.hbm.xml",
+ "legacy/Nameable.hbm.xml",
+ "legacy/SingleSeveral.hbm.xml",
+ "legacy/WZ.hbm.xml",
+ "legacy/UpDown.hbm.xml",
+ "legacy/Eye.hbm.xml"
+ };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( MasterDetailTest.class );
+ }
+
public void testOuterJoin() throws Exception {
Session s = openSession();
Eye e = new Eye();
@@ -1017,31 +1033,4 @@
s.close();
}
- public String[] getMappings() {
- return new String[] {
- "legacy/MasterDetail.hbm.xml",
- "legacy/Custom.hbm.xml",
- "legacy/Category.hbm.xml",
- "legacy/Nameable.hbm.xml",
- "legacy/SingleSeveral.hbm.xml",
- "legacy/WZ.hbm.xml",
- "legacy/UpDown.hbm.xml",
- "legacy/Eye.hbm.xml"
- };
- }
-
- public static Test suite() {
- return new TestSuite(MasterDetailTest.class);
- }
-
- public static void main(String[] args) throws Exception {
- TestRunner.run( suite() );
- }
-
}
-
-
-
-
-
-
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/MultiTableTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/MultiTableTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/MultiTableTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -10,18 +10,15 @@
import java.util.Set;
import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
import org.hibernate.Criteria;
import org.hibernate.FetchMode;
import org.hibernate.LockMode;
+import org.hibernate.Transaction;
import org.hibernate.classic.Session;
import org.hibernate.criterion.Expression;
-import org.hibernate.Transaction;
-import org.hibernate.id.PostInsertIdentifierGenerator;
import org.hibernate.dialect.MySQLDialect;
-import org.hibernate.dialect.SybaseDialect;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
public class MultiTableTest extends LegacyTestCase {
@@ -30,6 +27,14 @@
super(arg0);
}
+ public String[] getMappings() {
+ return new String[] { "legacy/Multi.hbm.xml", "legacy/MultiExtends.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( MultiTableTest.class );
+ }
+
public void testCriteria() throws Exception {
Session s = openSession();
Transaction t = s.beginTransaction();
@@ -614,15 +619,4 @@
sess.close();
}
- public String[] getMappings() {
- return new String[] { "legacy/Multi.hbm.xml", "legacy/MultiExtends.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(MultiTableTest.class);
- }
-
- public static void main(String[] args) throws Exception {
- TestRunner.run( suite() );
- }
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/NonReflectiveBinderTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/NonReflectiveBinderTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/NonReflectiveBinderTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -5,10 +5,8 @@
import java.util.Map;
import junit.framework.Test;
-import junit.framework.TestCase;
import junit.framework.TestSuite;
-import org.hibernate.MappingException;
import org.hibernate.cfg.Configuration;
import org.hibernate.mapping.Bag;
import org.hibernate.mapping.Collection;
@@ -16,57 +14,38 @@
import org.hibernate.mapping.MetaAttribute;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
+import org.hibernate.junit.UnitTestCase;
-public class NonReflectiveBinderTest extends TestCase {
+public class NonReflectiveBinderTest extends UnitTestCase {
- Configuration cfg;
- private Class lastTestClass;
+ private Configuration cfg;
- public static Test suite() {
- return new TestSuite(NonReflectiveBinderTest.class);
+ public NonReflectiveBinderTest(String x) {
+ super( x );
}
- Configuration getCfg() {
- return cfg;
- }
-
public String[] getMappings() {
return new String[] { "legacy/Wicked.hbm.xml"};
}
- void buildConfiguration(String[] files) throws MappingException {
-
- try {
- setCfg( new Configuration() );
-
- for (int i=0; i<files.length; i++) {
- if ( !files[i].startsWith("net/") ) files[i] = "org/hibernate/test/" + files[i];
- getCfg().addResource( files[i], TestCase.class.getClassLoader() );
- }
- } catch (MappingException e) {
- throw e;
- }
-
+ public static Test suite() {
+ return new TestSuite( NonReflectiveBinderTest.class );
}
protected void setUp() throws Exception {
- if ( getCfg()==null || lastTestClass!=getClass() ) {
- buildConfiguration( getMappings() );
- lastTestClass = getClass();
- }
+ super.setUp();
+ cfg = new Configuration()
+ .addResource( "org/hibernate/test/legacy/Wicked.hbm.xml" );
+ cfg.buildMappings();
}
- /**
- * @param configuration
- */
- private void setCfg(Configuration configuration) {
- cfg = configuration;
+ protected void tearDown() throws Exception {
+ cfg = null;
+ super.tearDown();
}
public void testMetaInheritance() {
- Configuration cfg = getCfg();
- cfg.buildMappings();
PersistentClass cm = cfg.getClassMapping("org.hibernate.test.legacy.Wicked");
Map m = cm.getMetaAttributes();
assertNotNull(m);
@@ -120,9 +99,6 @@
// HBX-718
public void testNonMutatedInheritance() {
- Configuration cfg = getCfg();
- cfg.buildMappings();
-
PersistentClass cm = cfg.getClassMapping("org.hibernate.test.legacy.Wicked");
MetaAttribute metaAttribute = cm.getMetaAttribute( "globalmutated" );
@@ -204,8 +180,6 @@
}
public void testComparator() {
- Configuration cfg = getCfg();
- cfg.buildMappings();
PersistentClass cm = cfg.getClassMapping("org.hibernate.test.legacy.Wicked");
Property property = cm.getProperty("sortedEmployee");
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/OneToOneCacheTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/OneToOneCacheTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/OneToOneCacheTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -4,11 +4,11 @@
import java.io.Serializable;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* Simple testcase to illustrate HB-992
@@ -17,44 +17,48 @@
*/
public class OneToOneCacheTest extends LegacyTestCase {
+ private Serializable generatedId;
+
public OneToOneCacheTest(String x) {
- super(x);
+ super( x );
}
+ public String[] getMappings() {
+ return new String[] { "legacy/Object2.hbm.xml", "legacy/MainObject.hbm.xml" };
+ }
+
public static Test suite() {
- return new TestSuite(OneToOneCacheTest.class);
+ return new FunctionalTestClassTestSuite( OneToOneCacheTest.class );
}
- private Serializable generatedId;
-
public void testOneToOneCache() throws HibernateException {
- //create a new MainObject
- createMainObject();
- // load the MainObject
- readMainObject();
+ //create a new MainObject
+ createMainObject();
+ // load the MainObject
+ readMainObject();
- //create and add Ojbect2
- addObject2();
+ //create and add Ojbect2
+ addObject2();
- //here the newly created Object2 is written to the database
- //but the MainObject does not know it yet
- MainObject mainObject = readMainObject();
+ //here the newly created Object2 is written to the database
+ //but the MainObject does not know it yet
+ MainObject mainObject = readMainObject();
- assertNotNull(mainObject.getObj2());
+ assertNotNull( mainObject.getObj2() );
- // after evicting, it works.
- getSessions().evict(MainObject.class);
+ // after evicting, it works.
+ getSessions().evict( MainObject.class );
- mainObject = readMainObject();
+ mainObject = readMainObject();
- assertNotNull(mainObject.getObj2());
+ assertNotNull( mainObject.getObj2() );
}
/**
* creates a new MainObject
- *
+ * <p/>
* one hibernate transaction !
*/
private void createMainObject() throws HibernateException {
@@ -62,9 +66,9 @@
Transaction tx = session.beginTransaction();
MainObject mo = new MainObject();
- mo.setDescription("Main Test");
+ mo.setDescription( "Main Test" );
- generatedId = session.save(mo);
+ generatedId = session.save( mo );
tx.commit();
session.close();
@@ -73,7 +77,7 @@
/**
* loads the newly created MainObject
* and adds a new Object2 to it
- *
+ * <p/>
* one hibernate transaction
*/
private void addObject2() throws HibernateException {
@@ -81,13 +85,13 @@
Transaction tx = session.beginTransaction();
MainObject mo =
- (MainObject) session.load(MainObject.class, generatedId);
+ ( MainObject ) session.load( MainObject.class, generatedId );
Object2 toAdd = new Object2();
- toAdd.setDummy("test");
+ toAdd.setDummy( "test" );
//toAdd should now be saved by cascade
- mo.setObj2(toAdd);
+ mo.setObj2( toAdd );
tx.commit();
session.close();
@@ -96,7 +100,7 @@
/**
* reads the newly created MainObject
* and its Object2 if it exists
- *
+ * <p/>
* one hibernate transaction
*/
private MainObject readMainObject() throws HibernateException {
@@ -106,19 +110,11 @@
Serializable id = generatedId;
- MainObject mo = (MainObject) session.load(MainObject.class, id);
+ MainObject mo = ( MainObject ) session.load( MainObject.class, id );
tx.commit();
session.close();
return mo;
}
-
-
- /* (non-Javadoc)
- * @see org.hibernate.test.TestCase#getMappings()
- */
- protected String[] getMappings() {
- return new String[] { "legacy/Object2.hbm.xml", "legacy/MainObject.hbm.xml" };
- }
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/ParentChildTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/ParentChildTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/ParentChildTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -13,8 +13,6 @@
import java.util.Map;
import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
import org.hibernate.Criteria;
import org.hibernate.FetchMode;
@@ -29,6 +27,7 @@
import org.hibernate.dialect.DB2Dialect;
import org.hibernate.dialect.HSQLDialect;
import org.hibernate.dialect.MySQLDialect;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
public class ParentChildTest extends LegacyTestCase {
@@ -37,6 +36,33 @@
super(x);
}
+ public String[] getMappings() {
+ return new String[] {
+ "legacy/ParentChild.hbm.xml",
+ "legacy/FooBar.hbm.xml",
+ "legacy/Baz.hbm.xml",
+ "legacy/Qux.hbm.xml",
+ "legacy/Glarch.hbm.xml",
+ "legacy/Fum.hbm.xml",
+ "legacy/Fumm.hbm.xml",
+ "legacy/Fo.hbm.xml",
+ "legacy/One.hbm.xml",
+ "legacy/Many.hbm.xml",
+ "legacy/Immutable.hbm.xml",
+ "legacy/Fee.hbm.xml",
+ "legacy/Vetoer.hbm.xml",
+ "legacy/Holder.hbm.xml",
+ "legacy/Simple.hbm.xml",
+ "legacy/Container.hbm.xml",
+ "legacy/Circular.hbm.xml",
+ "legacy/Stuff.hbm.xml"
+ };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( ParentChildTest.class );
+ }
+
public void testReplicate() throws Exception {
Session s = openSession();
Container baz = new Container();
@@ -1046,35 +1072,4 @@
session.close();
}
- public static Test suite() {
- return new TestSuite(ParentChildTest.class);
- }
-
- public String[] getMappings() {
- return new String[] {
- "legacy/ParentChild.hbm.xml",
- "legacy/FooBar.hbm.xml",
- "legacy/Baz.hbm.xml",
- "legacy/Qux.hbm.xml",
- "legacy/Glarch.hbm.xml",
- "legacy/Fum.hbm.xml",
- "legacy/Fumm.hbm.xml",
- "legacy/Fo.hbm.xml",
- "legacy/One.hbm.xml",
- "legacy/Many.hbm.xml",
- "legacy/Immutable.hbm.xml",
- "legacy/Fee.hbm.xml",
- "legacy/Vetoer.hbm.xml",
- "legacy/Holder.hbm.xml",
- "legacy/Simple.hbm.xml",
- "legacy/Container.hbm.xml",
- "legacy/Circular.hbm.xml",
- "legacy/Stuff.hbm.xml"
- };
- }
-
- public static void main(String[] args) throws Exception {
- TestRunner.run( suite() );
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/QueryByExampleTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/QueryByExampleTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/QueryByExampleTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -4,13 +4,13 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
+
import org.hibernate.Criteria;
+import org.hibernate.Transaction;
import org.hibernate.classic.Session;
import org.hibernate.criterion.Example;
import org.hibernate.criterion.Expression;
-import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* Query by example test to allow nested components
@@ -19,20 +19,18 @@
*/
public class QueryByExampleTest extends LegacyTestCase {
- /**
- * @param name test name
- */
public QueryByExampleTest(String name) {
super(name);
}
- /**
- * @see org.hibernate.test.TestCase#getMappings()
- */
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "legacy/Componentizable.hbm.xml" };
}
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( QueryByExampleTest.class );
+ }
+
public void testSimpleQBE() throws Exception {
deleteData();
initData();
@@ -135,12 +133,4 @@
}
return master;
}
-
- public static Test suite() {
- return new TestSuite(QueryByExampleTest.class);
- }
-
- public static void main(String[] args) throws Exception {
- TestRunner.run( suite() );
- }
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/SQLFunctionsTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/SQLFunctionsTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/SQLFunctionsTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -10,11 +10,9 @@
import java.util.Map;
import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.hibernate.Hibernate;
import org.hibernate.Query;
import org.hibernate.ScrollableResults;
@@ -30,6 +28,7 @@
import org.hibernate.dialect.SybaseDialect;
import org.hibernate.dialect.TimesTenDialect;
import org.hibernate.dialect.function.SQLFunction;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
public class SQLFunctionsTest extends LegacyTestCase {
@@ -40,6 +39,18 @@
super(name);
}
+ public String[] getMappings() {
+ return new String[] {
+ "legacy/AltSimple.hbm.xml",
+ "legacy/Broken.hbm.xml",
+ "legacy/Blobber.hbm.xml"
+ };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( SQLFunctionsTest.class );
+ }
+
public void testDialectSQLFunctions() throws Exception {
Session s = openSession();
@@ -169,7 +180,6 @@
t.commit();
s.close();
}
-
public void testBroken() throws Exception {
if (getDialect() instanceof Oracle9Dialect) return;
Session s = openSession();
@@ -646,28 +656,4 @@
}
-
- public String[] getMappings() {
- return new String[] {
- "legacy/AltSimple.hbm.xml",
- "legacy/Broken.hbm.xml",
- "legacy/Blobber.hbm.xml"
- };
- }
-
- public static Test suite() {
- return new TestSuite(SQLFunctionsTest.class);
- }
-
- public static void main(String[] args) throws Exception {
- TestRunner.run( suite() );
- }
-
}
-
-
-
-
-
-
-
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/SQLLoaderTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/SQLLoaderTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/SQLLoaderTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -7,8 +7,6 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
import org.hibernate.HibernateException;
import org.hibernate.Query;
@@ -17,20 +15,37 @@
import org.hibernate.dialect.HSQLDialect;
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.dialect.Oracle9Dialect;
+import org.hibernate.dialect.OracleDialect;
import org.hibernate.dialect.PostgreSQLDialect;
-import org.hibernate.dialect.SQLServerDialect;
import org.hibernate.dialect.TimesTenDialect;
-import org.hibernate.dialect.OracleDialect;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
public class SQLLoaderTest extends LegacyTestCase {
static int nextInt = 1;
static long nextLong = 1;
+
public SQLLoaderTest(String arg) {
super(arg);
}
+ public String[] getMappings() {
+ return new String[] {
+ "legacy/ABC.hbm.xml",
+ "legacy/Category.hbm.xml",
+ "legacy/Simple.hbm.xml",
+ "legacy/Fo.hbm.xml",
+ "legacy/SingleSeveral.hbm.xml",
+ "legacy/Componentizable.hbm.xml",
+ "legacy/CompositeIdId.hbm.xml"
+ };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( SQLLoaderTest.class );
+ }
+
public void testTS() throws Exception {
if (getDialect() instanceof Oracle9Dialect) return;
Session session = openSession();
@@ -604,23 +619,23 @@
public void testCompositeIdId() throws HibernateException, SQLException {
// issue HHH-21
Session s = openSession();
-
+
CompositeIdId id = new CompositeIdId();
id.setName("Max");
id.setSystem("c64");
id.setId("games");
-
+
s.save(id);
s.flush();
s.connection().commit();
s.close();
-
+
s = openSession();
// having a composite id with one property named id works since the map used by sqlloader to map names to properties handles it.
Query query = s.createSQLQuery("select system as {c.system}, id as {c.id}, name as {c.name}, foo as {c.composite.foo}, bar as {c.composite.bar} from CompositeIdId where system=? and id=?", "c", CompositeIdId.class);
query.setString(0, "c64");
query.setString(1, "games");
-
+
CompositeIdId id2 = (CompositeIdId) query.uniqueResult();
check(id, id2);
@@ -629,25 +644,20 @@
s.close();
s = openSession();
-
+
CompositeIdId useForGet = new CompositeIdId();
useForGet.setSystem("c64");
useForGet.setId("games");
// this doesn't work since the verification does not take column span into respect!
CompositeIdId getted = (CompositeIdId) s.get(CompositeIdId.class, useForGet);
check(id,getted);
-
-
+
+
s.connection().commit();
s.close();
-
+
}
-
-
- /**
- * @param id
- * @param id2
- */
+
private void check(CompositeIdId id, CompositeIdId id2) {
assertEquals(id,id2);
assertEquals(id.getName(), id2.getName());
@@ -655,24 +665,4 @@
assertEquals(id.getSystem(), id2.getSystem());
}
- public String[] getMappings() {
- return new String[] {
- "legacy/ABC.hbm.xml",
- "legacy/Category.hbm.xml",
- "legacy/Simple.hbm.xml",
- "legacy/Fo.hbm.xml",
- "legacy/SingleSeveral.hbm.xml",
- "legacy/Componentizable.hbm.xml",
- "legacy/CompositeIdId.hbm.xml"
- };
- }
-
- public static Test suite() {
- return new TestSuite(SQLLoaderTest.class);
- }
-
- public static void main(String[] args) throws Exception {
- TestRunner.run( suite() );
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/StatisticsTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/StatisticsTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/StatisticsTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,15 +1,13 @@
//$Id$
package org.hibernate.test.legacy;
-
import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.stat.Statistics;
/**
@@ -20,6 +18,14 @@
public StatisticsTest(String x) {
super(x);
}
+
+ public String[] getMappings() {
+ return new String[] { "legacy/ABC.hbm.xml", "legacy/ABCExtends.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( StatisticsTest.class );
+ }
public void testSessionStats() throws Exception {
@@ -53,20 +59,5 @@
stats.setStatisticsEnabled(isStats);
}
-
- public String[] getMappings() {
- return new String[] { "legacy/ABC.hbm.xml", "legacy/ABCExtends.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(StatisticsTest.class);
- }
-
- /**
- * @see org.hibernate.test.TestCase#getMappings()
- */
- public static void main(String[] args) throws Exception {
- TestRunner.run( suite() );
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/lob/BlobTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/lob/BlobTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/lob/BlobTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -2,15 +2,15 @@
import java.sql.Blob;
+import junit.framework.AssertionFailedError;
import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.framework.AssertionFailedError;
-import org.hibernate.test.DatabaseSpecificTestCase;
-import org.hibernate.Session;
import org.hibernate.Hibernate;
import org.hibernate.LockMode;
+import org.hibernate.Session;
import org.hibernate.dialect.Dialect;
+import org.hibernate.junit.functional.DatabaseSpecificFunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.util.ArrayHelper;
/**
@@ -18,23 +18,27 @@
*
* @author Steve Ebersole
*/
-public class BlobTest extends DatabaseSpecificTestCase {
+public class BlobTest extends DatabaseSpecificFunctionalTestCase {
private static final int BLOB_SIZE = 10000;
public BlobTest(String name) {
super( name );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "lob/LobMappings.hbm.xml" };
}
public static Test suite() {
- return new TestSuite( BlobTest.class );
+ return new FunctionalTestClassTestSuite( BlobTest.class );
}
public boolean appliesTo(Dialect dialect) {
- return supportsExpectedLobUsagePattern();
+ if ( ! dialect.supportsExpectedLobUsagePattern() ) {
+ reportSkip( "database/driver does not support expected LOB usage pattern", "LOB support" );
+ return false;
+ }
+ return true;
}
public void testBoundedMaterializedBlobAccess() {
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/lob/ClobTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/lob/ClobTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/lob/ClobTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -3,14 +3,14 @@
import java.sql.Clob;
import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.hibernate.test.DatabaseSpecificTestCase;
-import org.hibernate.Session;
import org.hibernate.Hibernate;
import org.hibernate.LockMode;
+import org.hibernate.Session;
+import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.H2Dialect;
-import org.hibernate.dialect.Dialect;
+import org.hibernate.junit.functional.DatabaseSpecificFunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* Test various access scenarios for eager and lazy materialization
@@ -19,23 +19,27 @@
*
* @author Steve Ebersole
*/
-public class ClobTest extends DatabaseSpecificTestCase {
+public class ClobTest extends DatabaseSpecificFunctionalTestCase {
private static final int CLOB_SIZE = 10000;
public ClobTest(String name) {
super( name );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "lob/LobMappings.hbm.xml" };
}
public static Test suite() {
- return new TestSuite( ClobTest.class );
+ return new FunctionalTestClassTestSuite( ClobTest.class );
}
public boolean appliesTo(Dialect dialect) {
- return supportsExpectedLobUsagePattern();
+ if ( ! dialect.supportsExpectedLobUsagePattern() ) {
+ reportSkip( "database/driver does not support expected LOB usage pattern", "LOB support" );
+ return false;
+ }
+ return true;
}
public void testBoundedMaterializedClobAccess() {
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/lob/LobHolder.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/lob/LobHolder.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/lob/LobHolder.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -25,8 +25,8 @@
* {@link #blobLocator} is used to hold BLOB data that is materialized lazily
* via a JDBC BLOB locator; it is mapped via the
* {@link org.hibernate.type.BlobType}
+ *
*
- *
* @author Steve Ebersole
*/
public class LobHolder {
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/lob/LobMappings.hbm.xml
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/lob/LobMappings.hbm.xml 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/lob/LobMappings.hbm.xml 2006-12-12 23:22:26 UTC (rev 10976)
@@ -12,10 +12,10 @@
<property name="serialData" column="SER_DATA" type="serializable"/>
- <property name="materializedClob" column="MAT_CLOB_DATA" type="text"/>
+ <property name="materializedClob" column="MAT_CLOB_DATA" type="text" length="15000"/>
<property name="clobLocator" column="CLOB_DATA" type="clob" />
- <property name="materializedBlob" column="MAT_BLOB_DATA" type="org.hibernate.test.lob.MaterializedBlobType"/>
+ <property name="materializedBlob" column="MAT_BLOB_DATA" type="org.hibernate.test.lob.MaterializedBlobType" length="15000"/>
<property name="blobLocator" column="BLOB_DATA" type="blob" />
</class>
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/lob/SerializableTypeTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/lob/SerializableTypeTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/lob/SerializableTypeTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -2,28 +2,28 @@
package org.hibernate.test.lob;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Session;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* Tests of {@link org.hibernate.type.SerializableType}
- *
+ *
* @author Steve Ebersole
*/
-public class SerializableTypeTest extends TestCase {
+public class SerializableTypeTest extends FunctionalTestCase {
public SerializableTypeTest(String testName) {
super( testName );
}
- public static Test suite() {
- return new TestSuite( SerializableTypeTest.class );
+ public String[] getMappings() {
+ return new String[] { "lob/LobMappings.hbm.xml" };
}
- protected String[] getMappings() {
- return new String[] { "lob/LobMappings.hbm.xml" };
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( SerializableTypeTest.class );
}
public String getCacheConcurrencyStrategy() {
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/manytomany/ManyToManyTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/manytomany/ManyToManyTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/manytomany/ManyToManyTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -2,7 +2,6 @@
package org.hibernate.test.manytomany;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.FetchMode;
import org.hibernate.Hibernate;
@@ -10,16 +9,29 @@
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class ManyToManyTest extends TestCase {
+public class ManyToManyTest extends FunctionalTestCase {
public ManyToManyTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "manytomany/UserGroup.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "false");
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( ManyToManyTest.class );
+ }
public void testManyToManyWithFormula() {
Session s = openSession();
@@ -111,18 +123,5 @@
t.commit();
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "manytomany/UserGroup.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(ManyToManyTest.class);
- }
-
- protected void configure(Configuration cfg) {
- cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "false");
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/manytomany/ordered/OrderedManyToManyTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/manytomany/ordered/OrderedManyToManyTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/manytomany/ordered/OrderedManyToManyTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,27 +1,40 @@
package org.hibernate.test.manytomany.ordered;
-import org.hibernate.test.TestCase;
+import java.util.List;
+
+import junit.framework.Test;
+
+import org.hibernate.Criteria;
+import org.hibernate.FetchMode;
+import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.Hibernate;
-import org.hibernate.FetchMode;
-import org.hibernate.Criteria;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
-import java.util.List;
-
/**
* @author Gavin King
*/
-public class OrderedManyToManyTest extends TestCase {
+public class OrderedManyToManyTest extends FunctionalTestCase {
public OrderedManyToManyTest(String str) {
super(str);
}
+ public String[] getMappings() {
+ return new String[] { "manytomany/ordered/UserGroup.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty( Environment.USE_SECOND_LEVEL_CACHE, "false");
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( OrderedManyToManyTest.class );
+ }
+
public void testManyToManyOrdering() {
Session s = openSession();
Transaction t = s.beginTransaction();
@@ -122,16 +135,5 @@
private User extractUser(List users, int position) {
return ( User ) users.get( position );
}
- protected String[] getMappings() {
- return new String[] { "manytomany/ordered/UserGroup.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite( OrderedManyToManyTest.class);
- }
-
- protected void configure(Configuration cfg) {
- cfg.setProperty( Environment.USE_SECOND_LEVEL_CACHE, "false");
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/map/MapIndexFormulaTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/map/MapIndexFormulaTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/map/MapIndexFormulaTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -5,20 +5,28 @@
import java.util.Map;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class MapIndexFormulaTest extends TestCase {
+public class MapIndexFormulaTest extends FunctionalTestCase {
public MapIndexFormulaTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "map/UserGroup.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( MapIndexFormulaTest.class );
+ }
public void testIndexFormulaMap() {
Session s = openSession();
@@ -94,14 +102,6 @@
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "map/UserGroup.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(MapIndexFormulaTest.class);
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/mapcompelem/MapCompositeElementTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/mapcompelem/MapCompositeElementTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/mapcompelem/MapCompositeElementTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -4,20 +4,28 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class MapCompositeElementTest extends TestCase {
+public class MapCompositeElementTest extends FunctionalTestCase {
public MapCompositeElementTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "mapcompelem/ProductPart.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( MapCompositeElementTest.class );
+ }
public void testMapCompositeElementWithFormula() {
Session s = openSession();
@@ -103,14 +111,6 @@
t.commit();
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "mapcompelem/ProductPart.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(MapCompositeElementTest.class);
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/mapelemformula/MapElementFormulaTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/mapelemformula/MapElementFormulaTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/mapelemformula/MapElementFormulaTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -2,21 +2,29 @@
package org.hibernate.test.mapelemformula;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class MapElementFormulaTest extends TestCase {
+public class MapElementFormulaTest extends FunctionalTestCase {
public MapElementFormulaTest(String str) {
super(str);
}
-
+
+ public String[] getMappings() {
+ return new String[] { "mapelemformula/UserGroup.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( MapElementFormulaTest.class );
+ }
+
public void testManyToManyFormula() {
Session s = openSession();
Transaction t = s.beginTransaction();
@@ -47,14 +55,6 @@
t.commit();
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "mapelemformula/UserGroup.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(MapElementFormulaTest.class);
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/mapping/PersistentClassVisitorTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/mapping/PersistentClassVisitorTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/mapping/PersistentClassVisitorTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -5,7 +5,6 @@
package org.hibernate.test.mapping;
import junit.framework.Test;
-import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.hibernate.mapping.JoinedSubclass;
@@ -14,13 +13,18 @@
import org.hibernate.mapping.SingleTableSubclass;
import org.hibernate.mapping.Subclass;
import org.hibernate.mapping.UnionSubclass;
+import org.hibernate.junit.UnitTestCase;
/**
* @author max
*
*/
-public class PersistentClassVisitorTest extends TestCase {
+public class PersistentClassVisitorTest extends UnitTestCase {
+ public PersistentClassVisitorTest(String string) {
+ super( string );
+ }
+
static public class PersistentClassVisitorValidator implements PersistentClassVisitor {
private Object validate(Class expectedClass, Object visitee) {
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/mapping/ValueVisitorTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/mapping/ValueVisitorTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/mapping/ValueVisitorTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -5,7 +5,6 @@
package org.hibernate.test.mapping;
import junit.framework.Test;
-import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.hibernate.mapping.Any;
@@ -25,13 +24,18 @@
import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Table;
import org.hibernate.mapping.ValueVisitor;
+import org.hibernate.junit.UnitTestCase;
/**
* @author max
*
*/
-public class ValueVisitorTest extends TestCase {
+public class ValueVisitorTest extends UnitTestCase {
+ public ValueVisitorTest(String string) {
+ super( string );
+ }
+
static public class ValueVisitorValidator implements ValueVisitor {
/* (non-Javadoc)
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/mappingexception/MappingExceptionTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/mappingexception/MappingExceptionTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/mappingexception/MappingExceptionTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -18,7 +18,8 @@
import org.hibernate.InvalidMappingException;
import org.hibernate.MappingException;
import org.hibernate.MappingNotFoundException;
-import org.hibernate.test.TestCase;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.junit.UnitTestCase;
import org.hibernate.util.ConfigHelper;
/**
@@ -26,20 +27,21 @@
*
* @author Max Rydahl Andersen
*/
-public class MappingExceptionTest extends TestCase {
+public class MappingExceptionTest extends UnitTestCase {
public MappingExceptionTest(String name) {
super( name );
}
- protected String[] getMappings() {
- return new String[] { "mappingexception/User.hbm.xml" };
+ public static Test suite() {
+ return new TestSuite( MappingExceptionTest.class );
}
public void testNotFound() throws MappingException, MalformedURLException {
+ Configuration cfg = new Configuration();
try {
- getCfg().addCacheableFile( "completelybogus.hbm.xml" );
+ cfg.addCacheableFile( "completelybogus.hbm.xml" );
fail();
}
catch ( MappingNotFoundException e ) {
@@ -48,7 +50,7 @@
}
try {
- getCfg().addCacheableFile( new File( "completelybogus.hbm.xml" ) );
+ cfg.addCacheableFile( new File( "completelybogus.hbm.xml" ) );
fail();
}
catch ( MappingNotFoundException e ) {
@@ -57,7 +59,7 @@
}
try {
- getCfg().addClass( Hibernate.class ); // TODO: String.class result in npe, because no classloader exists for it
+ cfg.addClass( Hibernate.class ); // TODO: String.class result in npe, because no classloader exists for it
fail();
}
catch ( MappingNotFoundException inv ) {
@@ -66,7 +68,7 @@
}
try {
- getCfg().addFile( "completelybogus.hbm.xml" );
+ cfg.addFile( "completelybogus.hbm.xml" );
fail();
}
catch ( MappingNotFoundException e ) {
@@ -75,7 +77,7 @@
}
try {
- getCfg().addFile( new File( "completelybogus.hbm.xml" ) );
+ cfg.addFile( new File( "completelybogus.hbm.xml" ) );
fail();
}
catch ( MappingNotFoundException inv ) {
@@ -84,7 +86,7 @@
}
try {
- getCfg().addInputStream( new ByteArrayInputStream( new byte[0] ) );
+ cfg.addInputStream( new ByteArrayInputStream( new byte[0] ) );
fail();
}
catch ( InvalidMappingException inv ) {
@@ -93,7 +95,7 @@
}
try {
- getCfg().addResource( "nothere" );
+ cfg.addResource( "nothere" );
fail();
}
catch ( MappingNotFoundException inv ) {
@@ -102,7 +104,7 @@
}
try {
- getCfg().addResource( "nothere", getClass().getClassLoader() );
+ cfg.addResource( "nothere", getClass().getClassLoader() );
fail();
}
catch ( MappingNotFoundException inv ) {
@@ -111,7 +113,7 @@
}
try {
- getCfg().addURL( new URL( "file://nothere" ) );
+ cfg.addURL( new URL( "file://nothere" ) );
fail();
}
catch ( InvalidMappingException inv ) {
@@ -121,39 +123,29 @@
}
public void testDuplicateMapping() {
+ String resourceName = "org/hibernate/test/mappingexception/User.hbm.xml";
+ Configuration cfg = new Configuration();
+ cfg.addResource( resourceName );
try {
- getCfg().addResource( getBaseForMappings() + "mappingexception/User.hbm.xml" );
+ cfg.addResource( resourceName );
fail();
}
catch ( InvalidMappingException inv ) {
assertEquals( inv.getType(), "resource" );
- assertEquals( inv.getPath(), getBaseForMappings() + "mappingexception/User.hbm.xml" );
+ assertEquals( inv.getPath(), resourceName );
assertClassAssignability( inv.getCause().getClass(), DuplicateMappingException.class );
}
}
- void copy(InputStream in, File dst) throws IOException {
- OutputStream out = new FileOutputStream( dst );
-
- // Transfer bytes from in to out
- byte[] buf = new byte[1024];
- int len;
- while ( ( len = in.read( buf ) ) > 0 ) {
- out.write( buf, 0, len );
- }
- in.close();
- out.close();
- }
-
public void testInvalidMapping() throws MappingException, IOException {
- String resourceName = getBaseForMappings() + "mappingexception/InvalidMapping.hbm.xml";
-
+ String resourceName = "org/hibernate/test/mappingexception/InvalidMapping.hbm.xml";
File file = File.createTempFile( "TempInvalidMapping", ".hbm.xml" );
file.deleteOnExit();
copy( ConfigHelper.getConfigStream( resourceName ), file );
+ Configuration cfg = new Configuration();
try {
- getCfg().addCacheableFile( file.getAbsolutePath() );
+ cfg.addCacheableFile( file.getAbsolutePath() );
fail();
}
catch ( InvalidMappingException inv ) {
@@ -164,7 +156,7 @@
}
try {
- getCfg().addCacheableFile( file );
+ cfg.addCacheableFile( file );
fail();
}
catch ( InvalidMappingException inv ) {
@@ -175,7 +167,7 @@
}
try {
- getCfg().addClass( InvalidMapping.class );
+ cfg.addClass( InvalidMapping.class );
fail();
}
catch ( InvalidMappingException inv ) {
@@ -185,7 +177,7 @@
}
try {
- getCfg().addFile( file.getAbsolutePath() );
+ cfg.addFile( file.getAbsolutePath() );
fail();
}
catch ( InvalidMappingException inv ) {
@@ -195,7 +187,7 @@
}
try {
- getCfg().addFile( file );
+ cfg.addFile( file );
fail();
}
catch ( InvalidMappingException inv ) {
@@ -206,7 +198,7 @@
try {
- getCfg().addInputStream( ConfigHelper.getResourceAsStream( resourceName ) );
+ cfg.addInputStream( ConfigHelper.getResourceAsStream( resourceName ) );
fail();
}
catch ( InvalidMappingException inv ) {
@@ -216,7 +208,7 @@
}
try {
- getCfg().addResource( resourceName );
+ cfg.addResource( resourceName );
fail();
}
catch ( InvalidMappingException inv ) {
@@ -226,7 +218,7 @@
}
try {
- getCfg().addResource( resourceName, getClass().getClassLoader() );
+ cfg.addResource( resourceName, getClass().getClassLoader() );
fail();
}
catch ( InvalidMappingException inv ) {
@@ -236,7 +228,7 @@
}
try {
- getCfg().addURL( ConfigHelper.findAsResource( resourceName ) );
+ cfg.addURL( ConfigHelper.findAsResource( resourceName ) );
fail();
}
catch ( InvalidMappingException inv ) {
@@ -246,7 +238,16 @@
}
}
- public static Test suite() {
- return new TestSuite( MappingExceptionTest.class );
+ void copy(InputStream in, File dst) throws IOException {
+ OutputStream out = new FileOutputStream( dst );
+
+ // Transfer bytes from in to out
+ byte[] buf = new byte[1024];
+ int len;
+ while ( ( len = in.read( buf ) ) > 0 ) {
+ out.write( buf, 0, len );
+ }
+ in.close();
+ out.close();
}
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/mixed/MixedTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/mixed/MixedTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/mixed/MixedTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -2,22 +2,35 @@
package org.hibernate.test.mixed;
import junit.framework.Test;
-import junit.framework.TestSuite;
+
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.dialect.PostgreSQLDialect;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class MixedTest extends TestCase {
+public class MixedTest extends FunctionalTestCase {
public MixedTest(String str) {
super( str );
}
+ public String[] getMappings() {
+ return new String[]{"mixed/Item.hbm.xml"};
+ }
+
+ public String getCacheConcurrencyStrategy() {
+ return null;
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( MixedTest.class );
+ }
+
public void testMixedInheritance() {
Session s = openSession( new DocumentInterceptor() );
Transaction t = s.beginTransaction();
@@ -90,18 +103,5 @@
t.commit();
s.close();
}
-
-
- protected String[] getMappings() {
- return new String[]{"mixed/Item.hbm.xml"};
- }
-
- public static Test suite() {
- return new TestSuite( MixedTest.class );
- }
-
- public String getCacheConcurrencyStrategy() {
- return null;
- }
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/naturalid/NaturalIdTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/naturalid/NaturalIdTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/naturalid/NaturalIdTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -4,7 +4,6 @@
import java.lang.reflect.Field;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.HibernateException;
import org.hibernate.Session;
@@ -12,16 +11,31 @@
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.criterion.Restrictions;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class NaturalIdTest extends TestCase {
+public class NaturalIdTest extends FunctionalTestCase {
public NaturalIdTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "naturalid/User.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "true");
+ cfg.setProperty(Environment.USE_QUERY_CACHE, "true");
+ cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( NaturalIdTest.class );
+ }
public void testNaturalIdCheck() throws Exception {
Session s = openSession();
@@ -230,21 +244,5 @@
t.commit();
s.close();
}
-
-
- protected void configure(Configuration cfg) {
- cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "true");
- cfg.setProperty(Environment.USE_QUERY_CACHE, "true");
- cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
- }
-
- protected String[] getMappings() {
- return new String[] { "naturalid/User.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(NaturalIdTest.class);
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ondelete/OnDeleteTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ondelete/OnDeleteTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ondelete/OnDeleteTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -4,7 +4,6 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Session;
import org.hibernate.Transaction;
@@ -12,17 +11,30 @@
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.dialect.MySQLInnoDBDialect;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.stat.Statistics;
-import org.hibernate.test.TestCase;
/**
* @author Gavin King
*/
-public class OnDeleteTest extends TestCase {
+public class OnDeleteTest extends FunctionalTestCase {
public OnDeleteTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "ondelete/Person.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( OnDeleteTest.class );
+ }
public void testJoinedSubclass() {
if ( ! supportsCircularCascadeDelete() ) {
@@ -74,20 +86,9 @@
List names = s.createQuery("select name from Person").list();
assertTrue( names.isEmpty() );
t.commit();
+
s.close();
}
- protected void configure(Configuration cfg) {
- cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
- }
-
- protected String[] getMappings() {
- return new String[] { "ondelete/Person.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(OnDeleteTest.class);
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetomany/OneToManyTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetomany/OneToManyTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetomany/OneToManyTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -2,20 +2,28 @@
package org.hibernate.test.onetomany;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class OneToManyTest extends TestCase {
+public class OneToManyTest extends FunctionalTestCase {
public OneToManyTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "onetomany/Parent.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( OneToManyTest.class );
+ }
public void testOneToManyLinkTable() {
Session s = openSession();
@@ -82,14 +90,5 @@
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "onetomany/Parent.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(OneToManyTest.class);
- }
-
}
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/OneToOneSuite.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/OneToOneSuite.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/OneToOneSuite.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,27 @@
+package org.hibernate.test.onetoone;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.hibernate.test.onetoone.formula.OneToOneFormulaTest;
+import org.hibernate.test.onetoone.joined.JoinedSubclassOneToOneTest;
+import org.hibernate.test.onetoone.link.OneToOneLinkTest;
+import org.hibernate.test.onetoone.nopojo.DynamicMapOneToOneTest;
+import org.hibernate.test.onetoone.singletable.DiscrimSubclassOneToOneTest;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class OneToOneSuite {
+ public static Test suite() {
+ TestSuite suite = new TestSuite( "one-to-one suite" );
+ suite.addTest( OneToOneFormulaTest.suite() );
+ suite.addTest( JoinedSubclassOneToOneTest.suite() );
+ suite.addTest( OneToOneLinkTest.suite() );
+ suite.addTest( DynamicMapOneToOneTest.suite() );
+ suite.addTest( DiscrimSubclassOneToOneTest.suite() );
+ return suite;
+ }
+}
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/formula/Address.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/formula/Address.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/formula/Address.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,57 @@
+//$Id: Address.java 5686 2005-02-12 07:27:32Z steveebersole $
+package org.hibernate.test.onetoone.formula;
+
+import java.io.Serializable;
+
+/**
+ * @author Gavin King
+ */
+public class Address implements Serializable {
+ private Person person;
+ private String type;
+ private String street;
+ private String state;
+ private String zip;
+
+ public Person getPerson() {
+ return person;
+ }
+ public void setPerson(Person person) {
+ this.person = person;
+ }
+ public String getState() {
+ return state;
+ }
+ public void setState(String state) {
+ this.state = state;
+ }
+ public String getStreet() {
+ return street;
+ }
+ public void setStreet(String street) {
+ this.street = street;
+ }
+ public String getType() {
+ return type;
+ }
+ public void setType(String type) {
+ this.type = type;
+ }
+ public String getZip() {
+ return zip;
+ }
+ public void setZip(String zip) {
+ this.zip = zip;
+ }
+
+ public boolean equals(Object that) {
+ if ( !(that instanceof Address) ) return false;
+ Address address = (Address) that;
+ return address.getType().equals(type) &&
+ address.getPerson().getName().equals( person.getName() );
+ }
+
+ public int hashCode() {
+ return person.getName().hashCode() + type.hashCode();
+ }
+}
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/formula/OneToOneFormulaTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/formula/OneToOneFormulaTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/formula/OneToOneFormulaTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,164 @@
+//$Id: OneToOneFormulaTest.java 5836 2005-02-21 14:41:05Z oneovthafew $
+package org.hibernate.test.onetoone.formula;
+
+import junit.framework.Test;
+
+import org.hibernate.FetchMode;
+import org.hibernate.Hibernate;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
+import org.hibernate.criterion.Property;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+
+/**
+ * @author Gavin King
+ */
+public class OneToOneFormulaTest extends FunctionalTestCase {
+
+ public OneToOneFormulaTest(String str) {
+ super(str);
+ }
+
+ public String[] getMappings() {
+ return new String[] { "onetoone/formula/Person.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "false");
+ cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
+ cfg.setProperty(Environment.DEFAULT_BATCH_FETCH_SIZE, "2");
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( OneToOneFormulaTest.class );
+ }
+
+ public void testOneToOneFormula() {
+ Person p = new Person();
+ p.setName("Gavin King");
+ Address a = new Address();
+ a.setPerson(p);
+ a.setType("HOME");
+ a.setZip("3181");
+ a.setState("VIC");
+ a.setStreet("Karbarook Ave");
+ p.setAddress(a);
+
+ Session s = openSession();
+ Transaction t = s.beginTransaction();
+ s.persist(p);
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ p = (Person) s.createQuery("from Person").uniqueResult();
+
+ assertNotNull( p.getAddress() );
+ assertTrue( Hibernate.isInitialized( p.getAddress() ) );
+ assertNull( p.getMailingAddress() );
+
+ s.clear();
+
+ p = (Person) s.createQuery("from Person p left join fetch p.mailingAddress left join fetch p.address").uniqueResult();
+
+ assertNotNull( p.getAddress() );
+ assertTrue( Hibernate.isInitialized( p.getAddress() ) );
+ assertNull( p.getMailingAddress() );
+
+ s.clear();
+
+ p = (Person) s.createQuery("from Person p left join fetch p.address").uniqueResult();
+
+ assertNotNull( p.getAddress() );
+ assertTrue( Hibernate.isInitialized( p.getAddress() ) );
+ assertNull( p.getMailingAddress() );
+
+ s.clear();
+
+ p = (Person) s.createCriteria(Person.class)
+ .createCriteria("address")
+ .add( Property.forName("zip").eq("3181") )
+ .uniqueResult();
+ assertNotNull(p);
+
+ s.clear();
+
+ p = (Person) s.createCriteria(Person.class)
+ .setFetchMode("address", FetchMode.JOIN)
+ .uniqueResult();
+
+ assertNotNull( p.getAddress() );
+ assertTrue( Hibernate.isInitialized( p.getAddress() ) );
+ assertNull( p.getMailingAddress() );
+
+ s.clear();
+
+ p = (Person) s.createCriteria(Person.class)
+ .setFetchMode("mailingAddress", FetchMode.JOIN)
+ .uniqueResult();
+
+ assertNotNull( p.getAddress() );
+ assertTrue( Hibernate.isInitialized( p.getAddress() ) );
+ assertNull( p.getMailingAddress() );
+
+ s.delete(p);
+
+ t.commit();
+ s.close();
+
+ }
+
+ public void testOneToOneEmbeddedCompositeKey() {
+ Person p = new Person();
+ p.setName("Gavin King");
+ Address a = new Address();
+ a.setPerson(p);
+ a.setType("HOME");
+ a.setZip("3181");
+ a.setState("VIC");
+ a.setStreet("Karbarook Ave");
+ p.setAddress(a);
+
+ Session s = openSession();
+ Transaction t = s.beginTransaction();
+ s.persist(p);
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+
+ a = new Address();
+ a.setType("HOME");
+ a.setPerson(p);
+ a = (Address) s.load(Address.class, a);
+ assertFalse( Hibernate.isInitialized(a) );
+ a.getPerson();
+ a.getType();
+ assertFalse( Hibernate.isInitialized(a) );
+ assertEquals(a.getZip(), "3181");
+
+ s.clear();
+
+ a = new Address();
+ a.setType("HOME");
+ a.setPerson(p);
+ Address a2 = (Address) s.get(Address.class, a);
+ assertTrue( Hibernate.isInitialized(a) );
+ assertSame(a2, a);
+ assertSame(a2.getPerson(), p); //this is a little bit desirable
+ assertEquals(a.getZip(), "3181");
+
+ s.delete(a2);
+ s.delete( s.get( Person.class, p.getName() ) ); //this is certainly undesirable! oh well...
+
+ t.commit();
+ s.close();
+
+ }
+
+}
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/formula/Person.hbm.xml
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/formula/Person.hbm.xml 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/formula/Person.hbm.xml 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="org.hibernate.test.onetoone.formula">
+
+ <class name="Person">
+ <id name="name"/>
+ <one-to-one name="address" cascade="all" constrained="false">
+ <formula>name</formula>
+ <formula>'HOME'</formula>
+ </one-to-one>
+ <one-to-one name="mailingAddress" constrained="false">
+ <formula>name</formula>
+ <formula>'MAILING'</formula>
+ </one-to-one>
+ </class>
+
+ <class name="Address" batch-size="2"
+ check="addressType in ('MAILING', 'HOME', 'BUSINESS')">
+ <composite-id>
+ <key-many-to-one name="person"
+ column="personName"/>
+ <key-property name="type"
+ column="addressType"/>
+ </composite-id>
+ <property name="street" type="text"/>
+ <property name="state"/>
+ <property name="zip"/>
+ </class>
+
+</hibernate-mapping>
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/formula/Person.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/formula/Person.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/formula/Person.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,42 @@
+//$Id: Person.java 5686 2005-02-12 07:27:32Z steveebersole $
+package org.hibernate.test.onetoone.formula;
+
+import java.io.Serializable;
+
+/**
+ * @author Gavin King
+ */
+public class Person implements Serializable {
+ private String name;
+ private Address address;
+ private Address mailingAddress;
+
+ public Address getAddress() {
+ return address;
+ }
+ public void setAddress(Address address) {
+ this.address = address;
+ }
+ public Address getMailingAddress() {
+ return mailingAddress;
+ }
+ public void setMailingAddress(Address mailingAddress) {
+ this.mailingAddress = mailingAddress;
+ }
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public boolean equals(Object that) {
+ if ( !(that instanceof Person) ) return false;
+ Person person = (Person) that;
+ return person.getName().equals(name);
+ }
+
+ public int hashCode() {
+ return name.hashCode();
+ }
+}
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/joined/JoinedSubclassOneToOneTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/joined/JoinedSubclassOneToOneTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/joined/JoinedSubclassOneToOneTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,159 @@
+//$Id: OneToOneTest.java 9914 2006-05-09 04:37:18 -0500 (Tue, 09 May 2006) max.andersen(a)jboss.com $
+package org.hibernate.test.onetoone.joined;
+
+import java.util.List;
+
+import junit.framework.Test;
+
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.stat.EntityStatistics;
+
+/**
+ * @author Gavin King
+ */
+public class JoinedSubclassOneToOneTest extends FunctionalTestCase {
+
+ public JoinedSubclassOneToOneTest(String str) {
+ super(str);
+ }
+
+ public String[] getMappings() {
+ return new String[] { "onetoone/joined/Person.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "false");
+ cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( JoinedSubclassOneToOneTest.class );
+ }
+
+ public void testOneToOneOnSubclass() {
+ Person p = new Person();
+ p.name = "Gavin";
+ Address a = new Address();
+ a.entityName = "Gavin";
+ a.zip = "3181";
+ a.state = "VIC";
+ a.street = "Karbarook Ave";
+ p.address = a;
+
+ Session s = openSession();
+ Transaction t = s.beginTransaction();
+ s.persist(p);
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+
+ EntityStatistics addressStats = getSessions().getStatistics().getEntityStatistics( Address.class.getName() );
+ EntityStatistics mailingAddressStats = getSessions().getStatistics().getEntityStatistics("MailingAddress");
+
+ p = (Person) s.createQuery("from Person p join fetch p.address left join fetch p.mailingAddress").uniqueResult();
+ assertNotNull(p.address); assertNull(p.mailingAddress);
+ s.clear();
+
+ p = (Person) s.createQuery("select p from Person p join fetch p.address left join fetch p.mailingAddress").uniqueResult();
+ assertNotNull(p.address); assertNull(p.mailingAddress);
+ s.clear();
+
+ Object[] stuff = (Object[]) s.createQuery("select p.name, p from Person p join fetch p.address left join fetch p.mailingAddress").uniqueResult();
+ assertEquals(stuff.length, 2);
+ p = (Person) stuff[1];
+ assertNotNull(p.address); assertNull(p.mailingAddress);
+ s.clear();
+
+ assertEquals( addressStats.getFetchCount(), 0 );
+ assertEquals( mailingAddressStats.getFetchCount(), 0 );
+
+ p = (Person) s.createQuery("from Person p join fetch p.address").uniqueResult();
+ assertNotNull(p.address); assertNull(p.mailingAddress);
+ s.clear();
+
+ assertEquals( addressStats.getFetchCount(), 0 );
+ assertEquals( mailingAddressStats.getFetchCount(), 1 );
+
+ p = (Person) s.createQuery("from Person").uniqueResult();
+ assertNotNull(p.address); assertNull(p.mailingAddress);
+ s.clear();
+
+ assertEquals( addressStats.getFetchCount(), 0 );
+ assertEquals( mailingAddressStats.getFetchCount(), 2 );
+
+ p = (Person) s.createQuery("from Entity").uniqueResult();
+ assertNotNull(p.address); assertNull(p.mailingAddress);
+ s.clear();
+
+ assertEquals( addressStats.getFetchCount(), 0 );
+ assertEquals( mailingAddressStats.getFetchCount(), 3 );
+
+ //note that in here join fetch is used for the nullable
+ //one-to-one, due to a very special case of default
+ p = (Person) s.get(Person.class, "Gavin");
+ assertNotNull(p.address); assertNull(p.mailingAddress);
+ s.clear();
+
+ assertEquals( addressStats.getFetchCount(), 0 );
+ assertEquals( mailingAddressStats.getFetchCount(), 3 );
+
+ p = (Person) s.get(Entity.class, "Gavin");
+ assertNotNull(p.address); assertNull(p.mailingAddress);
+ s.clear();
+
+ assertEquals( addressStats.getFetchCount(), 0 );
+ assertEquals( mailingAddressStats.getFetchCount(), 3 );
+
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ Org org = new Org();
+ org.name = "IFA";
+ Address a2 = new Address();
+ a2.entityName = "IFA";
+ a2.zip = "3181";
+ a2.state = "VIC";
+ a2.street = "Orrong Rd";
+ s.persist(org);
+ s.persist(a2);
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ org = (Org) s.get(Entity.class, "IFA");
+ s.clear();
+
+ List list = s.createQuery("from Entity e order by e.name").list();
+ p = (Person) list.get(0);
+ assertNotNull(p.address); assertNull(p.mailingAddress);
+ org = (Org) list.get(1);
+ s.clear();
+
+ list = s.createQuery("from Entity e left join fetch e.address left join fetch e.mailingAddress order by e.name").list();
+ p = (Person) list.get(0);
+ org = (Org) list.get(1);
+ assertNotNull(p.address); assertNull(p.mailingAddress);
+
+ s.clear();
+ s.delete(p);
+ s.delete( p.address );
+ s.delete( org );
+ s.delete( a2 );
+ s.flush();
+ t.commit();
+ s.close();
+
+ }
+
+}
+
Deleted: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/joined/OneToOneTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/joined/OneToOneTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/joined/OneToOneTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,159 +0,0 @@
-//$Id$
-package org.hibernate.test.onetoone.joined;
-
-import java.util.List;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.cfg.Environment;
-import org.hibernate.stat.EntityStatistics;
-import org.hibernate.test.TestCase;
-
-/**
- * @author Gavin King
- */
-public class OneToOneTest extends TestCase {
-
- public OneToOneTest(String str) {
- super(str);
- }
-
- public void testOneToOneOnSubclass() {
- Person p = new Person();
- p.name = "Gavin";
- Address a = new Address();
- a.entityName = "Gavin";
- a.zip = "3181";
- a.state = "VIC";
- a.street = "Karbarook Ave";
- p.address = a;
-
- Session s = openSession();
- Transaction t = s.beginTransaction();
- s.persist(p);
- t.commit();
- s.close();
-
- s = openSession();
- t = s.beginTransaction();
-
- EntityStatistics addressStats = getSessions().getStatistics().getEntityStatistics( Address.class.getName() );
- EntityStatistics mailingAddressStats = getSessions().getStatistics().getEntityStatistics("MailingAddress");
-
- p = (Person) s.createQuery("from Person p join fetch p.address left join fetch p.mailingAddress").uniqueResult();
- assertNotNull(p.address); assertNull(p.mailingAddress);
- s.clear();
-
- p = (Person) s.createQuery("select p from Person p join fetch p.address left join fetch p.mailingAddress").uniqueResult();
- assertNotNull(p.address); assertNull(p.mailingAddress);
- s.clear();
-
- Object[] stuff = (Object[]) s.createQuery("select p.name, p from Person p join fetch p.address left join fetch p.mailingAddress").uniqueResult();
- assertEquals(stuff.length, 2);
- p = (Person) stuff[1];
- assertNotNull(p.address); assertNull(p.mailingAddress);
- s.clear();
-
- assertEquals( addressStats.getFetchCount(), 0 );
- assertEquals( mailingAddressStats.getFetchCount(), 0 );
-
- p = (Person) s.createQuery("from Person p join fetch p.address").uniqueResult();
- assertNotNull(p.address); assertNull(p.mailingAddress);
- s.clear();
-
- assertEquals( addressStats.getFetchCount(), 0 );
- assertEquals( mailingAddressStats.getFetchCount(), 1 );
-
- p = (Person) s.createQuery("from Person").uniqueResult();
- assertNotNull(p.address); assertNull(p.mailingAddress);
- s.clear();
-
- assertEquals( addressStats.getFetchCount(), 0 );
- assertEquals( mailingAddressStats.getFetchCount(), 2 );
-
- p = (Person) s.createQuery("from Entity").uniqueResult();
- assertNotNull(p.address); assertNull(p.mailingAddress);
- s.clear();
-
- assertEquals( addressStats.getFetchCount(), 0 );
- assertEquals( mailingAddressStats.getFetchCount(), 3 );
-
- //note that in here join fetch is used for the nullable
- //one-to-one, due to a very special case of default
- p = (Person) s.get(Person.class, "Gavin");
- assertNotNull(p.address); assertNull(p.mailingAddress);
- s.clear();
-
- assertEquals( addressStats.getFetchCount(), 0 );
- assertEquals( mailingAddressStats.getFetchCount(), 3 );
-
- p = (Person) s.get(Entity.class, "Gavin");
- assertNotNull(p.address); assertNull(p.mailingAddress);
- s.clear();
-
- assertEquals( addressStats.getFetchCount(), 0 );
- assertEquals( mailingAddressStats.getFetchCount(), 3 );
-
- t.commit();
- s.close();
-
- s = openSession();
- t = s.beginTransaction();
- Org org = new Org();
- org.name = "IFA";
- Address a2 = new Address();
- a2.entityName = "IFA";
- a2.zip = "3181";
- a2.state = "VIC";
- a2.street = "Orrong Rd";
- s.persist(org);
- s.persist(a2);
- t.commit();
- s.close();
-
- s = openSession();
- t = s.beginTransaction();
- org = (Org) s.get(Entity.class, "IFA");
- s.clear();
-
- List list = s.createQuery("from Entity e order by e.name").list();
- p = (Person) list.get(0);
- assertNotNull(p.address); assertNull(p.mailingAddress);
- org = (Org) list.get(1);
- s.clear();
-
- list = s.createQuery("from Entity e left join fetch e.address left join fetch e.mailingAddress order by e.name").list();
- p = (Person) list.get(0);
- org = (Org) list.get(1);
- assertNotNull(p.address); assertNull(p.mailingAddress);
-
- s.clear();
- s.delete(p);
- s.delete( p.address );
- s.delete( org );
- s.delete( a2 );
- s.flush();
- t.commit();
- s.close();
-
- }
-
- protected String[] getMappings() {
- return new String[] { "onetoone/joined/Person.hbm.xml" };
- }
-
- protected void configure(Configuration cfg) {
- cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "false");
- cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
- }
-
- public static Test suite() {
- return new TestSuite(OneToOneTest.class);
- }
-
-}
-
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/link/Customer.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/link/Customer.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/link/Customer.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,22 @@
+//$Id: Customer.java 5686 2005-02-12 07:27:32Z steveebersole $
+package org.hibernate.test.onetoone.link;
+
+/**
+ * @author Gavin King
+ */
+public class Customer {
+ private Long id;
+ private Person person;
+ public Person getPerson() {
+ return person;
+ }
+ public void setPerson(Person person) {
+ this.person = person;
+ }
+ public Long getId() {
+ return id;
+ }
+ public void setId(Long id) {
+ this.id = id;
+ }
+}
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/link/Employee.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/link/Employee.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/link/Employee.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,22 @@
+//$Id: Employee.java 5686 2005-02-12 07:27:32Z steveebersole $
+package org.hibernate.test.onetoone.link;
+
+/**
+ * @author Gavin King
+ */
+public class Employee {
+ private Long id;
+ private Person person;
+ public Person getPerson() {
+ return person;
+ }
+ public void setPerson(Person person) {
+ this.person = person;
+ }
+ public Long getId() {
+ return id;
+ }
+ public void setId(Long id) {
+ this.id = id;
+ }
+}
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/link/OneToOneLinkTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/link/OneToOneLinkTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/link/OneToOneLinkTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,91 @@
+//$Id: OneToOneTest.java 5836 2005-02-21 14:41:05Z oneovthafew $
+package org.hibernate.test.onetoone.link;
+
+import java.util.Date;
+
+import junit.framework.Test;
+
+import org.hibernate.Hibernate;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+
+/**
+ * @author Gavin King
+ */
+public class OneToOneLinkTest extends FunctionalTestCase {
+
+ public OneToOneLinkTest(String str) {
+ super(str);
+ }
+
+ public String[] getMappings() {
+ return new String[] { "onetoone/link/Person.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( OneToOneLinkTest.class );
+ }
+
+ public void testOneToOneViaAssociationTable() {
+ Person p = new Person();
+ p.setName("Gavin King");
+ p.setDob( new Date() );
+ Employee e = new Employee();
+ p.setEmployee(e);
+ e.setPerson(p);
+
+ Session s = openSession();
+ Transaction t = s.beginTransaction();
+ s.persist(p);
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ e = (Employee) s.createQuery("from Employee e where e.person.name like 'Gavin%'").uniqueResult();
+ assertEquals( e.getPerson().getName(), "Gavin King" );
+ assertFalse( Hibernate.isInitialized( e.getPerson() ) );
+ assertNull( e.getPerson().getCustomer() );
+ s.clear();
+
+ e = (Employee) s.createQuery("from Employee e where e.person.dob = :date")
+ .setDate("date", new Date() )
+ .uniqueResult();
+ assertEquals( e.getPerson().getName(), "Gavin King" );
+ assertFalse( Hibernate.isInitialized( e.getPerson() ) );
+ assertNull( e.getPerson().getCustomer() );
+ s.clear();
+
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+
+ e = (Employee) s.createQuery("from Employee e join fetch e.person p left join fetch p.customer").uniqueResult();
+ assertTrue( Hibernate.isInitialized( e.getPerson() ) );
+ assertNull( e.getPerson().getCustomer() );
+ Customer c = new Customer();
+ e.getPerson().setCustomer(c);
+ c.setPerson( e.getPerson() );
+
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+
+ e = (Employee) s.createQuery("from Employee e join fetch e.person p left join fetch p.customer").uniqueResult();
+ assertTrue( Hibernate.isInitialized( e.getPerson() ) );
+ assertTrue( Hibernate.isInitialized( e.getPerson().getCustomer() ) );
+ assertNotNull( e.getPerson().getCustomer() );
+ s.delete(e);
+ t.commit();
+ s.close();
+
+ }
+
+}
+
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/link/Person.hbm.xml
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/link/Person.hbm.xml 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/link/Person.hbm.xml 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,69 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+ <!--
+
+ Demonstrates the mapping of two subtyping one-to-one relationships
+ to association tables using <many-to-one> nested inside <join>.
+ Note that the <join> elements specify optional="true", and that
+ there is an inverse="true" side of both joins.
+
+ -->
+
+<hibernate-mapping package="org.hibernate.test.onetoone.link">
+
+ <class name="Person">
+ <id name="name"/>
+ <property name="dob" type="date"/>
+ <join table="employeePerson"
+ inverse="true"
+ optional="true">
+ <key column="personId" unique="true"/>
+ <many-to-one name="employee"
+ column="employeeId"
+ cascade="all"
+ not-null="true"/>
+ </join>
+ <join table="customerPerson"
+ inverse="true"
+ optional="true">
+ <key column="personId" unique="true"/>
+ <many-to-one name="customer"
+ column="customerId"
+ cascade="all"
+ not-null="true"/>
+ </join>
+ </class>
+
+ <class name="Employee">
+ <id name="id" column="employeeId">
+ <generator class="native"/>
+ </id>
+ <join table="employeePerson"
+ optional="true">
+ <key column="employeeId"/>
+ <many-to-one name="person"
+ column="personId"
+ cascade="all"
+ not-null="true"
+ unique="true"/>
+ </join>
+ </class>
+
+ <class name="Customer">
+ <id name="id" column="customerId">
+ <generator class="native"/>
+ </id>
+ <join table="customerPerson" optional="true">
+ <key column="customerId"/>
+ <many-to-one name="person"
+ column="personId"
+ cascade="all"
+ not-null="true"
+ unique="true"/>
+ </join>
+ </class>
+
+</hibernate-mapping>
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/link/Person.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/link/Person.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/link/Person.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,38 @@
+//$Id: Person.java 5686 2005-02-12 07:27:32Z steveebersole $
+package org.hibernate.test.onetoone.link;
+
+import java.util.Date;
+
+/**
+ * @author Gavin King
+ */
+public class Person {
+ private String name;
+ private Date dob;
+ private Employee employee;
+ private Customer customer;
+ public Customer getCustomer() {
+ return customer;
+ }
+ public void setCustomer(Customer customer) {
+ this.customer = customer;
+ }
+ public Employee getEmployee() {
+ return employee;
+ }
+ public void setEmployee(Employee employee) {
+ this.employee = employee;
+ }
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public Date getDob() {
+ return dob;
+ }
+ public void setDob(Date dob) {
+ this.dob = dob;
+ }
+}
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/nopojo/DynamicMapOneToOneTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/nopojo/DynamicMapOneToOneTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/nopojo/DynamicMapOneToOneTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,82 @@
+//$Id: OneToOneTest.java 9012 2006-01-10 18:54:11Z steveebersole $
+package org.hibernate.test.onetoone.nopojo;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.Test;
+
+import org.hibernate.EntityMode;
+import org.hibernate.Session;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.stat.EntityStatistics;
+
+/**
+ * @author Gavin King
+ */
+public class DynamicMapOneToOneTest extends FunctionalTestCase {
+
+ public DynamicMapOneToOneTest(String str) {
+ super(str);
+ }
+
+ public String[] getMappings() {
+ return new String[] { "onetoone/nopojo/Person.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "false");
+ cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
+ cfg.setProperty( Environment.DEFAULT_ENTITY_MODE, EntityMode.MAP.toString() );
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( DynamicMapOneToOneTest.class );
+ }
+
+ public void testOneToOneOnSubclass() {
+ Map person = new HashMap();
+ person.put( "name", "Steve" );
+ Map address = new HashMap();
+ address.put( "zip", "12345" );
+ address.put( "state", "TX" );
+ address.put( "street", "123 Main St" );
+
+ person.put( "address", address );
+ address.put( "owner", person );
+
+ Session s = openSession();
+ s.beginTransaction();
+ s.persist( "Person", person );
+ s.getTransaction().commit();
+ s.close();
+
+ s = openSession();
+ s.beginTransaction();
+
+ EntityStatistics addressStats = getSessions().getStatistics().getEntityStatistics( "Address" );
+
+ person = ( Map ) s.createQuery( "from Person p join fetch p.address" ).uniqueResult();
+ assertNotNull( "could not locate person", person );
+ assertNotNull( "could not locate persons address", person.get( "address" ) );
+ s.clear();
+
+ Object[] tuple = ( Object[] ) s.createQuery( "select p.name, p from Person p join fetch p.address" ).uniqueResult();
+ assertEquals( tuple.length, 2 );
+ person = ( Map ) tuple[1];
+ assertNotNull( "could not locate person", person );
+ assertNotNull( "could not locate persons address", person.get( "address" ) );
+
+ s.delete( "Person", person );
+
+ s.getTransaction().commit();
+ s.close();
+
+ assertEquals( addressStats.getFetchCount(), 0 );
+ }
+
+}
+
Deleted: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/nopojo/OneToOneTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/nopojo/OneToOneTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/nopojo/OneToOneTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,84 +0,0 @@
-//$Id$
-package org.hibernate.test.onetoone.nopojo;
-
-import java.util.List;
-import java.util.Map;
-import java.util.HashMap;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.hibernate.EntityMode;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.cfg.Environment;
-import org.hibernate.stat.EntityStatistics;
-import org.hibernate.test.TestCase;
-
-/**
- * @author Gavin King
- */
-public class OneToOneTest extends TestCase {
-
- public OneToOneTest(String str) {
- super(str);
- }
-
- public void testOneToOneOnSubclass() {
- Map person = new HashMap();
- person.put( "name", "Steve" );
- Map address = new HashMap();
- address.put( "zip", "12345" );
- address.put( "state", "TX" );
- address.put( "street", "123 Main St" );
-
- person.put( "address", address );
- address.put( "owner", person );
-
- Session s = openSession();
- s.beginTransaction();
- s.persist( "Person", person );
- s.getTransaction().commit();
- s.close();
-
- s = openSession();
- s.beginTransaction();
-
- EntityStatistics addressStats = getSessions().getStatistics().getEntityStatistics( "Address" );
-
- person = ( Map ) s.createQuery( "from Person p join fetch p.address" ).uniqueResult();
- assertNotNull( "could not locate person", person );
- assertNotNull( "could not locate persons address", person.get( "address" ) );
- s.clear();
-
- Object[] tuple = ( Object[] ) s.createQuery( "select p.name, p from Person p join fetch p.address" ).uniqueResult();
- assertEquals( tuple.length, 2 );
- person = ( Map ) tuple[1];
- assertNotNull( "could not locate person", person );
- assertNotNull( "could not locate persons address", person.get( "address" ) );
-
- s.delete( "Person", person );
-
- s.getTransaction().commit();
- s.close();
-
- assertEquals( addressStats.getFetchCount(), 0 );
- }
-
- protected String[] getMappings() {
- return new String[] { "onetoone/nopojo/Person.hbm.xml" };
- }
-
- protected void configure(Configuration cfg) {
- cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "false");
- cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
- cfg.setProperty( Environment.DEFAULT_ENTITY_MODE, EntityMode.MAP.toString() );
- }
-
- public static Test suite() {
- return new TestSuite(OneToOneTest.class);
- }
-
-}
-
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/singletable/DiscrimSubclassOneToOneTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/singletable/DiscrimSubclassOneToOneTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/singletable/DiscrimSubclassOneToOneTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,148 @@
+//$Id: OneToOneTest.java 5836 2005-02-21 14:41:05Z oneovthafew $
+package org.hibernate.test.onetoone.singletable;
+
+import java.util.List;
+
+import junit.framework.Test;
+
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.stat.EntityStatistics;
+
+/**
+ * @author Gavin King
+ */
+public class DiscrimSubclassOneToOneTest extends FunctionalTestCase {
+
+ public DiscrimSubclassOneToOneTest(String str) {
+ super(str);
+ }
+
+ public String[] getMappings() {
+ return new String[] { "onetoone/singletable/Person.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "false");
+ cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( DiscrimSubclassOneToOneTest.class );
+ }
+
+ public void testOneToOneOnSubclass() {
+ Person p = new Person();
+ p.name = "Gavin";
+ Address a = new Address();
+ a.entityName = "Gavin";
+ a.zip = "3181";
+ a.state = "VIC";
+ a.street = "Karbarook Ave";
+ p.address = a;
+
+ Session s = openSession();
+ Transaction t = s.beginTransaction();
+ s.persist(p);
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+
+ EntityStatistics addressStats = getSessions().getStatistics().getEntityStatistics( Address.class.getName() );
+ EntityStatistics mailingAddressStats = getSessions().getStatistics().getEntityStatistics("MailingAddress");
+
+ p = (Person) s.createQuery("from Person p join fetch p.address left join fetch p.mailingAddress").uniqueResult();
+ assertNotNull(p.address); assertNull(p.mailingAddress);
+ s.clear();
+
+ assertEquals( addressStats.getFetchCount(), 0 );
+ assertEquals( mailingAddressStats.getFetchCount(), 0 );
+
+ p = (Person) s.createQuery("from Person p join fetch p.address").uniqueResult();
+ assertNotNull(p.address); assertNull(p.mailingAddress);
+ s.clear();
+
+ assertEquals( addressStats.getFetchCount(), 0 );
+ assertEquals( mailingAddressStats.getFetchCount(), 1 );
+
+ p = (Person) s.createQuery("from Person").uniqueResult();
+ assertNotNull(p.address); assertNull(p.mailingAddress);
+ s.clear();
+
+ assertEquals( addressStats.getFetchCount(), 1 );
+ assertEquals( mailingAddressStats.getFetchCount(), 2 );
+
+ p = (Person) s.createQuery("from Entity").uniqueResult();
+ assertNotNull(p.address); assertNull(p.mailingAddress);
+ s.clear();
+
+ assertEquals( addressStats.getFetchCount(), 2 );
+ assertEquals( mailingAddressStats.getFetchCount(), 3 );
+
+ //note that in here join fetch is used for the nullable
+ //one-to-one, due to a very special case of default
+ p = (Person) s.get(Person.class, "Gavin");
+ assertNotNull(p.address); assertNull(p.mailingAddress);
+ s.clear();
+
+ assertEquals( addressStats.getFetchCount(), 2 );
+ assertEquals( mailingAddressStats.getFetchCount(), 3 );
+
+ p = (Person) s.get(Entity.class, "Gavin");
+ assertNotNull(p.address); assertNull(p.mailingAddress);
+ s.clear();
+
+ assertEquals( addressStats.getFetchCount(), 2 );
+ assertEquals( mailingAddressStats.getFetchCount(), 3 );
+
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ Org org = new Org();
+ org.name = "IFA";
+ Address a2 = new Address();
+ a2.entityName = "IFA";
+ a2.zip = "3181";
+ a2.state = "VIC";
+ a2.street = "Orrong Rd";
+ org.addresses.add(a2);
+ s.persist(org);
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ org = (Org) s.get(Entity.class, "IFA");
+ s.clear();
+
+ List list = s.createQuery("from Entity e order by e.name").list();
+ p = (Person) list.get(0);
+ assertNotNull(p.address); assertNull(p.mailingAddress);
+ org = (Org) list.get(1);
+ assertEquals( org.addresses.size(), 1 );
+ s.clear();
+
+ list = s.createQuery("from Entity e left join fetch e.address left join fetch e.mailingAddress order by e.name").list();
+ p = (Person) list.get(0);
+ org = (Org) list.get(1);
+ assertNotNull(p.address); assertNull(p.mailingAddress);
+ assertEquals( org.addresses.size(), 1 );
+
+ s.delete(p);
+ s.delete(org);
+
+ t.commit();
+ s.close();
+
+ }
+
+}
+
Deleted: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/singletable/OneToOneTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/singletable/OneToOneTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/onetoone/singletable/OneToOneTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,148 +0,0 @@
-//$Id$
-package org.hibernate.test.onetoone.singletable;
-
-import java.util.List;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.cfg.Environment;
-import org.hibernate.stat.EntityStatistics;
-import org.hibernate.test.TestCase;
-
-/**
- * @author Gavin King
- */
-public class OneToOneTest extends TestCase {
-
- public OneToOneTest(String str) {
- super(str);
- }
-
- public void testOneToOneOnSubclass() {
- Person p = new Person();
- p.name = "Gavin";
- Address a = new Address();
- a.entityName = "Gavin";
- a.zip = "3181";
- a.state = "VIC";
- a.street = "Karbarook Ave";
- p.address = a;
-
- Session s = openSession();
- Transaction t = s.beginTransaction();
- s.persist(p);
- t.commit();
- s.close();
-
- s = openSession();
- t = s.beginTransaction();
-
- EntityStatistics addressStats = getSessions().getStatistics().getEntityStatistics( Address.class.getName() );
- EntityStatistics mailingAddressStats = getSessions().getStatistics().getEntityStatistics("MailingAddress");
-
- p = (Person) s.createQuery("from Person p join fetch p.address left join fetch p.mailingAddress").uniqueResult();
- assertNotNull(p.address); assertNull(p.mailingAddress);
- s.clear();
-
- assertEquals( addressStats.getFetchCount(), 0 );
- assertEquals( mailingAddressStats.getFetchCount(), 0 );
-
- p = (Person) s.createQuery("from Person p join fetch p.address").uniqueResult();
- assertNotNull(p.address); assertNull(p.mailingAddress);
- s.clear();
-
- assertEquals( addressStats.getFetchCount(), 0 );
- assertEquals( mailingAddressStats.getFetchCount(), 1 );
-
- p = (Person) s.createQuery("from Person").uniqueResult();
- assertNotNull(p.address); assertNull(p.mailingAddress);
- s.clear();
-
- assertEquals( addressStats.getFetchCount(), 1 );
- assertEquals( mailingAddressStats.getFetchCount(), 2 );
-
- p = (Person) s.createQuery("from Entity").uniqueResult();
- assertNotNull(p.address); assertNull(p.mailingAddress);
- s.clear();
-
- assertEquals( addressStats.getFetchCount(), 2 );
- assertEquals( mailingAddressStats.getFetchCount(), 3 );
-
- //note that in here join fetch is used for the nullable
- //one-to-one, due to a very special case of default
- p = (Person) s.get(Person.class, "Gavin");
- assertNotNull(p.address); assertNull(p.mailingAddress);
- s.clear();
-
- assertEquals( addressStats.getFetchCount(), 2 );
- assertEquals( mailingAddressStats.getFetchCount(), 3 );
-
- p = (Person) s.get(Entity.class, "Gavin");
- assertNotNull(p.address); assertNull(p.mailingAddress);
- s.clear();
-
- assertEquals( addressStats.getFetchCount(), 2 );
- assertEquals( mailingAddressStats.getFetchCount(), 3 );
-
- t.commit();
- s.close();
-
- s = openSession();
- t = s.beginTransaction();
- Org org = new Org();
- org.name = "IFA";
- Address a2 = new Address();
- a2.entityName = "IFA";
- a2.zip = "3181";
- a2.state = "VIC";
- a2.street = "Orrong Rd";
- org.addresses.add(a2);
- s.persist(org);
- t.commit();
- s.close();
-
- s = openSession();
- t = s.beginTransaction();
- org = (Org) s.get(Entity.class, "IFA");
- s.clear();
-
- List list = s.createQuery("from Entity e order by e.name").list();
- p = (Person) list.get(0);
- assertNotNull(p.address); assertNull(p.mailingAddress);
- org = (Org) list.get(1);
- assertEquals( org.addresses.size(), 1 );
- s.clear();
-
- list = s.createQuery("from Entity e left join fetch e.address left join fetch e.mailingAddress order by e.name").list();
- p = (Person) list.get(0);
- org = (Org) list.get(1);
- assertNotNull(p.address); assertNull(p.mailingAddress);
- assertEquals( org.addresses.size(), 1 );
-
- s.delete(p);
- s.delete(org);
-
- t.commit();
- s.close();
-
- }
-
- protected String[] getMappings() {
- return new String[] { "onetoone/singletable/Person.hbm.xml" };
- }
-
- protected void configure(Configuration cfg) {
- cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "false");
- cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
- }
-
- public static Test suite() {
- return new TestSuite(OneToOneTest.class);
- }
-
-}
-
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ops/AbstractOperationTestCase.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ops/AbstractOperationTestCase.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ops/AbstractOperationTestCase.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,25 +1,25 @@
package org.hibernate.test.ops;
-import org.hibernate.test.TestCase;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
+import org.hibernate.junit.functional.FunctionalTestCase;
/**
* {@inheritDoc}
*
* @author Steve Ebersole
*/
-public abstract class AbstractOperationTestCase extends TestCase {
+public abstract class AbstractOperationTestCase extends FunctionalTestCase {
public AbstractOperationTestCase(String name) {
super( name );
}
- protected void configure(Configuration cfg) {
+ public void configure(Configuration cfg) {
cfg.setProperty( Environment.GENERATE_STATISTICS, "true");
cfg.setProperty( Environment.STATEMENT_BATCH_SIZE, "0" );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "ops/Node.hbm.xml", "ops/Employer.hbm.xml", "ops/OptLockEntity.hbm.xml", "ops/OneToOne.hbm.xml" };
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ops/CreateTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ops/CreateTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ops/CreateTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -5,24 +5,24 @@
import java.util.Collection;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.PersistentObjectException;
import org.hibernate.Session;
import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.exception.ConstraintViolationException;
/**
* @author Gavin King
*/
public class CreateTest extends AbstractOperationTestCase {
-
+
public CreateTest(String str) {
super( str );
}
public static Test suite() {
- return new TestSuite( CreateTest.class );
+ return new FunctionalTestClassTestSuite( CreateTest.class );
}
public void testNoUpdatesOnCreateVersionedWithCollection() {
@@ -53,9 +53,9 @@
}
public void testCreateTree() {
-
+
clearCounts();
-
+
Session s = openSession();
Transaction tx = s.beginTransaction();
Node root = new Node("root");
@@ -64,7 +64,7 @@
s.persist(root);
tx.commit();
s.close();
-
+
assertInsertCount(2);
assertUpdateCount(0);
@@ -77,15 +77,15 @@
System.out.println("committing");
tx.commit();
s.close();
-
+
assertInsertCount(3);
assertUpdateCount(0);
}
-
+
public void testCreateTreeWithGeneratedId() {
-
+
clearCounts();
-
+
Session s = openSession();
Transaction tx = s.beginTransaction();
NumberedNode root = new NumberedNode("root");
@@ -94,7 +94,7 @@
s.persist(root);
tx.commit();
s.close();
-
+
assertInsertCount(2);
assertUpdateCount(0);
@@ -105,11 +105,11 @@
root.addChild(child2);
tx.commit();
s.close();
-
+
assertInsertCount(3);
assertUpdateCount(0);
}
-
+
public void testCreateException() {
Session s = openSession();
Transaction tx = s.beginTransaction();
@@ -118,7 +118,7 @@
s.persist(dupe);
tx.commit();
s.close();
-
+
s = openSession();
tx = s.beginTransaction();
s.persist(dupe);
@@ -131,10 +131,10 @@
}
tx.rollback();
s.close();
-
+
Node nondupe = new Node("nondupe");
nondupe.addChild(dupe);
-
+
s = openSession();
tx = s.beginTransaction();
s.persist(nondupe);
@@ -148,7 +148,7 @@
tx.rollback();
s.close();
}
-
+
public void testCreateExceptionWithGeneratedId() {
Session s = openSession();
Transaction tx = s.beginTransaction();
@@ -157,7 +157,7 @@
s.persist(dupe);
tx.commit();
s.close();
-
+
s = openSession();
tx = s.beginTransaction();
try {
@@ -169,10 +169,10 @@
}
tx.rollback();
s.close();
-
+
NumberedNode nondupe = new NumberedNode("nondupe");
nondupe.addChild(dupe);
-
+
s = openSession();
tx = s.beginTransaction();
try {
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ops/DeleteTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ops/DeleteTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ops/DeleteTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,9 +1,9 @@
package org.hibernate.test.ops;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Session;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* {@inheritDoc}
@@ -16,7 +16,7 @@
}
public static Test suite() {
- return new TestSuite( DeleteTest.class );
+ return new FunctionalTestClassTestSuite( DeleteTest.class );
}
public void testDeleteVersionedWithCollectionNoUpdate() {
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ops/GetLoadTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ops/GetLoadTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ops/GetLoadTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -7,14 +7,16 @@
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
-import org.hibernate.test.TestCase;
+
/**
* @author Gavin King
*/
-public class GetLoadTest extends TestCase {
+public class GetLoadTest extends FunctionalTestCase {
public GetLoadTest(String str) {
super(str);
@@ -90,20 +92,17 @@
assertEquals(count, fetches);
}
- protected void configure(Configuration cfg) {
+ public void configure(Configuration cfg) {
cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
cfg.setProperty(Environment.STATEMENT_BATCH_SIZE, "0");
}
- protected String[] getMappings() {
- return new String[] {
- "ops/Node.hbm.xml",
- "ops/Employer.hbm.xml"
- };
+ public String[] getMappings() {
+ return new String[] { "ops/Node.hbm.xml", "ops/Employer.hbm.xml" };
}
public static Test suite() {
- return new TestSuite(GetLoadTest.class);
+ return new FunctionalTestClassTestSuite(GetLoadTest.class);
}
public String getCacheConcurrencyStrategy() {
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ops/MergeTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ops/MergeTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ops/MergeTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -5,25 +5,25 @@
import java.util.Iterator;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.NonUniqueObjectException;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.criterion.Projections;
/**
* @author Gavin King
*/
public class MergeTest extends AbstractOperationTestCase {
-
+
public MergeTest(String str) {
super( str );
}
public static Test suite() {
- return new TestSuite( MergeTest.class );
+ return new FunctionalTestClassTestSuite( MergeTest.class );
}
public void testMergeBidiPrimayKeyOneToOne() throws Exception {
@@ -86,7 +86,7 @@
s.close();
}
- public void testNoExtraUpdatesOnMerge() throws Exception {
+ public void testNoExtraUpdatesOnMerge() throws Exception {
Session s = openSession();
s.beginTransaction();
Node node = new Node( "test" );
@@ -290,11 +290,11 @@
cleanup();
}
-
+
public void testMergeDeepTree() {
-
+
clearCounts();
-
+
Session s = openSession();
Transaction tx = s.beginTransaction();
Node root = new Node("root");
@@ -305,11 +305,11 @@
s.merge(root);
tx.commit();
s.close();
-
+
assertInsertCount(3);
assertUpdateCount(0);
clearCounts();
-
+
grandchild.setDescription("the grand child");
Node grandchild2 = new Node("grandchild2");
child.addChild( grandchild2 );
@@ -319,22 +319,22 @@
s.merge(root);
tx.commit();
s.close();
-
+
assertInsertCount(1);
assertUpdateCount(1);
clearCounts();
-
+
Node child2 = new Node("child2");
Node grandchild3 = new Node("grandchild3");
child2.addChild( grandchild3 );
root.addChild(child2);
-
+
s = openSession();
tx = s.beginTransaction();
s.merge(root);
tx.commit();
s.close();
-
+
assertInsertCount(2);
assertUpdateCount(0);
clearCounts();
@@ -351,11 +351,11 @@
s.close();
}
-
+
public void testMergeDeepTreeWithGeneratedId() {
-
+
clearCounts();
-
+
Session s = openSession();
Transaction tx = s.beginTransaction();
NumberedNode root = new NumberedNode("root");
@@ -366,11 +366,11 @@
root = (NumberedNode) s.merge(root);
tx.commit();
s.close();
-
+
assertInsertCount(3);
assertUpdateCount(0);
clearCounts();
-
+
child = (NumberedNode) root.getChildren().iterator().next();
grandchild = (NumberedNode) child.getChildren().iterator().next();
grandchild.setDescription("the grand child");
@@ -382,24 +382,24 @@
root = (NumberedNode) s.merge(root);
tx.commit();
s.close();
-
+
assertInsertCount(1);
assertUpdateCount(1);
clearCounts();
-
+
getSessions().evict(NumberedNode.class);
-
+
NumberedNode child2 = new NumberedNode("child2");
NumberedNode grandchild3 = new NumberedNode("grandchild3");
child2.addChild( grandchild3 );
root.addChild(child2);
-
+
s = openSession();
tx = s.beginTransaction();
root = (NumberedNode) s.merge(root);
tx.commit();
s.close();
-
+
assertInsertCount(2);
assertUpdateCount(0);
clearCounts();
@@ -413,11 +413,11 @@
s.close();
}
-
+
public void testMergeTree() {
-
+
clearCounts();
-
+
Session s = openSession();
Transaction tx = s.beginTransaction();
Node root = new Node("root");
@@ -426,33 +426,33 @@
s.persist(root);
tx.commit();
s.close();
-
+
assertInsertCount(2);
clearCounts();
-
+
root.setDescription("The root node");
child.setDescription("The child node");
-
+
Node secondChild = new Node("second child");
-
+
root.addChild(secondChild);
-
+
s = openSession();
tx = s.beginTransaction();
s.merge(root);
tx.commit();
s.close();
-
+
assertInsertCount(1);
assertUpdateCount(2);
cleanup();
}
-
+
public void testMergeTreeWithGeneratedId() {
-
+
clearCounts();
-
+
Session s = openSession();
Transaction tx = s.beginTransaction();
NumberedNode root = new NumberedNode("root");
@@ -461,39 +461,39 @@
s.persist(root);
tx.commit();
s.close();
-
+
assertInsertCount(2);
clearCounts();
-
+
root.setDescription("The root node");
child.setDescription("The child node");
-
+
NumberedNode secondChild = new NumberedNode("second child");
-
+
root.addChild(secondChild);
-
+
s = openSession();
tx = s.beginTransaction();
s.merge(root);
tx.commit();
s.close();
-
+
assertInsertCount(1);
assertUpdateCount(2);
cleanup();
}
-
+
public void testMergeManaged() {
-
+
Session s = openSession();
Transaction tx = s.beginTransaction();
NumberedNode root = new NumberedNode("root");
s.persist(root);
tx.commit();
-
+
clearCounts();
-
+
tx = s.beginTransaction();
NumberedNode child = new NumberedNode("child");
root.addChild(child);
@@ -506,24 +506,26 @@
assertTrue( root.getChildren().contains(mergedChild) );
//assertNotSame( mergedChild, s.merge(child) ); //yucky :(
tx.commit();
-
+
assertInsertCount(1);
assertUpdateCount(0);
-
+
assertEquals( root.getChildren().size(), 1 );
assertTrue( root.getChildren().contains(mergedChild) );
-
+
tx = s.beginTransaction();
- assertEquals(
+ assertEquals(
s.createCriteria(NumberedNode.class)
.setProjection( Projections.rowCount() )
- .uniqueResult(),
- new Integer(2)
+ .uniqueResult(),
+ new Integer(2)
);
+ s.close();
+
cleanup();
}
-
+
public void testRecursiveMergeTransient() {
Session s = openSession();
Transaction tx = s.beginTransaction();
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ops/Node.hbm.xml
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ops/Node.hbm.xml 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ops/Node.hbm.xml 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,14 +1,14 @@
<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
+<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
-
+
-->
<hibernate-mapping package="org.hibernate.test.ops">
-
+
<class name="Node" polymorphism="explicit">
<id name="name">
<generator class="assigned"/>
@@ -16,7 +16,7 @@
<property name="description"/>
<many-to-one name="parent"/>
<property name="created" not-null="true"/>
- <set name="children"
+ <set name="children"
inverse="true"
cascade="persist,merge,save-update,evict">
<key column="parent"/>
@@ -27,7 +27,7 @@
<one-to-many class="Node"/>
</set>
</class>
-
+
<class name="NumberedNode" polymorphism="explicit">
<id name="id" unsaved-value="0">
<generator class="native"/>
@@ -39,13 +39,13 @@
<property name="created" not-null="true"
type="imm_date"/>
<many-to-one name="parent" class="NumberedNode"/>
- <set name="children"
+ <set name="children"
inverse="true"
cascade="persist,merge,save-update">
<key column="parent"/>
<one-to-many class="NumberedNode"/>
</set>
</class>
-
+
</hibernate-mapping>
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ops/OneToOne.hbm.xml
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ops/OneToOne.hbm.xml 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ops/OneToOne.hbm.xml 2006-12-12 23:22:26 UTC (rev 10976)
@@ -37,7 +37,7 @@
<generator class="increment"/>
</id>
<property name="somePersonalDetail" column="SOME_DETAIL" type="string"/>
- <one-to-one name="person" class="Person" cascade="none" constrained="true" />
+ <one-to-one name="person" class="Person" cascade="none" constrained="true" />
</class>
</hibernate-mapping>
\ No newline at end of file
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ops/SaveOrUpdateTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ops/SaveOrUpdateTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ops/SaveOrUpdateTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -2,21 +2,21 @@
package org.hibernate.test.ops;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.intercept.FieldInterceptionHelper;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.criterion.Projections;
-import org.hibernate.test.TestCase;
/**
* @author Gavin King
*/
-public class SaveOrUpdateTest extends TestCase {
+public class SaveOrUpdateTest extends FunctionalTestCase {
public SaveOrUpdateTest(String str) {
super( str );
@@ -431,17 +431,17 @@
assertEquals( count, updates );
}
- protected void configure(Configuration cfg) {
+ public void configure(Configuration cfg) {
cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
cfg.setProperty( Environment.STATEMENT_BATCH_SIZE, "0" );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] {"ops/Node.hbm.xml"};
}
public static Test suite() {
- return new TestSuite( SaveOrUpdateTest.class );
+ return new FunctionalTestClassTestSuite( SaveOrUpdateTest.class );
}
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/optlock/Document.hbm.xml
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/optlock/Document.hbm.xml 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/optlock/Document.hbm.xml 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
@@ -12,44 +12,36 @@
-->
<hibernate-mapping package="org.hibernate.test.optlock">
-
- <class name="Document"
- entity-name="LockDirty"
- table="Document"
- optimistic-lock="dirty"
- dynamic-update="true">
- <id name="id">
- <generator class="native"/>
- </id>
- <property name="title"/>
- <property name="author"/>
- <component name="pubDate">
- <property name="year" not-null="true"/>
- <property name="month"/>
- </component>
- <property name="summary"/>
- <property name="totalSales" optimistic-lock="false"/>
- <property name="text" column="`text`"/>
- </class>
-
- <class name="Document"
- entity-name="LockAll"
- table="Document"
- optimistic-lock="all"
- dynamic-update="true">
- <id name="id">
- <generator class="native"/>
- </id>
- <property name="title"/>
- <property name="author"/>
- <component name="pubDate">
- <property name="year" not-null="true"/>
- <property name="month"/>
- </component>
- <property name="summary"/>
- <property name="totalSales" optimistic-lock="false"/>
- <property name="text" column="`text`"/>
- </class>
-
+
+ <class name="Document" entity-name="LockDirty" table="Document" optimistic-lock="dirty" dynamic-update="true">
+ <id name="id">
+ <generator class="native"/>
+ </id>
+ <property name="title"/>
+ <property name="author"/>
+ <component name="pubDate">
+ <property name="year" not-null="true"/>
+ <property name="month"/>
+ </component>
+ <property name="summary"/>
+ <property name="totalSales" optimistic-lock="false"/>
+ <property name="text" column="`text`"/>
+ </class>
+
+ <class name="Document" entity-name="LockAll" table="Document" optimistic-lock="all" dynamic-update="true">
+ <id name="id">
+ <generator class="native"/>
+ </id>
+ <property name="title"/>
+ <property name="author"/>
+ <component name="pubDate">
+ <property name="year" not-null="true"/>
+ <property name="month"/>
+ </component>
+ <property name="summary"/>
+ <property name="totalSales" optimistic-lock="false"/>
+ <property name="text" column="`text`"/>
+ </class>
+
</hibernate-mapping>
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/optlock/OptimisticLockTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/optlock/OptimisticLockTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/optlock/OptimisticLockTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -2,14 +2,14 @@
package org.hibernate.test.optlock;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.JDBCException;
import org.hibernate.Session;
import org.hibernate.StaleObjectStateException;
import org.hibernate.StaleStateException;
import org.hibernate.dialect.SQLServerDialect;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* Tests relating to the optimisitc-lock mapping option.
@@ -17,20 +17,20 @@
* @author Gavin King
* @author Steve Ebersole
*/
-public class OptimisticLockTest extends TestCase {
-
+public class OptimisticLockTest extends FunctionalTestCase {
+
public OptimisticLockTest(String str) {
super(str);
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "optlock/Document.hbm.xml" };
}
public static Test suite() {
- return new TestSuite(OptimisticLockTest.class);
+ return new FunctionalTestClassTestSuite( OptimisticLockTest.class );
}
-
+
public void testOptimisticLockDirty() {
testUpdateOptimisticLockFailure( "LockDirty" );
}
@@ -46,6 +46,7 @@
public void testOptimisticLockAllDelete() {
testDeleteOptimisticLockFailure( "LockAll" );
}
+
private void testUpdateOptimisticLockFailure(String entityName) {
Session mainSession = openSession();
mainSession.beginTransaction();
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ordered/OrderByTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ordered/OrderByTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ordered/OrderByTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -4,22 +4,30 @@
import java.util.Iterator;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.FetchMode;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class OrderByTest extends TestCase {
+public class OrderByTest extends FunctionalTestCase {
public OrderByTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "ordered/Search.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( OrderByTest.class );
+ }
public void testOrderBy() {
Search s = new Search("Hibernate");
@@ -75,14 +83,6 @@
tx.commit();
sess.close();
}
-
- protected String[] getMappings() {
- return new String[] { "ordered/Search.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(OrderByTest.class);
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/orphan/OrphanIdRollbackTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/orphan/OrphanIdRollbackTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/orphan/OrphanIdRollbackTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -2,27 +2,36 @@
package org.hibernate.test.orphan;
import junit.framework.Test;
-import junit.framework.TestSuite;
+
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Emmanuel Bernard
*/
-public class OrphanIdRollbackTest extends TestCase {
+public class OrphanIdRollbackTest extends FunctionalTestCase {
public OrphanIdRollbackTest(String str) {
super(str);
}
- protected void configure(Configuration cfg) {
+ public String[] getMappings() {
+ return new String[] { "orphan/ProductAndIdRollback.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
cfg.setProperty( Environment.USE_IDENTIFIER_ROLLBACK, "true");
super.configure( cfg );
}
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( OrphanIdRollbackTest.class );
+ }
+
public void testOrphanDeleteOnDelete() {
Session session = openSession();
Transaction t = session.beginTransaction();
@@ -39,13 +48,5 @@
session.close();
}
- protected String[] getMappings() {
- return new String[] { "orphan/ProductAndIdRollback.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite( OrphanIdRollbackTest.class);
- }
-
}
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/orphan/OrphanSuite.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/orphan/OrphanSuite.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/orphan/OrphanSuite.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -0,0 +1,19 @@
+package org.hibernate.test.orphan;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class OrphanSuite {
+ public static Test suite() {
+ TestSuite suite = new TestSuite( "orphan delete suite" );
+ suite.addTest( OrphanIdRollbackTest.suite() );
+ suite.addTest( OrphanTest.suite() );
+ suite.addTest( PropertyRefTest.suite() );
+ return suite;
+ }
+}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/orphan/OrphanTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/orphan/OrphanTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/orphan/OrphanTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -2,23 +2,31 @@
package org.hibernate.test.orphan;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.LockMode;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.util.SerializationHelper;
/**
* @author Gavin King
*/
-public class OrphanTest extends TestCase {
+public class OrphanTest extends FunctionalTestCase {
public OrphanTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "orphan/Product.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( OrphanTest.class );
+ }
public void testOrphanDeleteOnDelete() {
Session session = openSession();
@@ -286,15 +294,6 @@
t.commit();
session.close();
}
-
-
- protected String[] getMappings() {
- return new String[] { "orphan/Product.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(OrphanTest.class);
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/orphan/PropertyRefTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/orphan/PropertyRefTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/orphan/PropertyRefTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -2,11 +2,11 @@
package org.hibernate.test.orphan;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
@@ -14,19 +14,20 @@
*
* @author Steve Ebersole
*/
-public class PropertyRefTest extends TestCase {
+public class PropertyRefTest extends FunctionalTestCase {
public PropertyRefTest(String name) {
super( name );
}
- protected String[] getMappings() {
- return new String[] {
- "orphan/User.hbm.xml",
- "orphan/Mail.hbm.xml"
- };
+ public String[] getMappings() {
+ return new String[] { "orphan/User.hbm.xml", "orphan/Mail.hbm.xml" };
}
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( PropertyRefTest.class );
+ }
+
public void testDeleteParentWithBidirOrphanDeleteCollectionBasedOnPropertyRef() {
Session session = openSession();
Transaction txn = session.beginTransaction();
@@ -51,9 +52,5 @@
txn.commit();
session.close();
}
-
- public static Test suite() {
- return new TestSuite(PropertyRefTest.class);
- }
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/pagination/PaginationTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/pagination/PaginationTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/pagination/PaginationTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -4,26 +4,41 @@
import java.math.BigDecimal;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.criterion.Order;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class PaginationTest extends TestCase {
+public class PaginationTest extends FunctionalTestCase {
public PaginationTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "pagination/DataPoint.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty(Environment.STATEMENT_BATCH_SIZE, "20");
+ }
+
+ public String getCacheConcurrencyStrategy() {
+ return null;
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( PaginationTest.class );
+ }
public void testPagination() {
-
Session s = openSession();
Transaction t = s.beginTransaction();
for ( int i=0; i<10; i++ ) {
@@ -57,22 +72,5 @@
s.close();
}
-
- protected void configure(Configuration cfg) {
- cfg.setProperty(Environment.STATEMENT_BATCH_SIZE, "20");
- }
-
- protected String[] getMappings() {
- return new String[] { "pagination/DataPoint.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(PaginationTest.class);
- }
-
- public String getCacheConcurrencyStrategy() {
- return null;
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/pretty/SQLFormatterTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/pretty/SQLFormatterTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/pretty/SQLFormatterTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -2,12 +2,15 @@
import java.util.StringTokenizer;
-import junit.framework.TestCase;
-
import org.hibernate.pretty.Formatter;
+import org.hibernate.junit.UnitTestCase;
-public class SQLFormatterTest extends TestCase {
+public class SQLFormatterTest extends UnitTestCase {
+ public SQLFormatterTest(String string) {
+ super( string );
+ }
+
public void testNoLoss() {
assertNoLoss("insert into Address (city, state, zip, \"from\") values (?, ?, ?, 'insert value')");
assertNoLoss("delete from Address where id = ? and version = ?");
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/basic/Person.hbm.xml
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/basic/Person.hbm.xml 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/basic/Person.hbm.xml 2006-12-12 23:22:26 UTC (rev 10976)
@@ -8,10 +8,10 @@
Demonstrates the use of property-ref to map legacy data where
foreign keys reference something other than the primary key of
the associated entity. Here we show:
-
- (1) A one-to-one foreign key association (prefer primary key
+
+ (1) A one-to-one foreign key association (prefer primary key
associations)
-
+
(2) A bidirectional one-to-many association on a key that is
not the primary key (prefer associations from foreign keys
to primary keys)
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/basic/PropertyRefTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/basic/PropertyRefTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/basic/PropertyRefTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -5,7 +5,6 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.FetchMode;
import org.hibernate.Hibernate;
@@ -13,29 +12,26 @@
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.ForeignKey;
import org.hibernate.mapping.PersistentClass;
-import org.hibernate.test.TestCase;
/**
* @author Gavin King
*/
-public class PropertyRefTest extends TestCase {
-
- public PropertyRefTest(String str) {
- super(str);
+public class PropertyRefTest extends FunctionalTestCase {
+
+ public PropertyRefTest(String name) {
+ super( name );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "propertyref/basic/Person.hbm.xml" };
}
- public static Test suite() {
- return new TestSuite(PropertyRefTest.class);
- }
-
- protected void configure(Configuration cfg) {
+ public void configure(Configuration cfg) {
cfg.setProperty(Environment.DEFAULT_BATCH_FETCH_SIZE, "1");
cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
}
@@ -44,6 +40,10 @@
return null;
}
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( PropertyRefTest.class );
+ }
+
public void testNonLazyBagKeyPropertyRef() {
Session s = openSession();
Transaction t = s.beginTransaction();
@@ -115,7 +115,7 @@
t.commit();
s.close();
}
-
+
public void testOneToOnePropertyRef() {
Session s = openSession();
Transaction t = s.beginTransaction();
@@ -139,7 +139,7 @@
s.save(act);
s.flush();
s.clear();
-
+
p = (Person) s.get( Person.class, p.getId() ); //get address reference by outer join
p2 = (Person) s.get( Person.class, p2.getId() ); //get null address reference by outer join
assertNull( p2.getAddress() );
@@ -148,13 +148,13 @@
assertEquals( l.size(), 2 );
assertTrue( l.contains(p) && l.contains(p2) );
s.clear();
-
+
l = s.createQuery("from Person p order by p.name").list(); //get address references by sequential selects
assertEquals( l.size(), 2 );
assertNull( ( (Person) l.get(0) ).getAddress() );
assertNotNull( ( (Person) l.get(1) ).getAddress() );
s.clear();
-
+
l = s.createQuery("from Person p left join fetch p.address a order by a.country").list(); //get em by outer join
assertEquals( l.size(), 2 );
if ( ( (Person) l.get(0) ).getName().equals("Max") ) {
@@ -166,7 +166,7 @@
assertNotNull( ( (Person) l.get(0) ).getAddress() );
}
s.clear();
-
+
l = s.createQuery("from Person p left join p.accounts a").list();
for ( int i=0; i<2; i++ ) {
Object[] row = (Object[]) l.get(i);
@@ -189,16 +189,16 @@
assertTrue( Hibernate.isInitialized(acc.getUser()) );
assertNotNull(acc.getUser());
assertTrue( acc.getUser().getAccounts().contains(acc) );
-
+
s.createQuery("delete from Address").executeUpdate();
s.createQuery("delete from Account").executeUpdate(); // to not break constraint violation between Person and Account
s.createQuery("delete from Person").executeUpdate();
-
+
t.commit();
s.close();
}
-
+
public void testJoinFetchPropertyRef() {
Session s = openSession();
Transaction t = s.beginTransaction();
@@ -218,7 +218,7 @@
getSessions().getStatistics().clear();
p = (Person) s.get( Person.class, p.getId() ); //get address reference by outer join
-
+
assertTrue( Hibernate.isInitialized( p.getAddress() ) );
assertNotNull( p.getAddress() );
assertEquals( getSessions().getStatistics().getPrepareStatementCount(), 1 );
@@ -231,7 +231,7 @@
p = (Person) s.createCriteria(Person.class)
.setFetchMode("address", FetchMode.SELECT)
.uniqueResult(); //get address reference by select
-
+
assertTrue( Hibernate.isInitialized( p.getAddress() ) );
assertNotNull( p.getAddress() );
assertEquals( getSessions().getStatistics().getPrepareStatementCount(), 2 );
@@ -239,30 +239,30 @@
s.createQuery("delete from Address").executeUpdate();
s.createQuery("delete from Person").executeUpdate();
-
+
t.commit();
s.close();
}
public void testForeignKeyCreation() {
PersistentClass classMapping = getCfg().getClassMapping("org.hibernate.test.propertyref.basic.Account");
-
+
Iterator foreignKeyIterator = classMapping.getTable().getForeignKeyIterator();
boolean found = false;
while ( foreignKeyIterator.hasNext() ) {
ForeignKey element = (ForeignKey) foreignKeyIterator.next();
if(element.getReferencedEntityName().equals(Person.class.getName() ) ) {
-
+
if(!element.isReferenceToPrimaryKey() ) {
List referencedColumns = element.getReferencedColumns();
Column column = (Column) referencedColumns.get(0);
if(column.getName().equals("person_userid") ) {
found = true; // extend test to include the columns
- }
+ }
}
}
}
-
+
assertTrue("Property ref foreign key not found",found);
}
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/complete/CompleteComponentPropertyRefTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/complete/CompleteComponentPropertyRefTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/complete/CompleteComponentPropertyRefTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,28 +1,28 @@
package org.hibernate.test.propertyref.component.complete;
import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.hibernate.test.TestCase;
+import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.Hibernate;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class CompleteComponentPropertyRefTest extends TestCase {
+public class CompleteComponentPropertyRefTest extends FunctionalTestCase {
- public CompleteComponentPropertyRefTest(String str) {
- super(str);
+ public CompleteComponentPropertyRefTest(String name) {
+ super( name );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "propertyref/component/complete/Mapping.hbm.xml" };
}
public static Test suite() {
- return new TestSuite( CompleteComponentPropertyRefTest.class);
+ return new FunctionalTestClassTestSuite( CompleteComponentPropertyRefTest.class );
}
public void testComponentPropertyRef() {
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/partial/PartialComponentPropertyRefTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/partial/PartialComponentPropertyRefTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/component/partial/PartialComponentPropertyRefTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -2,28 +2,28 @@
package org.hibernate.test.propertyref.component.partial;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class PartialComponentPropertyRefTest extends TestCase {
+public class PartialComponentPropertyRefTest extends FunctionalTestCase {
- public PartialComponentPropertyRefTest(String str) {
- super(str);
+ public PartialComponentPropertyRefTest(String name) {
+ super( name );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "propertyref/component/partial/Mapping.hbm.xml" };
}
public static Test suite() {
- return new TestSuite( PartialComponentPropertyRefTest.class);
+ return new FunctionalTestClassTestSuite( PartialComponentPropertyRefTest.class );
}
public void testComponentPropertyRef() {
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/discrim/SubclassPropertyRefTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/discrim/SubclassPropertyRefTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/discrim/SubclassPropertyRefTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -2,28 +2,28 @@
package org.hibernate.test.propertyref.inheritence.discrim;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class SubclassPropertyRefTest extends TestCase {
+public class SubclassPropertyRefTest extends FunctionalTestCase {
- public SubclassPropertyRefTest(String str) {
- super( str );
+ public SubclassPropertyRefTest(String name) {
+ super( name );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "propertyref/inheritence/discrim/Person.hbm.xml" };
}
public static Test suite() {
- return new TestSuite( SubclassPropertyRefTest.class );
+ return new FunctionalTestClassTestSuite( SubclassPropertyRefTest.class );
}
public void testOneToOnePropertyRef() {
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/joined/JoinedSubclassPropertyRefTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/joined/JoinedSubclassPropertyRefTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/joined/JoinedSubclassPropertyRefTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -2,29 +2,29 @@
package org.hibernate.test.propertyref.inheritence.joined;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.FetchMode;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class JoinedSubclassPropertyRefTest extends TestCase {
+public class JoinedSubclassPropertyRefTest extends FunctionalTestCase {
- public JoinedSubclassPropertyRefTest(String str) {
- super(str);
+ public JoinedSubclassPropertyRefTest(String name) {
+ super( name );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "propertyref/inheritence/joined/Person.hbm.xml" };
}
public static Test suite() {
- return new TestSuite( JoinedSubclassPropertyRefTest.class);
+ return new FunctionalTestClassTestSuite( JoinedSubclassPropertyRefTest.class );
}
public void testPropertyRefToJoinedSubclass() {
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/union/UnionSubclassPropertyRefTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/union/UnionSubclassPropertyRefTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/propertyref/inheritence/union/UnionSubclassPropertyRefTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,28 +1,28 @@
package org.hibernate.test.propertyref.inheritence.union;
import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.hibernate.test.TestCase;
+import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.Hibernate;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class UnionSubclassPropertyRefTest extends TestCase {
+public class UnionSubclassPropertyRefTest extends FunctionalTestCase {
- public UnionSubclassPropertyRefTest(String str) {
- super( str );
+ public UnionSubclassPropertyRefTest(String name) {
+ super( name );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "propertyref/inheritence/union/Person.hbm.xml" };
}
public static Test suite() {
- return new TestSuite( UnionSubclassPropertyRefTest.class );
+ return new FunctionalTestClassTestSuite( UnionSubclassPropertyRefTest.class );
}
public void testOneToOnePropertyRef() {
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/proxy/ProxyTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/proxy/ProxyTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/proxy/ProxyTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -5,33 +5,49 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.FlushMode;
import org.hibernate.Hibernate;
+import org.hibernate.LazyInitializationException;
import org.hibernate.LockMode;
+import org.hibernate.ObjectNotFoundException;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.FlushMode;
-import org.hibernate.ObjectNotFoundException;
-import org.hibernate.LazyInitializationException;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.impl.SessionImpl;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.proxy.HibernateProxy;
-import org.hibernate.test.TestCase;
import org.hibernate.util.SerializationHelper;
/**
* @author Gavin King
*/
-public class ProxyTest extends TestCase {
+public class ProxyTest extends FunctionalTestCase {
- public ProxyTest(String str) {
- super(str);
+ public ProxyTest(String name) {
+ super( name );
}
-
+
+ public String[] getMappings() {
+ return new String[] { "proxy/DataPoint.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ super.configure( cfg );
+ cfg.setProperty( Environment.STATEMENT_BATCH_SIZE, "0" ); // problem on HSQLDB (go figure)
+ }
+
+ public String getCacheConcurrencyStrategy() {
+ return null;
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( ProxyTest.class );
+ }
+
public void testFinalizeFiltered() {
-
Session s = openSession();
Transaction t = s.beginTransaction();
DataPoint dp = new DataPoint();
@@ -283,23 +299,6 @@
s.close();
}
- protected String[] getMappings() {
- return new String[] { "proxy/DataPoint.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(ProxyTest.class);
- }
-
- public String getCacheConcurrencyStrategy() {
- return null;
- }
-
- protected void configure(Configuration cfg) {
- super.configure( cfg );
- cfg.setProperty( Environment.STATEMENT_BATCH_SIZE, "0" ); // problem on HSQLDB (go figure)
- }
-
public void testFullyLoadedPCSerialization() {
Session s = openSession();
Transaction t = s.beginTransaction();
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/querycache/QueryCacheTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/querycache/QueryCacheTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/querycache/QueryCacheTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -5,27 +5,42 @@
import java.util.Map;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.stat.EntityStatistics;
import org.hibernate.stat.QueryStatistics;
-import org.hibernate.stat.CollectionStatistics;
-import org.hibernate.test.TestCase;
import org.hibernate.transform.Transformers;
/**
* @author Gavin King
*/
-public class QueryCacheTest extends TestCase {
+public class QueryCacheTest extends FunctionalTestCase {
public QueryCacheTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "querycache/Item.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ super.configure( cfg );
+ cfg.setProperty( Environment.USE_QUERY_CACHE, "true" );
+ cfg.setProperty( Environment.CACHE_REGION_PREFIX, "foo" );
+ cfg.setProperty( Environment.USE_SECOND_LEVEL_CACHE, "true" );
+ cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( QueryCacheTest.class );
+ }
public void testQueryCacheInvalidation() throws Exception {
@@ -258,20 +273,5 @@
}
- protected String[] getMappings() {
- return new String[] { "querycache/Item.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(QueryCacheTest.class);
- }
-
- protected void configure(Configuration cfg) {
- super.configure( cfg );
- cfg.setProperty( Environment.USE_QUERY_CACHE, "true" );
- cfg.setProperty( Environment.CACHE_REGION_PREFIX, "foo" );
- cfg.setProperty( Environment.USE_SECOND_LEVEL_CACHE, "true" );
- cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
- }
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/readonly/ReadOnlyTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/readonly/ReadOnlyTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/readonly/ReadOnlyTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -5,31 +5,44 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.CacheMode;
+import org.hibernate.Hibernate;
import org.hibernate.ScrollMode;
import org.hibernate.ScrollableResults;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.Hibernate;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
- * This is how to do batch processing in Hibernate.
- * Remember to enable JDBC batch updates, or this
- * test will take a Very Long Time!
*
* @author Gavin King
*/
-public class ReadOnlyTest extends TestCase {
+public class ReadOnlyTest extends FunctionalTestCase {
public ReadOnlyTest(String str) {
super(str);
}
+ public String[] getMappings() {
+ return new String[] { "readonly/DataPoint.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty(Environment.STATEMENT_BATCH_SIZE, "20");
+ }
+
+ public String getCacheConcurrencyStrategy() {
+ return null;
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( ReadOnlyTest.class );
+ }
+
public void testReadOnlyOnProxiesFailureExpected() {
Session s = openSession();
s.setCacheMode( CacheMode.IGNORE );
@@ -103,22 +116,6 @@
s.close();
}
-
- protected void configure(Configuration cfg) {
- cfg.setProperty(Environment.STATEMENT_BATCH_SIZE, "20");
- }
- protected String[] getMappings() {
- return new String[] { "readonly/DataPoint.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(ReadOnlyTest.class);
- }
-
- public String getCacheConcurrencyStrategy() {
- return null;
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/rowid/Point.hbm.xml
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/rowid/Point.hbm.xml 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/rowid/Point.hbm.xml 2006-12-12 23:22:26 UTC (rev 10976)
@@ -17,11 +17,7 @@
<key-property name="y" column="`y`"/>
</composite-id>
<property name="description"/>
- <property name="row"
- type="rowid"
- column="rowid"
- insert="false"
- update="false"/>
+ <property name="row" type="rowid" column="rowid" insert="false" update="false"/>
</class>
</hibernate-mapping>
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/rowid/RowIdTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/rowid/RowIdTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/rowid/RowIdTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -2,56 +2,67 @@
package org.hibernate.test.rowid;
import java.math.BigDecimal;
-import java.sql.DatabaseMetaData;
-import java.sql.ResultSet;
import java.sql.Statement;
+import java.sql.SQLException;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.dialect.Oracle9Dialect;
-import org.hibernate.test.TestCase;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.junit.functional.DatabaseSpecificFunctionalTestCase;
/**
* @author Gavin King
*/
-public class RowIdTest extends TestCase {
+public class RowIdTest extends DatabaseSpecificFunctionalTestCase {
public RowIdTest(String str) {
super(str);
}
-
- protected boolean recreateSchema() {
+
+ public String[] getMappings() {
+ return new String[] { "rowid/Point.hbm.xml" };
+ }
+
+ public String getCacheConcurrencyStrategy() {
+ return null;
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( RowIdTest.class );
+ }
+
+ public boolean appliesTo(Dialect dialect) {
+ return dialect instanceof Oracle9Dialect;
+ }
+
+ public boolean createSchema() {
return false;
}
-
- public void setUp() throws Exception {
- super.setUp();
- if ( !( getDialect() instanceof Oracle9Dialect ) ) return;
- Session s = openSession();
- Statement st = s.connection().createStatement();
+
+ public void afterSessionFactoryBuilt() {
+ super.afterSessionFactoryBuilt();
try {
- st.execute( "drop table Point");
+ Session s = openSession();
+ Statement st = s.connection().createStatement();
+ try {
+ st.execute( "drop table Point");
+ }
+ catch( Throwable t ) {
+ // ignore
+ }
+ st.execute("create table Point (\"x\" number(19,2) not null, \"y\" number(19,2) not null, description varchar2(255) )");
+ s.close();
}
- catch( Throwable t ) {
- // ignore
+ catch ( SQLException e ) {
+ throw new RuntimeException( "Unable to build actual schema : " + e.getMessage() );
}
- st.execute("create table Point (\"x\" number(19,2) not null, \"y\" number(19,2) not null, description varchar2(255) )");
- s.close();
}
- public void tearDown() throws Exception {
- /*Session s = openSession();
- Statement st = s.connection().createStatement();
- st.execute("drop table Point");
- s.close();*/
- }
-
public void testRowId() {
- if ( !( getDialect() instanceof Oracle9Dialect ) ) return;
-
Session s = openSession();
Transaction t = s.beginTransaction();
Point p = new Point( new BigDecimal(1.0), new BigDecimal(1.0) );
@@ -78,18 +89,6 @@
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "rowid/Point.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(RowIdTest.class);
- }
-
- public String getCacheConcurrencyStrategy() {
- return null;
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/schemaupdate/MigrationTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/schemaupdate/MigrationTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/schemaupdate/MigrationTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -4,45 +4,43 @@
import junit.framework.TestSuite;
import org.hibernate.cfg.Configuration;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.UnitTestCase;
import org.hibernate.tool.hbm2ddl.SchemaExport;
import org.hibernate.tool.hbm2ddl.SchemaUpdate;
/**
* @author Max Rydahl Andersen
*/
-public class MigrationTest extends TestCase {
-
+public class MigrationTest extends UnitTestCase {
+
public MigrationTest(String str) {
- super(str);
+ super( str );
}
+ public static Test suite() {
+ return new TestSuite( MigrationTest.class );
+ }
+
public void testSimpleColumnAddition() {
+ String resource1 = "org/hibernate/test/schemaupdate/1_Version.hbm.xml";
+ String resource2 = "org/hibernate/test/schemaupdate/2_Version.hbm.xml";
+
Configuration v1cfg = new Configuration();
- v1cfg.addResource(getBaseForMappings() + "/schemaupdate/1_Version.hbm.xml");
-
- new SchemaExport(v1cfg).execute(false, true, true, false);
-
- SchemaUpdate v1schemaUpdate = new SchemaUpdate(v1cfg);
- v1schemaUpdate.execute(true, true);
-
- assertEquals(0, v1schemaUpdate.getExceptions().size());
-
+ v1cfg.addResource( resource1 );
+ new SchemaExport( v1cfg ).execute( false, true, true, false );
+
+ SchemaUpdate v1schemaUpdate = new SchemaUpdate( v1cfg );
+ v1schemaUpdate.execute( true, true );
+
+ assertEquals( 0, v1schemaUpdate.getExceptions().size() );
+
Configuration v2cfg = new Configuration();
- v2cfg.addResource(getBaseForMappings() + "/schemaupdate/2_Version.hbm.xml");
-
- SchemaUpdate v2schemaUpdate = new SchemaUpdate(v2cfg);
- v2schemaUpdate.execute(true, true);
- assertEquals(0, v2schemaUpdate.getExceptions().size());
-
- }
-
- protected String[] getMappings() {
- return new String[] { };
- }
+ v2cfg.addResource( resource2 );
- public static Test suite() {
- return new TestSuite(MigrationTest.class);
+ SchemaUpdate v2schemaUpdate = new SchemaUpdate( v2cfg );
+ v2schemaUpdate.execute( true, true );
+ assertEquals( 0, v2schemaUpdate.getExceptions().size() );
+
}
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sorted/SortTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sorted/SortTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sorted/SortTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -4,22 +4,30 @@
import java.util.Iterator;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.FetchMode;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class SortTest extends TestCase {
+public class SortTest extends FunctionalTestCase {
public SortTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "sorted/Search.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( SortTest.class );
+ }
public void testOrderBy() {
Search s = new Search("Hibernate");
@@ -66,14 +74,6 @@
tx.commit();
sess.close();
}
-
- protected String[] getMappings() {
- return new String[] { "sorted/Search.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(SortTest.class);
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/DataDirectOracleSQLTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/DataDirectOracleSQLTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/DataDirectOracleSQLTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -2,10 +2,10 @@
package org.hibernate.test.sql;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.dialect.DataDirectOracle9Dialect;
import org.hibernate.dialect.Dialect;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Max Rydahl Andersen
@@ -16,12 +16,12 @@
super(str);
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "sql/OracleEmployment.hbm.xml", "sql/OracleDataDirectDriverStoredProcedures.hbm.xml" };
}
public static Test suite() {
- return new TestSuite(DataDirectOracleSQLTest.class);
+ return new FunctionalTestClassTestSuite( DataDirectOracleSQLTest.class );
}
public boolean appliesTo(Dialect dialect) {
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/Db2SQLTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/Db2SQLTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/Db2SQLTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -2,11 +2,10 @@
package org.hibernate.test.sql;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.dialect.DB2Dialect;
import org.hibernate.dialect.Dialect;
-import org.hibernate.dialect.Oracle9Dialect;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Max Rydahl Andersen
@@ -17,12 +16,12 @@
super(str);
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "sql/Db2Employment.hbm.xml" };
}
public static Test suite() {
- return new TestSuite(Db2SQLTest.class);
+ return new FunctionalTestClassTestSuite( Db2SQLTest.class );
}
public boolean appliesTo(Dialect dialect) {
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/GeneralTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/GeneralTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/GeneralTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,14 +1,13 @@
package org.hibernate.test.sql;
import java.io.Serializable;
+import java.math.BigDecimal;
+import java.math.BigInteger;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.math.BigInteger;
-import java.math.BigDecimal;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.HibernateException;
@@ -17,32 +16,33 @@
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.transform.DistinctRootEntityResultTransformer;
import org.hibernate.transform.Transformers;
/**
* @author Steve Ebersole
*/
-public class GeneralTest extends TestCase {
+public class GeneralTest extends FunctionalTestCase {
public GeneralTest(String x) {
super( x );
}
- public static Test suite() {
- return new TestSuite(GeneralTest.class);
- }
-
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "sql/General.hbm.xml" };
}
- protected void configure(Configuration cfg) {
+ public void configure(Configuration cfg) {
super.configure( cfg );
cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
}
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( GeneralTest.class );
+ }
+
protected String getOrganizationFetchJoinEmploymentSQL() {
return "SELECT org.ORGID as {org.id}, " +
" org.NAME as {org.name}, " +
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/HandSQLTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/HandSQLTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/HandSQLTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,23 +1,22 @@
package org.hibernate.test.sql;
-import org.hibernate.test.DatabaseSpecificTestCase;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.hibernate.LockMode;
-import org.hibernate.HibernateException;
-import org.hibernate.Query;
-import org.hibernate.Hibernate;
-
import java.io.Serializable;
+import java.sql.SQLException;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
-import java.sql.SQLException;
+import org.hibernate.HibernateException;
+import org.hibernate.LockMode;
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.junit.functional.DatabaseSpecificFunctionalTestCase;
+
/**
* @author Steve Ebersole
*/
-public abstract class HandSQLTest extends DatabaseSpecificTestCase {
+public abstract class HandSQLTest extends DatabaseSpecificFunctionalTestCase {
public HandSQLTest(String name) {
super( name );
@@ -35,7 +34,7 @@
Person gavin = new Person( "Gavin" );
Employment emp = new Employment( gavin, jboss, "AU" );
Serializable orgId = s.save( jboss );
- Serializable orgId2 = s.save( ifa );
+ s.save( ifa );
s.save( gavin );
s.save( emp );
t.commit();
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/MSSQLTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/MSSQLTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/MSSQLTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -2,10 +2,10 @@
package org.hibernate.test.sql;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.SybaseDialect;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
@@ -16,12 +16,12 @@
super( str );
}
- public static Test suite() {
- return new TestSuite( MSSQLTest.class );
+ public String[] getMappings() {
+ return new String[] {"sql/MSSQLEmployment.hbm.xml"};
}
- protected String[] getMappings() {
- return new String[] {"sql/MSSQLEmployment.hbm.xml"};
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( MSSQLTest.class );
}
public boolean appliesTo(Dialect dialect) {
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/MySQLTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/MySQLTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/MySQLTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -2,10 +2,10 @@
package org.hibernate.test.sql;
import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.MySQLDialect;
-import org.hibernate.dialect.Dialect;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
@@ -16,12 +16,12 @@
super(str);
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "sql/MySQLEmployment.hbm.xml" };
}
public static Test suite() {
- return new TestSuite(MySQLTest.class);
+ return new FunctionalTestClassTestSuite( MySQLTest.class );
}
public boolean appliesTo(Dialect dialect) {
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/OracleSQLTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/OracleSQLTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/OracleSQLTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -2,45 +2,27 @@
package org.hibernate.test.sql;
import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.dialect.DataDirectOracle9Dialect;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.Oracle9Dialect;
-import org.hibernate.dialect.DataDirectOracle9Dialect;
-import org.hibernate.HibernateException;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
-import java.sql.SQLException;
-
/**
* @author Gavin King
*/
public class OracleSQLTest extends HandSQLTest {
- public void testHandSQL() {
- super.testHandSQL();
- }
- public void testScalarStoredProcedure() throws HibernateException, SQLException {
- super.testScalarStoredProcedure();
- }
-
- public void testParameterHandling() throws HibernateException, SQLException {
- super.testParameterHandling();
- }
-
- public void testEntityStoredProcedure() throws HibernateException, SQLException {
- super.testEntityStoredProcedure();
- }
-
public OracleSQLTest(String str) {
super(str);
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "sql/OracleEmployment.hbm.xml", "sql/OracleDriverStoredProcedures.hbm.xml" };
}
public static Test suite() {
- return new TestSuite(OracleSQLTest.class);
+ return new FunctionalTestClassTestSuite( OracleSQLTest.class );
}
public boolean appliesTo(Dialect dialect) {
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/check/OracleCheckStyleTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/check/OracleCheckStyleTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/check/OracleCheckStyleTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,9 +1,10 @@
package org.hibernate.test.sql.check;
+import junit.framework.Test;
+
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.Oracle9Dialect;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* todo: describe OracleCheckStyleTest
@@ -15,7 +16,7 @@
super( name );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "sql/check/oracle-mappings.hbm.xml" };
}
@@ -24,6 +25,7 @@
}
public static Test suite() {
- return new TestSuite( OracleCheckStyleTest.class );
+ return new FunctionalTestClassTestSuite( OracleCheckStyleTest.class );
}
+
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/check/ResultCheckStyleTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/check/ResultCheckStyleTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/check/ResultCheckStyleTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,17 +1,16 @@
package org.hibernate.test.sql.check;
-import org.hibernate.test.DatabaseSpecificTestCase;
-import org.hibernate.Session;
-import org.hibernate.JDBCException;
import org.hibernate.HibernateException;
-import org.hibernate.dialect.Dialect;
+import org.hibernate.JDBCException;
+import org.hibernate.Session;
+import org.hibernate.junit.functional.DatabaseSpecificFunctionalTestCase;
/**
* todo: describe ResultCheckStyleTest
*
* @author Steve Ebersole
*/
-public abstract class ResultCheckStyleTest extends DatabaseSpecificTestCase {
+public abstract class ResultCheckStyleTest extends DatabaseSpecificFunctionalTestCase {
public ResultCheckStyleTest(String name) {
super( name );
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/stateless/StatelessSessionTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/stateless/StatelessSessionTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/stateless/StatelessSessionTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -4,23 +4,31 @@
import java.util.Date;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.ScrollMode;
import org.hibernate.ScrollableResults;
import org.hibernate.StatelessSession;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class StatelessSessionTest extends TestCase {
+public class StatelessSessionTest extends FunctionalTestCase {
public StatelessSessionTest(String str) {
super(str);
}
+ public String[] getMappings() {
+ return new String[] { "stateless/Document.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( StatelessSessionTest.class );
+ }
+
public void testCreateUpdateReadDelete() {
StatelessSession ss = getSessions().openStatelessSession();
Transaction tx = ss.beginTransaction();
@@ -155,15 +163,6 @@
tx.commit();
ss.close();
}
-
-
- protected String[] getMappings() {
- return new String[] { "stateless/Document.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(StatelessSessionTest.class);
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/stats/SessionStatsTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/stats/SessionStatsTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/stats/SessionStatsTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -4,18 +4,32 @@
import java.util.HashSet;
import junit.framework.Test;
-import junit.framework.TestSuite;
+
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.stat.SessionStatistics;
import org.hibernate.stat.Statistics;
-import org.hibernate.test.TestCase;
/**
* @author Emmanuel Bernard
*/
-public class SessionStatsTest extends TestCase {
+public class SessionStatsTest extends FunctionalTestCase {
+
+ public SessionStatsTest(String x) {
+ super(x);
+ }
+
+ public String[] getMappings() {
+ return new String[] { "stats/Continent2.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( SessionStatsTest.class );
+ }
+
public void testSessionStatistics() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@@ -58,17 +72,4 @@
return europe;
}
- protected String[] getMappings() {
- return new String[] {
- "stats/Continent2.hbm.xml"
- };
- }
-
- public SessionStatsTest(String x) {
- super(x);
- }
-
- public static Test suite() {
- return new TestSuite(SessionStatsTest.class);
- }
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/stats/StatsTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/stats/StatsTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/stats/StatsTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -5,26 +5,45 @@
import java.util.Iterator;
import junit.framework.Test;
-import junit.framework.TestSuite;
+
import org.hibernate.FetchMode;
+import org.hibernate.Hibernate;
+import org.hibernate.ScrollableResults;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
-import org.hibernate.Hibernate;
-import org.hibernate.ScrollableResults;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.mapping.Collection;
+import org.hibernate.stat.QueryStatistics;
import org.hibernate.stat.Statistics;
-import org.hibernate.stat.QueryStatistics;
-import org.hibernate.test.TestCase;
/**
* Show the difference between fetch and load
*
* @author Emmanuel Bernard
*/
-public class StatsTest extends TestCase {
+public class StatsTest extends FunctionalTestCase {
+
+ public StatsTest(String x) {
+ super(x);
+ }
+
+ public String[] getMappings() {
+ return new String[] { "stats/Continent.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ super.configure( cfg );
+ cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( StatsTest.class );
+ }
+
public void testCollectionFetchVsLoad() throws Exception {
Statistics stats = getSessions().getStatistics();
stats.clear();
@@ -210,20 +229,4 @@
s.createQuery( "delete Continent" ).executeUpdate();
}
- protected void configure(Configuration cfg) {
- super.configure( cfg );
- cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
- }
-
- protected String[] getMappings() {
- return new String[] { "stats/Continent.hbm.xml" };
- }
-
- public StatsTest(String x) {
- super(x);
- }
-
- public static Test suite() {
- return new TestSuite(StatsTest.class);
- }
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/subclassfilter/DiscrimSubclassFilterTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/subclassfilter/DiscrimSubclassFilterTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/subclassfilter/DiscrimSubclassFilterTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,33 +1,37 @@
// $Id$
package org.hibernate.test.subclassfilter;
-import org.hibernate.test.TestCase;
-import org.hibernate.classic.Session;
-import org.hibernate.Transaction;
-
-import java.util.List;
-import java.util.Iterator;
import java.util.ArrayList;
import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.Transaction;
+import org.hibernate.classic.Session;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+
/**
* Implementation of DiscrimSubclassFilterTest.
*
* @author Steve Ebersole
*/
-public class DiscrimSubclassFilterTest extends TestCase {
+public class DiscrimSubclassFilterTest extends FunctionalTestCase {
public DiscrimSubclassFilterTest(String name) {
super( name );
}
- protected final String[] getMappings() {
+ public final String[] getMappings() {
return new String[] { "subclassfilter/discrim-subclass.hbm.xml" };
}
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( DiscrimSubclassFilterTest.class );
+ }
+
public void testFiltersWithSubclass() {
Session s = openSession();
s.enableFilter( "region" ).setParameter( "userRegion", "US" );
@@ -125,7 +129,4 @@
s.flush();
}
- public static Test suite() {
- return new TestSuite(DiscrimSubclassFilterTest.class);
- }
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/subclassfilter/JoinedSubclassFilterTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/subclassfilter/JoinedSubclassFilterTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/subclassfilter/JoinedSubclassFilterTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -7,27 +7,31 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Transaction;
import org.hibernate.classic.Session;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* Implementation of JoinedSubclassFilterTest.
*
* @author Steve Ebersole
*/
-public class JoinedSubclassFilterTest extends TestCase {
+public class JoinedSubclassFilterTest extends FunctionalTestCase {
public JoinedSubclassFilterTest(String name) {
super( name );
}
- protected final String[] getMappings() {
+ public final String[] getMappings() {
return new String[] { "subclassfilter/joined-subclass.hbm.xml" };
}
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( JoinedSubclassFilterTest.class );
+ }
+
public void testFiltersWithJoinedSubclass() {
Session s = openSession();
s.enableFilter( "region" ).setParameter( "userRegion", "US" );
@@ -48,7 +52,7 @@
final Person p = ( Person ) itr.next();
if ( p.getName().equals( "John Doe" ) ) {
Employee john = ( Employee ) p;
- assertEquals( "Incorrect fetched minions count", 2, john.getMinions().size() );
+ assertEquals( "Incorrect fecthed minions count", 2, john.getMinions().size() );
break;
}
}
@@ -66,7 +70,7 @@
final Person p = ( Person ) itr.next();
if ( p.getName().equals( "John Doe" ) ) {
Employee john = ( Employee ) p;
- assertEquals( "Incorrect fetched minions count", 2, john.getMinions().size() );
+ assertEquals( "Incorrect fecthed minions count", 2, john.getMinions().size() );
break;
}
}
@@ -80,7 +84,7 @@
final Person p = ( Person ) itr.next();
if ( p.getName().equals( "John Doe" ) ) {
Employee john = ( Employee ) p;
- assertEquals( "Incorrect fetched minions count", 2, john.getMinions().size() );
+ assertEquals( "Incorrect fecthed minions count", 2, john.getMinions().size() );
break;
}
}
@@ -136,7 +140,4 @@
s.flush();
}
- public static Test suite() {
- return new TestSuite(JoinedSubclassFilterTest.class);
- }
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/subclassfilter/UnionSubclassFilterTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/subclassfilter/UnionSubclassFilterTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/subclassfilter/UnionSubclassFilterTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,33 +1,37 @@
// $Id$
package org.hibernate.test.subclassfilter;
-import org.hibernate.test.TestCase;
-import org.hibernate.classic.Session;
-import org.hibernate.Transaction;
-
-import java.util.List;
-import java.util.Iterator;
import java.util.ArrayList;
import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.Transaction;
+import org.hibernate.classic.Session;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+
/**
* Implementation of DiscrimSubclassFilterTest.
*
* @author Steve Ebersole
*/
-public class UnionSubclassFilterTest extends TestCase {
+public class UnionSubclassFilterTest extends FunctionalTestCase {
public UnionSubclassFilterTest(String name) {
super( name );
}
- protected final String[] getMappings() {
+ public final String[] getMappings() {
return new String[] { "subclassfilter/union-subclass.hbm.xml" };
}
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( UnionSubclassFilterTest.class );
+ }
+
public void testFiltersWithUnionSubclass() {
Session s = openSession();
s.enableFilter( "region" ).setParameter( "userRegion", "US" );
@@ -73,26 +77,26 @@
break;
}
}
-
+
t.commit();
s.close();
-
+
s = openSession();
t = s.beginTransaction();
- s.delete("from Person");
+ s.delete( "from Person" );
t.commit();
s.close();
-
+
}
private void prepareTestData(Session s) {
- Employee john = new Employee("John Doe");
+ Employee john = new Employee( "John Doe" );
john.setCompany( "JBoss" );
john.setDepartment( "hr" );
john.setTitle( "hr guru" );
john.setRegion( "US" );
- Employee polli = new Employee("Polli Wog");
+ Employee polli = new Employee( "Polli Wog" );
polli.setCompany( "JBoss" );
polli.setDepartment( "hr" );
polli.setTitle( "hr novice" );
@@ -123,8 +127,4 @@
s.flush();
}
-
- public static Test suite() {
- return new TestSuite(UnionSubclassFilterTest.class);
- }
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/subselect/SubselectTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/subselect/SubselectTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/subselect/SubselectTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -5,20 +5,28 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class SubselectTest extends TestCase {
+public class SubselectTest extends FunctionalTestCase {
public SubselectTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "subselect/Beings.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( SubselectTest.class );
+ }
public void testEntitySubselect() {
Session s = openSession();
@@ -60,14 +68,5 @@
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "subselect/Beings.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(SubselectTest.class);
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/subselectfetch/SubselectFetchTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/subselectfetch/SubselectFetchTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/subselectfetch/SubselectFetchTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -4,7 +4,6 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.FetchMode;
import org.hibernate.Hibernate;
@@ -14,20 +13,33 @@
import org.hibernate.cfg.Environment;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Property;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class SubselectFetchTest extends TestCase {
+public class SubselectFetchTest extends FunctionalTestCase {
- protected void configure(Configuration cfg) {
+ public SubselectFetchTest(String str) {
+ super(str);
+ }
+
+ public String[] getMappings() {
+ return new String[] { "subselectfetch/ParentChild.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
}
- public SubselectFetchTest(String str) {
- super(str);
+ public String getCacheConcurrencyStrategy() {
+ return null;
}
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( SubselectFetchTest.class );
+ }
public void testSubselectFetchHql() {
Session s = openSession();
@@ -367,18 +379,6 @@
t.commit();
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "subselectfetch/ParentChild.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(SubselectFetchTest.class);
- }
-
- public String getCacheConcurrencyStrategy() {
- return null;
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ternary/TernaryTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ternary/TernaryTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/ternary/TernaryTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,29 +1,41 @@
//$Id$
package org.hibernate.test.ternary;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.HashMap;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class TernaryTest extends TestCase {
+public class TernaryTest extends FunctionalTestCase {
public TernaryTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "ternary/Ternary.hbm.xml" };
+ }
+
+ public String getCacheConcurrencyStrategy() {
+ return null;
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( TernaryTest.class );
+ }
public void testTernary() {
Session s = openSession();
@@ -99,18 +111,6 @@
t.commit();
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "ternary/Ternary.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(TernaryTest.class);
- }
-
- public String getCacheConcurrencyStrategy() {
- return null;
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/timestamp/TimestampTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/timestamp/TimestampTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/timestamp/TimestampTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -4,22 +4,34 @@
import java.util.Date;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class TimestampTest extends TestCase {
+public class TimestampTest extends FunctionalTestCase {
public TimestampTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "timestamp/User.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( TimestampTest.class );
+ }
public void testUpdateFalse() {
@@ -74,19 +86,6 @@
t.commit();
s.close();
}
-
-
- protected String[] getMappings() {
- return new String[] { "timestamp/User.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(TimestampTest.class);
- }
-
- protected void configure(Configuration cfg) {
- cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/tm/CMTTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/tm/CMTTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/tm/CMTTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -2,90 +2,113 @@
package org.hibernate.test.tm;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Iterator;
-
import javax.transaction.Transaction;
import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.ConnectionReleaseMode;
import org.hibernate.EntityMode;
+import org.hibernate.ScrollableResults;
import org.hibernate.Session;
-import org.hibernate.ScrollableResults;
-import org.hibernate.ConnectionReleaseMode;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
+import org.hibernate.criterion.Order;
import org.hibernate.dialect.SybaseDialect;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.transaction.CMTTransactionFactory;
import org.hibernate.util.SerializationHelper;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.cfg.Environment;
-import org.hibernate.criterion.Order;
-import org.hibernate.test.TestCase;
/**
* @author Gavin King
*/
-public class CMTTest extends TestCase {
-
+public class CMTTest extends FunctionalTestCase {
+
public CMTTest(String str) {
- super(str);
+ super( str );
}
-
+
+ public String[] getMappings() {
+ return new String[] { "tm/Item.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty( Environment.CONNECTION_PROVIDER, DummyConnectionProvider.class.getName() );
+ cfg.setProperty( Environment.TRANSACTION_MANAGER_STRATEGY, DummyTransactionManagerLookup.class.getName() );
+ cfg.setProperty( Environment.TRANSACTION_STRATEGY, CMTTransactionFactory.class.getName() );
+ cfg.setProperty( Environment.AUTO_CLOSE_SESSION, "true" );
+ cfg.setProperty( Environment.FLUSH_BEFORE_COMPLETION, "true" );
+ cfg.setProperty( Environment.RELEASE_CONNECTIONS, ConnectionReleaseMode.AFTER_STATEMENT.toString() );
+ cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
+ cfg.setProperty( Environment.USE_QUERY_CACHE, "true" );
+ cfg.setProperty( Environment.DEFAULT_ENTITY_MODE, EntityMode.MAP.toString() );
+ }
+
+ public String getCacheConcurrencyStrategy() {
+ return "transactional";
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( CMTTest.class );
+ }
+
public void testConcurrent() throws Exception {
getSessions().getStatistics().clear();
-
+
DummyTransactionManager.INSTANCE.begin();
Session s = openSession();
Map foo = new HashMap();
- foo.put("name", "Foo");
- foo.put("description", "a big foo");
- s.persist("Item", foo);
+ foo.put( "name", "Foo" );
+ foo.put( "description", "a big foo" );
+ s.persist( "Item", foo );
Map bar = new HashMap();
- bar.put("name", "Bar");
- bar.put("description", "a small bar");
- s.persist("Item", bar);
+ bar.put( "name", "Bar" );
+ bar.put( "description", "a small bar" );
+ s.persist( "Item", bar );
DummyTransactionManager.INSTANCE.commit();
-
- getSessions().evictEntity("Item");
-
+
+ getSessions().evictEntity( "Item" );
+
DummyTransactionManager.INSTANCE.begin();
Session s1 = openSession();
- foo = (Map) s1.get("Item", "Foo");
+ foo = ( Map ) s1.get( "Item", "Foo" );
//foo.put("description", "a big red foo");
//s1.flush();
Transaction tx1 = DummyTransactionManager.INSTANCE.suspend();
-
+
DummyTransactionManager.INSTANCE.begin();
Session s2 = openSession();
- foo = (Map) s2.get("Item", "Foo");
+ foo = ( Map ) s2.get( "Item", "Foo" );
DummyTransactionManager.INSTANCE.commit();
-
- DummyTransactionManager.INSTANCE.resume(tx1);
+
+ DummyTransactionManager.INSTANCE.resume( tx1 );
tx1.commit();
-
- getSessions().evictEntity("Item");
+ getSessions().evictEntity( "Item" );
+
DummyTransactionManager.INSTANCE.begin();
s1 = openSession();
- s1.createCriteria("Item").list();
+ s1.createCriteria( "Item" ).list();
//foo.put("description", "a big red foo");
//s1.flush();
tx1 = DummyTransactionManager.INSTANCE.suspend();
-
+
DummyTransactionManager.INSTANCE.begin();
s2 = openSession();
- s2.createCriteria("Item").list();
+ s2.createCriteria( "Item" ).list();
DummyTransactionManager.INSTANCE.commit();
-
- DummyTransactionManager.INSTANCE.resume(tx1);
+
+ DummyTransactionManager.INSTANCE.resume( tx1 );
tx1.commit();
-
+
DummyTransactionManager.INSTANCE.begin();
s2 = openSession();
- s2.createCriteria("Item").list();
+ s2.createCriteria( "Item" ).list();
DummyTransactionManager.INSTANCE.commit();
-
+
assertEquals( getSessions().getStatistics().getEntityLoadCount(), 7 );
assertEquals( getSessions().getStatistics().getEntityFetchCount(), 0 );
assertEquals( getSessions().getStatistics().getQueryExecutionCount(), 3 );
@@ -94,48 +117,50 @@
DummyTransactionManager.INSTANCE.begin();
s = openSession();
- s.createQuery("delete from Item").executeUpdate();
+ s.createQuery( "delete from Item" ).executeUpdate();
DummyTransactionManager.INSTANCE.commit();
}
-
+
public void testConcurrentCachedQueries() throws Exception {
-
+
DummyTransactionManager.INSTANCE.begin();
Session s = openSession();
Map foo = new HashMap();
- foo.put("name", "Foo");
- foo.put("description", "a big foo");
- s.persist("Item", foo);
+ foo.put( "name", "Foo" );
+ foo.put( "description", "a big foo" );
+ s.persist( "Item", foo );
Map bar = new HashMap();
- bar.put("name", "Bar");
- bar.put("description", "a small bar");
- s.persist("Item", bar);
+ bar.put( "name", "Bar" );
+ bar.put( "description", "a small bar" );
+ s.persist( "Item", bar );
DummyTransactionManager.INSTANCE.commit();
-
- synchronized (this) { wait(1000); }
+ synchronized ( this ) {
+ wait( 1000 );
+ }
+
getSessions().getStatistics().clear();
-
- getSessions().evictEntity("Item");
+ getSessions().evictEntity( "Item" );
+
DummyTransactionManager.INSTANCE.begin();
Session s4 = openSession();
Transaction tx4 = DummyTransactionManager.INSTANCE.suspend();
DummyTransactionManager.INSTANCE.begin();
Session s1 = openSession();
- List r1 = s1.createCriteria("Item").addOrder( Order.asc("description") )
- .setCacheable(true).list();
+ List r1 = s1.createCriteria( "Item" ).addOrder( Order.asc( "description" ) )
+ .setCacheable( true ).list();
assertEquals( r1.size(), 2 );
Transaction tx1 = DummyTransactionManager.INSTANCE.suspend();
DummyTransactionManager.INSTANCE.begin();
Session s2 = openSession();
- List r2 = s2.createCriteria("Item").addOrder( Order.asc("description") )
- .setCacheable(true).list();
+ List r2 = s2.createCriteria( "Item" ).addOrder( Order.asc( "description" ) )
+ .setCacheable( true ).list();
assertEquals( r2.size(), 2 );
DummyTransactionManager.INSTANCE.commit();
-
+
assertEquals( getSessions().getStatistics().getSecondLevelCacheHitCount(), 2 );
assertEquals( getSessions().getStatistics().getSecondLevelCacheMissCount(), 0 );
assertEquals( getSessions().getStatistics().getEntityLoadCount(), 2 );
@@ -144,16 +169,16 @@
assertEquals( getSessions().getStatistics().getQueryCachePutCount(), 1 );
assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 1 );
assertEquals( getSessions().getStatistics().getQueryCacheMissCount(), 1 );
-
- DummyTransactionManager.INSTANCE.resume(tx1);
+
+ DummyTransactionManager.INSTANCE.resume( tx1 );
tx1.commit();
-
+
DummyTransactionManager.INSTANCE.begin();
Session s3 = openSession();
- s3.createCriteria("Item").addOrder( Order.asc("description") )
- .setCacheable(true).list();
+ s3.createCriteria( "Item" ).addOrder( Order.asc( "description" ) )
+ .setCacheable( true ).list();
DummyTransactionManager.INSTANCE.commit();
-
+
assertEquals( getSessions().getStatistics().getSecondLevelCacheHitCount(), 4 );
assertEquals( getSessions().getStatistics().getSecondLevelCacheMissCount(), 0 );
assertEquals( getSessions().getStatistics().getEntityLoadCount(), 2 );
@@ -162,13 +187,13 @@
assertEquals( getSessions().getStatistics().getQueryCachePutCount(), 1 );
assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 2 );
assertEquals( getSessions().getStatistics().getQueryCacheMissCount(), 1 );
-
- DummyTransactionManager.INSTANCE.resume(tx4);
- List r4 = s4.createCriteria("Item").addOrder( Order.asc("description") )
- .setCacheable(true).list();
+
+ DummyTransactionManager.INSTANCE.resume( tx4 );
+ List r4 = s4.createCriteria( "Item" ).addOrder( Order.asc( "description" ) )
+ .setCacheable( true ).list();
assertEquals( r4.size(), 2 );
tx4.commit();
-
+
assertEquals( getSessions().getStatistics().getSecondLevelCacheHitCount(), 6 );
assertEquals( getSessions().getStatistics().getSecondLevelCacheMissCount(), 0 );
assertEquals( getSessions().getStatistics().getEntityLoadCount(), 2 );
@@ -177,15 +202,16 @@
assertEquals( getSessions().getStatistics().getQueryCachePutCount(), 1 );
assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 3 );
assertEquals( getSessions().getStatistics().getQueryCacheMissCount(), 1 );
-
+
DummyTransactionManager.INSTANCE.begin();
s = openSession();
- s.createQuery("delete from Item").executeUpdate();
+ s.createQuery( "delete from Item" ).executeUpdate();
DummyTransactionManager.INSTANCE.commit();
}
-
+
public void testConcurrentCachedDirtyQueries() throws Exception {
if ( getDialect() instanceof SybaseDialect ) {
+ // sybase and sqlserver have serious locking issues here...
reportSkip( "dead-lock bug", "concurrent queries" );
return;
}
@@ -193,42 +219,44 @@
DummyTransactionManager.INSTANCE.begin();
Session s = openSession();
Map foo = new HashMap();
- foo.put("name", "Foo");
- foo.put("description", "a big foo");
- s.persist("Item", foo);
+ foo.put( "name", "Foo" );
+ foo.put( "description", "a big foo" );
+ s.persist( "Item", foo );
Map bar = new HashMap();
- bar.put("name", "Bar");
- bar.put("description", "a small bar");
- s.persist("Item", bar);
+ bar.put( "name", "Bar" );
+ bar.put( "description", "a small bar" );
+ s.persist( "Item", bar );
DummyTransactionManager.INSTANCE.commit();
-
- synchronized (this) { wait(1000); }
+ synchronized ( this ) {
+ wait( 1000 );
+ }
+
getSessions().getStatistics().clear();
-
- getSessions().evictEntity("Item");
+ getSessions().evictEntity( "Item" );
+
DummyTransactionManager.INSTANCE.begin();
Session s4 = openSession();
Transaction tx4 = DummyTransactionManager.INSTANCE.suspend();
DummyTransactionManager.INSTANCE.begin();
Session s1 = openSession();
- List r1 = s1.createCriteria("Item").addOrder( Order.asc("description") )
- .setCacheable(true).list();
+ List r1 = s1.createCriteria( "Item" ).addOrder( Order.asc( "description" ) )
+ .setCacheable( true ).list();
assertEquals( r1.size(), 2 );
- foo = (Map) r1.get(0);
- foo.put("description", "a big red foo");
+ foo = ( Map ) r1.get( 0 );
+ foo.put( "description", "a big red foo" );
s1.flush();
Transaction tx1 = DummyTransactionManager.INSTANCE.suspend();
DummyTransactionManager.INSTANCE.begin();
Session s2 = openSession();
- List r2 = s2.createCriteria("Item").addOrder( Order.asc("description") )
- .setCacheable(true).list();
+ List r2 = s2.createCriteria( "Item" ).addOrder( Order.asc( "description" ) )
+ .setCacheable( true ).list();
assertEquals( r2.size(), 2 );
DummyTransactionManager.INSTANCE.commit();
-
+
assertEquals( getSessions().getStatistics().getSecondLevelCacheHitCount(), 0 );
assertEquals( getSessions().getStatistics().getSecondLevelCacheMissCount(), 0 );
assertEquals( getSessions().getStatistics().getEntityLoadCount(), 4 );
@@ -237,16 +265,16 @@
assertEquals( getSessions().getStatistics().getQueryCachePutCount(), 2 );
assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 0 );
assertEquals( getSessions().getStatistics().getQueryCacheMissCount(), 2 );
-
- DummyTransactionManager.INSTANCE.resume(tx1);
+
+ DummyTransactionManager.INSTANCE.resume( tx1 );
tx1.commit();
-
+
DummyTransactionManager.INSTANCE.begin();
Session s3 = openSession();
- s3.createCriteria("Item").addOrder( Order.asc("description") )
- .setCacheable(true).list();
+ s3.createCriteria( "Item" ).addOrder( Order.asc( "description" ) )
+ .setCacheable( true ).list();
DummyTransactionManager.INSTANCE.commit();
-
+
assertEquals( getSessions().getStatistics().getSecondLevelCacheHitCount(), 0 );
assertEquals( getSessions().getStatistics().getSecondLevelCacheMissCount(), 0 );
assertEquals( getSessions().getStatistics().getEntityLoadCount(), 6 );
@@ -255,13 +283,13 @@
assertEquals( getSessions().getStatistics().getQueryCachePutCount(), 3 );
assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 0 );
assertEquals( getSessions().getStatistics().getQueryCacheMissCount(), 3 );
-
- DummyTransactionManager.INSTANCE.resume(tx4);
- List r4 = s4.createCriteria("Item").addOrder( Order.asc("description") )
- .setCacheable(true).list();
+
+ DummyTransactionManager.INSTANCE.resume( tx4 );
+ List r4 = s4.createCriteria( "Item" ).addOrder( Order.asc( "description" ) )
+ .setCacheable( true ).list();
assertEquals( r4.size(), 2 );
tx4.commit();
-
+
assertEquals( getSessions().getStatistics().getSecondLevelCacheHitCount(), 2 );
assertEquals( getSessions().getStatistics().getSecondLevelCacheMissCount(), 0 );
assertEquals( getSessions().getStatistics().getEntityLoadCount(), 6 );
@@ -270,13 +298,13 @@
assertEquals( getSessions().getStatistics().getQueryCachePutCount(), 3 );
assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 1 );
assertEquals( getSessions().getStatistics().getQueryCacheMissCount(), 3 );
-
+
DummyTransactionManager.INSTANCE.begin();
s = openSession();
- s.createQuery("delete from Item").executeUpdate();
+ s.createQuery( "delete from Item" ).executeUpdate();
DummyTransactionManager.INSTANCE.commit();
}
-
+
public void testCMT() throws Exception {
getSessions().getStatistics().clear();
@@ -295,17 +323,17 @@
DummyTransactionManager.INSTANCE.begin();
s = openSession();
Map item = new HashMap();
- item.put("name", "The Item");
- item.put("description", "The only item we have");
- s.persist("Item", item);
+ item.put( "name", "The Item" );
+ item.put( "description", "The only item we have" );
+ s.persist( "Item", item );
DummyTransactionManager.INSTANCE.getTransaction().commit();
assertFalse( s.isOpen() );
DummyTransactionManager.INSTANCE.begin();
s = openSession();
- item = (Map) s.createQuery("from Item").uniqueResult();
- assertNotNull(item);
- s.delete(item);
+ item = ( Map ) s.createQuery( "from Item" ).uniqueResult();
+ assertNotNull( item );
+ s.delete( item );
DummyTransactionManager.INSTANCE.getTransaction().commit();
assertFalse( s.isOpen() );
@@ -320,9 +348,9 @@
DummyTransactionManager.INSTANCE.begin();
s = openSession();
- s.createQuery("delete from Item").executeUpdate();
+ s.createQuery( "delete from Item" ).executeUpdate();
DummyTransactionManager.INSTANCE.commit();
-
+
}
public void testCurrentSession() throws Exception {
@@ -416,7 +444,7 @@
DummyTransactionManager.INSTANCE.begin();
s = getSessions().getCurrentSession();
results = s.createQuery( "from Item" ).scroll();
- while( !results.isLast() ) {
+ while ( !results.isLast() ) {
results.next();
}
DummyTransactionManager.INSTANCE.getTransaction().commit();
@@ -425,7 +453,7 @@
DummyTransactionManager.INSTANCE.begin();
s = getSessions().getCurrentSession();
results = s.createQuery( "from Item" ).scroll();
- while( !results.isLast() ) {
+ while ( !results.isLast() ) {
results.next();
}
results.close();
@@ -482,28 +510,5 @@
}
}
- protected String[] getMappings() {
- return new String[] { "tm/Item.hbm.xml" };
- }
-
- public String getCacheConcurrencyStrategy() {
- return "transactional";
- }
-
- public static Test suite() {
- return new TestSuite(CMTTest.class);
- }
-
- protected void configure(Configuration cfg) {
- cfg.setProperty( Environment.CONNECTION_PROVIDER, DummyConnectionProvider.class.getName() );
- cfg.setProperty( Environment.TRANSACTION_MANAGER_STRATEGY, DummyTransactionManagerLookup.class.getName() );
- cfg.setProperty( Environment.TRANSACTION_STRATEGY, CMTTransactionFactory.class.getName() );
- cfg.setProperty( Environment.AUTO_CLOSE_SESSION, "true" );
- cfg.setProperty( Environment.FLUSH_BEFORE_COMPLETION, "true" );
- cfg.setProperty( Environment.RELEASE_CONNECTIONS, ConnectionReleaseMode.AFTER_STATEMENT.toString() );
- cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
- cfg.setProperty( Environment.USE_QUERY_CACHE, "true" );
- cfg.setProperty( Environment.DEFAULT_ENTITY_MODE, EntityMode.MAP.toString() );
- }
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/tool/TestSchemaTools.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/tool/TestSchemaTools.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/tool/TestSchemaTools.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -2,14 +2,16 @@
import java.sql.Connection;
import java.sql.Statement;
+import java.sql.SQLException;
import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
import org.hibernate.HibernateException;
import org.hibernate.Session;
-import org.hibernate.test.TestCase;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.dialect.HSQLDialect;
+import org.hibernate.junit.functional.DatabaseSpecificFunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.tool.hbm2ddl.SchemaExport;
import org.hibernate.tool.hbm2ddl.SchemaUpdate;
import org.hibernate.tool.hbm2ddl.SchemaValidator;
@@ -25,7 +27,50 @@
* This schema should not be the same at the default db user schema and should come after the users schema alphabetically.
*
*/
-public class TestSchemaTools extends TestCase{
+public class TestSchemaTools extends DatabaseSpecificFunctionalTestCase {
+
+ public TestSchemaTools(String name) {
+ super( name );
+ }
+
+ public String[] getMappings() {
+ return new String[] { "tool/Team.hbm.xml" };
+ }
+
+ public boolean createSchema() {
+ return false;
+ }
+
+
+ public void afterSessionFactoryBuilt() {
+ super.afterSessionFactoryBuilt();
+ try {
+ Session session = openSession();
+ Connection conn = session.connection();
+ Statement stat = conn.createStatement();
+ stat.execute("CREATE SCHEMA sb AUTHORIZATION DBA ");
+ stat.execute(" CREATE SCHEMA sa AUTHORIZATION DBA ");
+ stat.execute(" CREATE TABLE \"SA\".\"Team\" (test INTEGER) ");
+ stat.close();
+ conn.close();
+ }
+ catch ( SQLException e ) {
+ throw new RuntimeException( "could not prepare additional schemas" );
+ }
+ }
+
+ protected void prepareTest() throws Exception {
+ super.prepareTest();
+ }
+
+
+ public boolean appliesTo(Dialect dialect) {
+ return dialect instanceof HSQLDialect;
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( TestSchemaTools.class );
+ }
public void testSchemaTools() throws Exception{
// database schema have been created thanks to the setUp method
@@ -170,40 +215,4 @@
session.close();
}
- public TestSchemaTools(String arg0) {
- super(arg0);
- }
-
- public String[] getMappings() {
- return new String[] {"tool/Team.hbm.xml"};
- }
-
- public static Test suite() {
- return new TestSuite(TestSchemaTools.class);
- }
-
- public static void main(String[] args) throws Exception {
- TestRunner.run( suite() );
- }
-
- protected boolean recreateSchema() {
- return false;
- }
-
-
- protected void setUp() throws Exception {
- super.setUp();
- Session session = openSession();
- Connection conn = session.connection();
- Statement stat = conn.createStatement();
- stat.execute("CREATE SCHEMA sb AUTHORIZATION DBA ");
- stat.execute(" CREATE SCHEMA sa AUTHORIZATION DBA ");
- stat.execute(" CREATE TABLE \"SA\".\"Team\" (test INTEGER) ");
- stat.close();
- conn.close();
-
- }
-
-
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/typedmanytoone/TypedManyToOneTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/typedmanytoone/TypedManyToOneTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/typedmanytoone/TypedManyToOneTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -4,21 +4,29 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class TypedManyToOneTest extends TestCase {
+public class TypedManyToOneTest extends FunctionalTestCase {
public TypedManyToOneTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "typedmanytoone/Customer.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( TypedManyToOneTest.class );
+ }
public void testCreateQuery() {
Customer cust = new Customer();
@@ -98,15 +106,8 @@
s.delete( cust );
t.commit();
s.close();
+
}
-
- protected String[] getMappings() {
- return new String[] { "typedmanytoone/Customer.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(TypedManyToOneTest.class);
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/typedonetoone/TypedOneToOneTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/typedonetoone/TypedOneToOneTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/typedonetoone/TypedOneToOneTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -4,21 +4,29 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class TypedOneToOneTest extends TestCase {
+public class TypedOneToOneTest extends FunctionalTestCase {
public TypedOneToOneTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "typedonetoone/Customer.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( TypedOneToOneTest.class );
+ }
public void testCreateQuery() {
Customer cust = new Customer();
@@ -64,6 +72,7 @@
s.delete( cust );
t.commit();
s.close();
+
}
public void testCreateQueryNull() {
@@ -89,14 +98,6 @@
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "typedonetoone/Customer.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(TypedOneToOneTest.class);
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/typeparameters/TypeParameterTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/typeparameters/TypeParameterTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/typeparameters/TypeParameterTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -5,35 +5,32 @@
import java.sql.PreparedStatement;
import java.sql.ResultSet;
-import org.hibernate.classic.Session;
-import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
-
import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
+import org.hibernate.Transaction;
+import org.hibernate.classic.Session;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+
/**
* Test for parameterizable types.
*
* @author Michael Gloegl
*/
-public class TypeParameterTest extends TestCase {
+public class TypeParameterTest extends FunctionalTestCase {
public TypeParameterTest(String name) {
super(name);
}
- /**
- * @see org.hibernate.test.TestCase#getMappings()
- */
- protected String[] getMappings() {
- return new String[] {
- "typeparameters/Typedef.hbm.xml",
- "typeparameters/Widget.hbm.xml"
- };
+ public String[] getMappings() {
+ return new String[] { "typeparameters/Typedef.hbm.xml", "typeparameters/Widget.hbm.xml" };
}
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( TypeParameterTest.class );
+ }
+
public void testSave() throws Exception {
deleteData();
@@ -122,12 +119,4 @@
t.commit();
s.close();
}
-
- public static Test suite() {
- return new TestSuite(TypeParameterTest.class);
- }
-
- public static void main(String[] args) throws Exception {
- TestRunner.run(suite());
- }
}
\ No newline at end of file
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/unconstrained/UnconstrainedTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/unconstrained/UnconstrainedTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/unconstrained/UnconstrainedTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -2,24 +2,32 @@
package org.hibernate.test.unconstrained;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.FetchMode;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.criterion.Restrictions;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class UnconstrainedTest extends TestCase {
+public class UnconstrainedTest extends FunctionalTestCase {
public UnconstrainedTest(String str) {
super(str);
}
-
+
+ public String[] getMappings() {
+ return new String[] { "unconstrained/Person.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( UnconstrainedTest.class );
+ }
+
public void testUnconstrainedNoCache() {
Session session = openSession();
Transaction tx = session.beginTransaction();
@@ -115,13 +123,5 @@
session.close();
}
- protected String[] getMappings() {
- return new String[] { "unconstrained/Person.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(UnconstrainedTest.class);
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/unidir/BackrefTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/unidir/BackrefTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/unidir/BackrefTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -2,21 +2,33 @@
package org.hibernate.test.unidir;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class BackrefTest extends TestCase {
+public class BackrefTest extends FunctionalTestCase {
public BackrefTest(String str) {
super(str);
}
-
+
+ public String[] getMappings() {
+ return new String[] { "unidir/ParentChild.hbm.xml" };
+ }
+
+ public String getCacheConcurrencyStrategy() {
+ return null;
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( BackrefTest.class );
+ }
+
public void testBackRef() {
Session s = openSession();
Transaction t = s.beginTransaction();
@@ -72,18 +84,5 @@
t.commit();
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "unidir/ParentChild.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(BackrefTest.class);
- }
-
- public String getCacheConcurrencyStrategy() {
- return null;
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/unionsubclass/UnionSubclassTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/unionsubclass/UnionSubclassTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/unionsubclass/UnionSubclassTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -5,24 +5,32 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.FetchMode;
import org.hibernate.Hibernate;
+import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.Query;
import org.hibernate.criterion.Order;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class UnionSubclassTest extends TestCase {
+public class UnionSubclassTest extends FunctionalTestCase {
public UnionSubclassTest(String str) {
super(str);
}
+
+ public String[] getMappings() {
+ return new String[] { "unionsubclass/Beings.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( UnionSubclassTest.class );
+ }
public void testUnionSubclassCollection() {
Session s = openSession();
@@ -389,14 +397,5 @@
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "unionsubclass/Beings.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(UnionSubclassTest.class);
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/unionsubclass2/UnionSubclassTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/unionsubclass2/UnionSubclassTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/unionsubclass2/UnionSubclassTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -6,28 +6,33 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.criterion.Expression;
import org.hibernate.criterion.Property;
-import org.hibernate.dialect.DB2Dialect;
import org.hibernate.dialect.HSQLDialect;
-import org.hibernate.dialect.MySQLDialect;
-import org.hibernate.dialect.PostgreSQLDialect;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class UnionSubclassTest extends TestCase {
+public class UnionSubclassTest extends FunctionalTestCase {
public UnionSubclassTest(String str) {
super(str);
}
-
+
+ public String[] getMappings() {
+ return new String[] { "unionsubclass2/Person.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( UnionSubclassTest.class );
+ }
+
public void testUnionSubclass() {
Session s = openSession();
Transaction t = s.beginTransaction();
@@ -88,7 +93,7 @@
mark.setZip("30306");
assertEquals( s.createQuery("from Person p where p.address.zip = '30306'").list().size(), 1 );
-
+
if ( supportsRowValueConstructorSyntaxInInList() ) {
s.createCriteria(Person.class).add(
Expression.in("address", new Address[] { mark.getAddress(), joe.getAddress() } )
@@ -104,7 +109,9 @@
}
public void testQuerySubclassAttribute() {
- if ( getDialect() instanceof HSQLDialect ) return; //why??
+ if ( getDialect() instanceof HSQLDialect ) {
+ return; // TODO : why??
+ }
Session s = openSession();
Transaction t = s.beginTransaction();
@@ -142,14 +149,5 @@
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "unionsubclass2/Person.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(UnionSubclassTest.class);
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/usercollection/UserCollectionTypeTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/usercollection/UserCollectionTypeTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/usercollection/UserCollectionTypeTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -2,22 +2,30 @@
package org.hibernate.test.usercollection;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Max Rydahl Andersen
*/
-public class UserCollectionTypeTest extends TestCase {
+public class UserCollectionTypeTest extends FunctionalTestCase {
public UserCollectionTypeTest(String str) {
super(str);
}
+ public String[] getMappings() {
+ return new String[] { "usercollection/UserPermissions.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( UserCollectionTypeTest.class );
+ }
+
public void testBasicOperation() {
Session s = openSession();
Transaction t = s.beginTransaction();
@@ -50,15 +58,6 @@
t.commit();
s.close();
}
-
-
- protected String[] getMappings() {
- return new String[] { "usercollection/UserPermissions.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(UserCollectionTypeTest.class);
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/util/PropertiesHelperTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/util/PropertiesHelperTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/util/PropertiesHelperTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,18 +1,17 @@
package org.hibernate.test.util;
-import junit.framework.TestCase;
+import java.util.Properties;
+
import junit.framework.Test;
import junit.framework.TestSuite;
-import java.util.Properties;
-import java.util.Iterator;
-
+import org.hibernate.junit.UnitTestCase;
import org.hibernate.util.PropertiesHelper;
/**
- * @author <a href="mailto:steve@hibernate.org">Steve Ebersole </a>
+ * @author Steve Ebersole
*/
-public class PropertiesHelperTest extends TestCase {
+public class PropertiesHelperTest extends UnitTestCase {
private Properties props;
@@ -20,6 +19,10 @@
super( string );
}
+ public static Test suite() {
+ return new TestSuite( PropertiesHelperTest.class );
+ }
+
protected void setUp() throws Exception {
props = new Properties();
@@ -103,8 +106,4 @@
catch( NumberFormatException expected ) {
}
}
-
- public static Test suite() {
- return new TestSuite( PropertiesHelperTest.class );
- }
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/util/StringHelperTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/util/StringHelperTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/util/StringHelperTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,20 +1,24 @@
package org.hibernate.test.util;
-import junit.framework.TestCase;
import junit.framework.Test;
import junit.framework.TestSuite;
+
+import org.hibernate.junit.UnitTestCase;
import org.hibernate.util.StringHelper;
/**
- * todo: describe StringHelperTest
- *
* @author Steve Ebersole
*/
-public class StringHelperTest extends TestCase {
+public class StringHelperTest extends UnitTestCase {
+
public StringHelperTest(String string) {
super( string );
}
+ public static Test suite() {
+ return new TestSuite( StringHelperTest.class );
+ }
+
public void testAliasGeneration() {
assertSimpleAlias( "xyz", "xyz_" );
assertSimpleAlias( "_xyz", "xyz_" );
@@ -25,8 +29,4 @@
private void assertSimpleAlias(String source, String expected) {
assertEquals( expected, StringHelper.generateAlias( source ) );
}
-
- public static Test suite() {
- return new TestSuite( StringHelperTest.class );
- }
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/util/dtd/EntityResolverTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/util/dtd/EntityResolverTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/util/dtd/EntityResolverTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,28 +1,32 @@
package org.hibernate.test.util.dtd;
-import junit.framework.TestCase;
import junit.framework.Test;
import junit.framework.TestSuite;
+
import org.hibernate.cfg.Configuration;
+import org.hibernate.junit.UnitTestCase;
/**
- * todo: describe EntityResolverTest
- *
* @author Steve Ebersole
*/
-public class EntityResolverTest extends TestCase {
+public class EntityResolverTest extends UnitTestCase {
+
public EntityResolverTest(String name) {
super( name );
}
+ public static Test suite() {
+ return new TestSuite( EntityResolverTest.class );
+ }
+
public void testEntityIncludeResolution() {
+ // Parent.hbm.xml contains the following entity include:
+ // <!ENTITY child SYSTEM "classpath://org/hibernate/test/util/dtd/child.xml">
+ // which we are expecting the Hibernate custom entity resolver to be able to resolve
+ // locally via classpath lookup.
Configuration cfg = new Configuration();
cfg.addResource( "org/hibernate/test/util/dtd/Parent.hbm.xml" );
cfg.buildMappings();
}
-
- public static Test suite() {
- return new TestSuite( EntityResolverTest.class );
- }
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/util/dtd/Parent.hbm.xml
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/util/dtd/Parent.hbm.xml 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/util/dtd/Parent.hbm.xml 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
+<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" [
<!ENTITY child SYSTEM "classpath://org/hibernate/test/util/dtd/child.xml">
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/version/VersionTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/version/VersionTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/version/VersionTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -2,22 +2,30 @@
package org.hibernate.test.version;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Max Rydahl Andersen
*/
-public class VersionTest extends TestCase {
+public class VersionTest extends FunctionalTestCase {
public VersionTest(String str) {
super(str);
}
+ public String[] getMappings() {
+ return new String[] { "version/PersonThing.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( VersionTest.class );
+ }
+
public void testVersionShortCircuitFlush() {
Session s = openSession();
Transaction t = s.beginTransaction();
@@ -122,15 +130,6 @@
t.commit();
s.close();
}
-
-
- protected String[] getMappings() {
- return new String[] { "version/PersonThing.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(VersionTest.class);
- }
-
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/version/db/DbVersionTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/version/db/DbVersionTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/version/db/DbVersionTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -3,36 +3,33 @@
import java.sql.Timestamp;
-import org.hibernate.test.TestCase;
+import junit.framework.Test;
+
+import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.Hibernate;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
/**
* Implementation of DbVersionTest.
*
* @author Steve Ebersole
*/
-public class DbVersionTest extends TestCase {
+public class DbVersionTest extends FunctionalTestCase {
public DbVersionTest(String x) {
super( x );
}
- protected String[] getMappings() {
- return new String[] { "User.hbm.xml" };
+
+ public String[] getMappings() {
+ return new String[] { "version/db/User.hbm.xml" };
}
- /**
- * @return
- */
- protected String getBaseForMappings() {
- return super.getBaseForMappings() + "version/db/";
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( DbVersionTest.class );
}
-
public void testCollectionVersion() throws Exception {
Session s = openSession();
Transaction t = s.beginTransaction();
@@ -47,9 +44,7 @@
// For dialects (Oracle8 for example) which do not return "true
// timestamps" sleep for a bit to allow the db date-time increment...
- //if ( steveTimestamp.getNanos() == 0 ) {
- Thread.sleep( 1500 );
- //}
+ Thread.sleep( 1500 );
s = openSession();
t = s.beginTransaction();
@@ -63,9 +58,7 @@
assertFalse( "owner version not incremented", Hibernate.TIMESTAMP.isEqual( steveTimestamp, steve.getTimestamp() ) );
steveTimestamp = steve.getTimestamp();
- //if ( steveTimestamp.getNanos() == 0 ) {
- Thread.sleep( 1500 );
- //}
+ Thread.sleep( 1500 );
s = openSession();
t = s.beginTransaction();
@@ -123,8 +116,4 @@
t.commit();
s.close();
}
-
- public static Test suite() {
- return new TestSuite(DbVersionTest.class);
- }
}
\ No newline at end of file
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/version/sybase/SybaseTimestampVersioningTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/version/sybase/SybaseTimestampVersioningTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/version/sybase/SybaseTimestampVersioningTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -1,30 +1,29 @@
// $Id$
package org.hibernate.test.version.sybase;
-import org.hibernate.test.TestCase;
-import org.hibernate.test.DatabaseSpecificTestCase;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
+import junit.framework.Test;
+
import org.hibernate.Hibernate;
import org.hibernate.HibernateException;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.SybaseDialect;
+import org.hibernate.junit.functional.DatabaseSpecificFunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
/**
* Implementation of VersionTest.
*
* @author Steve Ebersole
*/
-public class SybaseTimestampVersioningTest extends DatabaseSpecificTestCase {
+public class SybaseTimestampVersioningTest extends DatabaseSpecificFunctionalTestCase {
public SybaseTimestampVersioningTest(String x) {
super( x );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "version/sybase/User.hbm.xml" };
}
@@ -32,6 +31,9 @@
return dialect instanceof SybaseDialect;
}
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( SybaseTimestampVersioningTest.class );
+ }
public void testLocking() throws Throwable {
// First, create the needed row...
@@ -197,8 +199,4 @@
t.commit();
s.close();
}
-
- public static Test suite() {
- return new TestSuite(SybaseTimestampVersioningTest.class);
- }
}
\ No newline at end of file
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/where/WhereTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/where/WhereTest.java 2006-12-12 18:11:47 UTC (rev 10975)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/where/WhereTest.java 2006-12-12 23:22:26 UTC (rev 10976)
@@ -2,17 +2,29 @@
package org.hibernate.test.where;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.FetchMode;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
-import org.hibernate.test.TestCase;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Max Rydahl Andersen
*/
-public class WhereTest extends TestCase {
+public class WhereTest extends FunctionalTestCase {
+
+ public WhereTest(String str) {
+ super(str);
+ }
+
+ public String[] getMappings() {
+ return new String[] { "where/File.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( WhereTest.class );
+ }
public void testWhere() {
Session s = openSession();
@@ -40,18 +52,6 @@
s.getTransaction().commit();
s.close();
}
-
- public WhereTest(String str) {
- super(str);
- }
-
- protected String[] getMappings() {
- return new String[] { "where/File.hbm.xml" };
- }
- public static Test suite() {
- return new TestSuite(WhereTest.class);
- }
-
}
17 years, 11 months
Hibernate SVN: r10975 - branches/Branch_3_2/Hibernate3/src/org/hibernate/dialect
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-12-12 13:11:47 -0500 (Tue, 12 Dec 2006)
New Revision: 10975
Modified:
branches/Branch_3_2/Hibernate3/src/org/hibernate/dialect/Oracle9Dialect.java
Log:
fixed incorrect override
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/dialect/Oracle9Dialect.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/dialect/Oracle9Dialect.java 2006-12-12 18:11:31 UTC (rev 10974)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/dialect/Oracle9Dialect.java 2006-12-12 18:11:47 UTC (rev 10975)
@@ -332,12 +332,4 @@
public boolean supportsEmptyInList() {
return false;
}
-
- public boolean supportsRowValueConstructorSyntax() {
- return true;
- }
-
- public boolean supportsRowValueConstructorSyntaxInInList() {
- return true;
- }
}
17 years, 11 months
Hibernate SVN: r10974 - trunk/Hibernate3/src/org/hibernate/dialect
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-12-12 13:11:31 -0500 (Tue, 12 Dec 2006)
New Revision: 10974
Modified:
trunk/Hibernate3/src/org/hibernate/dialect/Oracle9Dialect.java
Log:
fixed incorrect override
Modified: trunk/Hibernate3/src/org/hibernate/dialect/Oracle9Dialect.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/dialect/Oracle9Dialect.java 2006-12-11 13:19:41 UTC (rev 10973)
+++ trunk/Hibernate3/src/org/hibernate/dialect/Oracle9Dialect.java 2006-12-12 18:11:31 UTC (rev 10974)
@@ -332,12 +332,4 @@
public boolean supportsEmptyInList() {
return false;
}
-
- public boolean supportsRowValueConstructorSyntax() {
- return true;
- }
-
- public boolean supportsRowValueConstructorSyntaxInInList() {
- return true;
- }
}
17 years, 11 months
Hibernate SVN: r10973 - branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics
by hibernate-commits@lists.jboss.org
Author: nusco
Date: 2006-12-11 08:19:41 -0500 (Mon, 11 Dec 2006)
New Revision: 10973
Modified:
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics/ApproximatingTypeEnvironment.java
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics/SimpleTypeEnvironment.java
Log:
Comments
Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics/ApproximatingTypeEnvironment.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics/ApproximatingTypeEnvironment.java 2006-12-11 12:30:20 UTC (rev 10972)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics/ApproximatingTypeEnvironment.java 2006-12-11 13:19:41 UTC (rev 10973)
@@ -27,7 +27,7 @@
* Lower bounds are ignored.<p>
* <p/>
* Wildcards are generally not approximated. <code>Class<?></code> stays <code>Class<?></code>.
- * A wildcard within a generic type is approximated to its upper binding. <code>List<?></code> becomes
+ * A wildcard within a generic collection is approximated to its upper binding. <code>List<?></code> becomes
* <code>List<Object></code><p>
* <p/>
* Note that <code>Class<T></code> is <emp>not</emp> approximated <code>Class<Object></code>.
Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics/SimpleTypeEnvironment.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics/SimpleTypeEnvironment.java 2006-12-11 12:30:20 UTC (rev 10972)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics/SimpleTypeEnvironment.java 2006-12-11 13:19:41 UTC (rev 10973)
@@ -8,6 +8,8 @@
import java.util.HashMap;
/**
+ * Binds formal type arguments (typically T, E, etc.) to actual types.
+ *
* @author Davide Marchignoli
* @author Paolo Perrotta
*/
17 years, 11 months
Hibernate SVN: r10972 - in branches/Branch_3_2/HibernateExt/metadata/src: java/org/hibernate/cfg/annotations java/org/hibernate/reflection/java java/org/hibernate/reflection/java/generics test/org/hibernate/test/annotations/generics test/org/hibernate/test/reflection/java/generics/deep
by hibernate-commits@lists.jboss.org
Author: nusco
Date: 2006-12-11 07:30:20 -0500 (Mon, 11 Dec 2006)
New Revision: 10972
Added:
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/generics/EmbeddedGenericsTest.java
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/DeepGenericsContainment.java
Modified:
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/CollectionBinder.java
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/IdBagBinder.java
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/ListBinder.java
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/MapBinder.java
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaXClass.java
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaXFactory.java
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics/ApproximatingTypeEnvironment.java
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics/CompoundTypeEnvironment.java
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics/IdentityTypeEnvironment.java
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics/SimpleTypeEnvironment.java
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics/TypeEnvironment.java
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics/TypeEnvironmentFactory.java
Log:
[ANN-494] - Type guessing in @Embedded and @CollectionOfElements
Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/CollectionBinder.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/CollectionBinder.java 2006-12-10 19:39:06 UTC (rev 10971)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/CollectionBinder.java 2006-12-11 12:30:20 UTC (rev 10972)
@@ -375,11 +375,10 @@
//work on association
boolean isMappedBy = ! BinderHelper.isDefault( mappedBy );
collection.setInverse( isMappedBy );
- String collType = getCollectionType().getName();
-
+
//many to many may need some second pass informations
if ( ! oneToMany && isMappedBy ) {
- mappings.addMappedBy( collType, mappedBy, propertyName );
+ mappings.addMappedBy( getCollectionType().getName(), mappedBy, propertyName );
}
//TODO reducce tableBinder != null and oneToMany
//FIXME collection of elements shouldn't be executed as a secondpass
@@ -389,7 +388,7 @@
inverseJoinColumns,
elementColumns,
mapKeyColumns, mapKeyManyToManyColumns, isEmbedded,
- property, collType,
+ property, getCollectionType(),
ignoreNotFound, oneToMany,
tableBinder, mappings
);
@@ -496,7 +495,7 @@
final Ejb3JoinColumn[] inverseColumns,
final Ejb3Column[] elementColumns,
final Ejb3Column[] mapKeyColumns, final Ejb3JoinColumn[] mapKeyManyToManyColumns, final boolean isEmbedded,
- final XProperty property, final String collType,
+ final XProperty property, final XClass collType,
final boolean ignoreNotFound, final boolean unique,
final TableBinder assocTableBinder, final ExtendedMappings mappings
) {
@@ -518,13 +517,13 @@
* return true if it's a Fk, false if it's an association table
*/
protected boolean bindStarToManySecondPass(
- Map persistentClasses, String collType, Ejb3JoinColumn[] fkJoinColumns,
+ Map persistentClasses, XClass collType, Ejb3JoinColumn[] fkJoinColumns,
Ejb3JoinColumn[] keyColumns, Ejb3JoinColumn[] inverseColumns, Ejb3Column[] elementColumns,
boolean isEmbedded,
XProperty property, boolean unique,
TableBinder associationTableBinder, boolean ignoreNotFound, ExtendedMappings mappings
) {
- PersistentClass persistentClass = (PersistentClass) persistentClasses.get( collType );
+ PersistentClass persistentClass = (PersistentClass) persistentClasses.get( collType.getName() );
boolean reversePropertyInJoin = false;
if ( persistentClass != null && StringHelper.isNotEmpty( this.mappedBy ) ) {
try {
@@ -581,7 +580,7 @@
protected void bindOneToManySecondPass(
Collection collection, Map persistentClasses, Ejb3JoinColumn[] fkJoinColumns,
- String collectionType,
+ XClass collectionType,
boolean cascadeDeleteEnabled, boolean ignoreNotFound, String hqlOrderBy, ExtendedMappings extendedMappings
) {
if ( log.isDebugEnabled() ) {
@@ -591,7 +590,7 @@
}
org.hibernate.mapping.OneToMany oneToMany = new org.hibernate.mapping.OneToMany( collection.getOwner() );
collection.setElement( oneToMany );
- oneToMany.setReferencedEntityName( collectionType );
+ oneToMany.setReferencedEntityName( collectionType.getName() );
oneToMany.setIgnoreNotFound( ignoreNotFound );
String assocClass = oneToMany.getReferencedEntityName();
@@ -988,14 +987,14 @@
Ejb3JoinColumn[] inverseJoinColumns,
Ejb3Column[] elementColumns,
boolean isEmbedded,
- String collType,
+ XClass collType,
boolean ignoreNotFound, boolean unique,
boolean cascadeDeleteEnabled,
TableBinder associationTableBinder, XProperty property, PropertyHolder parentPropertyHolder,
String hqlOrderBy, ExtendedMappings mappings
) throws MappingException {
- PersistentClass collectionEntity = (PersistentClass) persistentClasses.get( collType );
+ PersistentClass collectionEntity = (PersistentClass) persistentClasses.get( collType.getName() );
boolean isCollectionOfEntities = collectionEntity != null;
if ( log.isDebugEnabled() ) {
String path = collValue.getOwnerEntityName() + "." + joinColumns[0].getPropertyName();
@@ -1105,7 +1104,7 @@
element =
new ManyToOne( collValue.getCollectionTable() );
collValue.setElement( element );
- element.setReferencedEntityName( collType );
+ element.setReferencedEntityName( collType.getName() );
//element.setFetchMode( fetchMode );
//element.setLazy( fetchMode != FetchMode.JOIN );
//make the second join non lazy
@@ -1129,17 +1128,12 @@
// );
//FIXME the "element" is lost
PropertyHolder holder = null;
- if ( BinderHelper.PRIMITIVE_NAMES.contains( collType ) ) {
+ if ( BinderHelper.PRIMITIVE_NAMES.contains( collType.getName() ) ) {
classType = AnnotatedClassType.NONE;
elementClass = null;
}
else {
- try {
- elementClass = mappings.getReflectionManager().classForName( collType, CollectionBinder.class );
- }
- catch (ClassNotFoundException e) {
- throw new AnnotationException( "Unable to find class: " + collType, e );
- }
+ elementClass = collType;
classType = mappings.getClassType( elementClass );
holder = PropertyHolderBuilder.buildPropertyHolder(
@@ -1195,7 +1189,7 @@
else {
SimpleValueBinder elementBinder = new SimpleValueBinder();
elementBinder.setMappings( mappings );
- elementBinder.setReturnedClassName( collType );
+ elementBinder.setReturnedClassName( collType.getName() );
if ( elementColumns == null || elementColumns.length == 0 ) {
elementColumns = new Ejb3Column[1];
Ejb3Column column = new Ejb3Column();
Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/IdBagBinder.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/IdBagBinder.java 2006-12-10 19:39:06 UTC (rev 10971)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/IdBagBinder.java 2006-12-11 12:30:20 UTC (rev 10972)
@@ -1,25 +1,26 @@
//$Id: $
package org.hibernate.cfg.annotations;
+import java.util.Collections;
import java.util.Map;
-import java.util.Collections;
+import org.hibernate.AnnotationException;
+import org.hibernate.annotations.CollectionId;
+import org.hibernate.annotations.Type;
+import org.hibernate.cfg.BinderHelper;
+import org.hibernate.cfg.Ejb3Column;
+import org.hibernate.cfg.Ejb3JoinColumn;
+import org.hibernate.cfg.ExtendedMappings;
+import org.hibernate.cfg.PropertyData;
+import org.hibernate.cfg.PropertyInferredData;
+import org.hibernate.cfg.WrappedInferredData;
import org.hibernate.mapping.Collection;
+import org.hibernate.mapping.IdentifierCollection;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.SimpleValue;
-import org.hibernate.mapping.IdentifierCollection;
import org.hibernate.mapping.Table;
-import org.hibernate.cfg.Ejb3JoinColumn;
-import org.hibernate.cfg.Ejb3Column;
-import org.hibernate.cfg.ExtendedMappings;
-import org.hibernate.cfg.PropertyData;
-import org.hibernate.cfg.WrappedInferredData;
-import org.hibernate.cfg.PropertyInferredData;
-import org.hibernate.cfg.BinderHelper;
+import org.hibernate.reflection.XClass;
import org.hibernate.reflection.XProperty;
-import org.hibernate.annotations.CollectionId;
-import org.hibernate.annotations.Type;
-import org.hibernate.AnnotationException;
import org.hibernate.util.StringHelper;
/**
@@ -32,7 +33,7 @@
@Override
protected boolean bindStarToManySecondPass(
- Map persistentClasses, String collType, Ejb3JoinColumn[] fkJoinColumns, Ejb3JoinColumn[] keyColumns,
+ Map persistentClasses, XClass collType, Ejb3JoinColumn[] fkJoinColumns, Ejb3JoinColumn[] keyColumns,
Ejb3JoinColumn[] inverseColumns, Ejb3Column[] elementColumns, boolean isEmbedded, XProperty property,
boolean unique, TableBinder associationTableBinder, boolean ignoreNotFound, ExtendedMappings mappings
) {
Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/ListBinder.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/ListBinder.java 2006-12-10 19:39:06 UTC (rev 10971)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/ListBinder.java 2006-12-11 12:30:20 UTC (rev 10972)
@@ -55,7 +55,7 @@
final Ejb3JoinColumn[] inverseColumns,
final Ejb3Column[] elementColumns,
Ejb3Column[] mapKeyColumns, final Ejb3JoinColumn[] mapKeyManyToManyColumns, final boolean isEmbedded,
- final XProperty property, final String collType,
+ final XProperty property, final XClass collType,
final boolean ignoreNotFound, final boolean unique,
final TableBinder assocTableBinder, final ExtendedMappings mappings
) {
Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/MapBinder.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/MapBinder.java 2006-12-10 19:39:06 UTC (rev 10971)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/MapBinder.java 2006-12-11 12:30:20 UTC (rev 10972)
@@ -70,7 +70,7 @@
final Ejb3JoinColumn[] inverseColumns,
final Ejb3Column[] elementColumns,
final Ejb3Column[] mapKeyColumns, final Ejb3JoinColumn[] mapKeyManyToManyColumns, final boolean isEmbedded,
- final XProperty property, final String collType,
+ final XProperty property, final XClass collType,
final boolean ignoreNotFound, final boolean unique,
final TableBinder assocTableBinder, final ExtendedMappings mappings
) {
@@ -91,13 +91,13 @@
}
private void bindKeyFromAssociationTable(
- String collType, Map persistentClasses, String mapKeyPropertyName, XProperty property,
+ XClass collType, Map persistentClasses, String mapKeyPropertyName, XProperty property,
boolean isEmbedded, ExtendedMappings mappings, Ejb3Column[] mapKeyColumns,
Ejb3JoinColumn[] mapKeyManyToManyColumns, String targetPropertyName
) {
if ( mapKeyPropertyName != null ) {
//this is an EJB3 @MapKey
- PersistentClass associatedClass = (PersistentClass) persistentClasses.get( collType );
+ PersistentClass associatedClass = (PersistentClass) persistentClasses.get( collType.getName() );
if ( associatedClass == null ) throw new AnnotationException( "Associated class not found: " + collType );
Property mapProperty = BinderHelper.findPropertyByName( associatedClass, mapKeyPropertyName );
if ( mapProperty == null ) {
Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaXClass.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaXClass.java 2006-12-10 19:39:06 UTC (rev 10971)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaXClass.java 2006-12-11 12:30:20 UTC (rev 10972)
@@ -33,9 +33,10 @@
}
public XClass getSuperclass() {
- //return getFactory().toXClass( toClass().getSuperclass(), getFactory().getTypeEnvironment( toClass() ) );
return getFactory().toXClass( toClass().getSuperclass(),
- new CompoundTypeEnvironment( getTypeEnvironment(), getFactory().getTypeEnvironment( toClass() )
+ CompoundTypeEnvironment.create(
+ getTypeEnvironment(),
+ getFactory().getTypeEnvironment( toClass() )
)
);
}
@@ -44,10 +45,11 @@
Class[] classes = toClass().getInterfaces();
int length = classes.length;
XClass[] xClasses = new XClass[length];
- //TypeEnvironment environment = getFactory().getTypeEnvironment( toClass() );
if (length != 0) {
- TypeEnvironment environment =
- new CompoundTypeEnvironment( getTypeEnvironment(), getFactory().getTypeEnvironment( toClass() ) );
+ TypeEnvironment environment = CompoundTypeEnvironment.create(
+ getTypeEnvironment(),
+ getFactory().getTypeEnvironment( toClass() )
+ );
for ( int index = 0; index < length ; index++ ) {
xClasses[index] = getFactory().toXClass( classes[index], environment );
}
@@ -75,7 +77,7 @@
List<XProperty> result = new LinkedList<XProperty>();
for ( Field f : toClass().getDeclaredFields() ) {
if ( JavaXProperty.isProperty( f, getTypeEnvironment().bind( f.getGenericType() ), filter ) ) {
- result.add( getFactory().getXProperty( f, this ) );
+ result.add( getFactory().getXProperty( f, getTypeEnvironment() ) );
}
}
return result;
@@ -85,7 +87,7 @@
List<XProperty> result = new LinkedList<XProperty>();
for ( Method m : toClass().getDeclaredMethods() ) {
if ( JavaXProperty.isProperty( m, getTypeEnvironment().bind( m.getGenericReturnType() ), filter ) ) {
- result.add( getFactory().getXProperty( m, this ) );
+ result.add( getFactory().getXProperty( m, getTypeEnvironment() ) );
}
}
return result;
@@ -108,7 +110,7 @@
public List<XMethod> getDeclaredMethods() {
List<XMethod> result = new LinkedList<XMethod>();
for ( Method m : toClass().getDeclaredMethods() ) {
- result.add( getFactory().getXMethod( m, this ) );
+ result.add( getFactory().getXMethod( m, getTypeEnvironment() ) );
}
return result;
}
@@ -128,4 +130,9 @@
TypeEnvironment getTypeEnvironment() {
return context;
}
+
+ @Override
+ public String toString() {
+ return getName();
+ }
}
\ No newline at end of file
Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaXFactory.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaXFactory.java 2006-12-10 19:39:06 UTC (rev 10971)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaXFactory.java 2006-12-11 12:30:20 UTC (rev 10972)
@@ -24,6 +24,7 @@
import org.hibernate.reflection.XMethod;
import org.hibernate.reflection.XPackage;
import org.hibernate.reflection.XProperty;
+import org.hibernate.reflection.java.generics.CompoundTypeEnvironment;
import org.hibernate.reflection.java.generics.IdentityTypeEnvironment;
import org.hibernate.reflection.java.generics.TypeEnvironment;
import org.hibernate.reflection.java.generics.TypeEnvironmentFactory;
@@ -102,9 +103,9 @@
}
}
- private static class MemberKey extends Pair<Member, TypeKey> {
- MemberKey(Member member, Type owner, TypeEnvironment context) {
- super( member, new TypeKey( owner, context ) );
+ private static class MemberKey extends Pair<Member, TypeEnvironment> {
+ MemberKey(Member member, TypeEnvironment context) {
+ super( member, context );
}
}
@@ -236,7 +237,9 @@
@Override
public XClass caseParameterizedType(ParameterizedType parameterizedType) {
- return toXClass( parameterizedType.getRawType(), context );
+ return toXClass( parameterizedType.getRawType(),
+ typeEnvs.getEnvironment( parameterizedType, context )
+ );
}
}.doSwitch( context.bind( t ) );
}
@@ -250,23 +253,23 @@
return xPackage;
}
- XProperty getXProperty(Member member, JavaXClass owner) {
- MemberKey key = new MemberKey( member, owner.toClass(), owner.getTypeEnvironment() );
+ XProperty getXProperty(Member member, TypeEnvironment context) {
+ MemberKey key = new MemberKey( member, context );
//FIXME get is as expensive as create most time spent in hashCode and equals
JavaXProperty xProperty = xProperties.get( key );
if ( xProperty == null ) {
- xProperty = JavaXProperty.create( member, owner.getTypeEnvironment(), this );
+ xProperty = JavaXProperty.create( member, context, this );
xProperties.put( key, xProperty );
}
return xProperty;
}
- XMethod getXMethod(Member member, JavaXClass owner) {
- MemberKey key = new MemberKey( member, owner.toClass(), owner.getTypeEnvironment() );
+ XMethod getXMethod(Member member, TypeEnvironment context) {
+ MemberKey key = new MemberKey( member, context );
//FIXME get is as expensive as create most time spent in hashCode and equals
JavaXMethod xMethod = xMethods.get( key );
if ( xMethod == null ) {
- xMethod = JavaXMethod.create( member, owner.getTypeEnvironment(), this );
+ xMethod = JavaXMethod.create( member, context, this );
xMethods.put( key, xMethod );
}
return xMethod;
Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics/ApproximatingTypeEnvironment.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics/ApproximatingTypeEnvironment.java 2006-12-10 19:39:06 UTC (rev 10971)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics/ApproximatingTypeEnvironment.java 2006-12-11 12:30:20 UTC (rev 10972)
@@ -101,7 +101,7 @@
}.doSwitch( type );
}
- public Type coarseApproximation(final Type type) {
+ private Type coarseApproximation(final Type type) {
Type result = new TypeSwitch<Type>() {
public Type caseWildcardType(WildcardType wildcardType) {
return approximateTo( wildcardType.getUpperBounds() );
@@ -143,4 +143,9 @@
assert TypeUtils.isResolved( result );
return result;
}
+
+ @Override
+ public String toString() {
+ return "approximated_types";
+ }
}
Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics/CompoundTypeEnvironment.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics/CompoundTypeEnvironment.java 2006-12-10 19:39:06 UTC (rev 10971)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics/CompoundTypeEnvironment.java 2006-12-11 12:30:20 UTC (rev 10972)
@@ -13,9 +13,18 @@
private final TypeEnvironment f;
private final TypeEnvironment g;
+
private final int hashCode;
- public CompoundTypeEnvironment(TypeEnvironment f, TypeEnvironment g) {
+ public static TypeEnvironment create(TypeEnvironment f, TypeEnvironment g) {
+ if ( g == IdentityTypeEnvironment.INSTANCE )
+ return f;
+ if ( f == IdentityTypeEnvironment.INSTANCE )
+ return g;
+ return new CompoundTypeEnvironment( f, g );
+ }
+
+ private CompoundTypeEnvironment(TypeEnvironment f, TypeEnvironment g) {
this.f = f;
this.g = g;
hashCode = doHashCode();
@@ -53,4 +62,9 @@
//cached because the inheritance can be big
return hashCode;
}
+
+ @Override
+ public String toString() {
+ return f.toString() + "(" + g.toString() + ")";
+ }
}
Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics/IdentityTypeEnvironment.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics/IdentityTypeEnvironment.java 2006-12-10 19:39:06 UTC (rev 10971)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics/IdentityTypeEnvironment.java 2006-12-11 12:30:20 UTC (rev 10972)
@@ -18,4 +18,8 @@
public Type bind(Type type) {
return type;
}
+
+ public String toString() {
+ return "{}";
+ }
}
Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics/SimpleTypeEnvironment.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics/SimpleTypeEnvironment.java 2006-12-10 19:39:06 UTC (rev 10971)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics/SimpleTypeEnvironment.java 2006-12-11 12:30:20 UTC (rev 10972)
@@ -5,18 +5,17 @@
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
import java.lang.reflect.WildcardType;
+import java.util.HashMap;
/**
* @author Davide Marchignoli
* @author Paolo Perrotta
*/
-class SimpleTypeEnvironment implements TypeEnvironment {
+class SimpleTypeEnvironment extends HashMap<Type, Type> implements TypeEnvironment {
- final Type[] formalArguments;
-
- final Type[] actualArguments;
-
- private final TypeSwitch<Type> substitute = new TypeSwitch<Type>() {
+ private static final long serialVersionUID = 1L;
+
+ private final TypeSwitch<Type> substitute = new TypeSwitch<Type>() {
@Override
public Type caseClass(Class classType) {
return classType;
@@ -60,28 +59,22 @@
@Override
public Type caseTypeVariable(TypeVariable typeVariable) {
- int idx = indexOf( formalArguments, typeVariable );
- return ( idx >= 0 ) ? actualArguments[idx] : typeVariable;
+ if ( !containsKey( typeVariable )) {
+ return typeVariable;
+ }
+ return get( typeVariable );
}
- private int indexOf(Object[] array, Object o) {
- for ( int i = 0; i < array.length ; i++ ) {
- if ( array[i].equals( o ) ) {
- return i;
- }
- }
- return -1;
- }
-
@Override
public Type caseWildcardType(WildcardType wildcardType) {
return wildcardType;
}
};
- public SimpleTypeEnvironment(Type[] formal, Type[] actual) {
- actualArguments = actual;
- formalArguments = formal;
+ public SimpleTypeEnvironment(Type[] formalTypeArgs, Type[] actualTypeArgs) {
+ for (int i = 0; i < formalTypeArgs.length; i++) {
+ put( formalTypeArgs[i], actualTypeArgs[i] );
+ }
}
public Type bind(Type type) {
Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics/TypeEnvironment.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics/TypeEnvironment.java 2006-12-10 19:39:06 UTC (rev 10971)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics/TypeEnvironment.java 2006-12-11 12:30:20 UTC (rev 10972)
@@ -40,7 +40,7 @@
* then it's guaranteed to be a regular Java <code>Class</code>. In all
* other cases, this method might return a custom implementation of some
* interface that extends <code>Type</code>. Be sure not to mix these
- * objects with with Java's implementations of <code>Type</code> to avoid
+ * objects with Java's implementations of <code>Type</code> to avoid
* potential identity problems.
* <p/>
* This class does not support bindings involving inner classes or
Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics/TypeEnvironmentFactory.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics/TypeEnvironmentFactory.java 2006-12-10 19:39:06 UTC (rev 10971)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics/TypeEnvironmentFactory.java 2006-12-11 12:30:20 UTC (rev 10972)
@@ -26,12 +26,16 @@
return doGetEnvironment( context );
}
- public TypeEnvironment getEnvironment(ParameterizedType context) {
+ public TypeEnvironment getEnvironment(Type context) {
return doGetEnvironment( context );
}
+ public TypeEnvironment getEnvironment(Type t, TypeEnvironment context) {
+ return CompoundTypeEnvironment.create( getEnvironment(t), context );
+ }
+
public TypeEnvironment toApproximatingEnvironment(TypeEnvironment context) {
- return new CompoundTypeEnvironment( new ApproximatingTypeEnvironment(), context );
+ return CompoundTypeEnvironment.create( new ApproximatingTypeEnvironment(), context );
}
private TypeEnvironment doGetEnvironment(Type context) {
@@ -50,10 +54,10 @@
return new TypeSwitch<TypeEnvironment>() {
@Override
public TypeEnvironment caseClass(Class classType) {
- return new CompoundTypeEnvironment(
- createSuperTypeEnvironment( classType ),
- getEnvironment( classType.getSuperclass() )
- );
+ return CompoundTypeEnvironment.create(
+ createSuperTypeEnvironment( classType ),
+ getEnvironment( classType.getSuperclass() )
+ );
}
@Override
Added: branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/generics/EmbeddedGenericsTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/generics/EmbeddedGenericsTest.java 2006-12-10 19:39:06 UTC (rev 10971)
+++ branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/generics/EmbeddedGenericsTest.java 2006-12-11 12:30:20 UTC (rev 10972)
@@ -0,0 +1,111 @@
+package org.hibernate.test.annotations.generics;
+
+/**
+ * A test case for ANN-494.
+ *
+ * @author Edward Costello
+ * @author Paolo Perrotta
+ */
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.persistence.Embeddable;
+import javax.persistence.Embedded;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.annotations.CollectionOfElements;
+import org.hibernate.test.annotations.TestCase;
+
+public class EmbeddedGenericsTest extends TestCase {
+
+ Session session;
+ Edition<String> edition;
+
+ public void setUp() throws Exception {
+ super.setUp();
+ session = getSessions().openSession();
+ session.getTransaction().begin();
+ edition = new Edition<String>();
+ edition.name = "Second";
+ }
+
+ public void tearDown() throws Exception {
+ session.close();
+ super.tearDown();
+ }
+
+ public void testWorksWithGenericEmbedded() {
+ Book b = new Book();
+ b.edition = edition;
+ persist( b );
+
+ Book retrieved = (Book)find( Book.class, b.id );
+ assertEquals( "Second", retrieved.edition.name );
+
+ clean( Book.class, b.id );
+ }
+
+ public void testWorksWithGenericCollectionOfElements() {
+ PopularBook b = new PopularBook();
+ b.editions.add( edition );
+ persist( b );
+
+ PopularBook retrieved = (PopularBook)find( PopularBook.class, b.id );
+ assertEquals( "Second", retrieved.editions.iterator().next().name );
+
+ clean( PopularBook.class, b.id );
+ }
+
+ protected Class[] getMappings() {
+ return new Class[]{
+ Book.class,
+ PopularBook.class
+ };
+ }
+
+ private void persist(Object data) {
+ session.persist( data );
+ session.getTransaction().commit();
+ session.clear();
+ }
+
+ private Object find(Class clazz, Long id) {
+ return session.get( clazz, id );
+ }
+
+ private void clean(Class<?> clazz, Long id) {
+ Transaction tx = session.beginTransaction();
+ session.delete( find( clazz, id ) );
+ tx.commit();
+ }
+
+ @Embeddable
+ public static class Edition<T> {
+ T name;
+ }
+
+ @Entity
+ public static class Book {
+ @Id
+ @GeneratedValue(strategy=GenerationType.AUTO)
+ Long id;
+
+ @Embedded
+ Edition<String> edition;
+ }
+
+ @Entity
+ public static class PopularBook {
+ @Id
+ @GeneratedValue(strategy=GenerationType.AUTO)
+ Long id;
+
+ @CollectionOfElements
+ Set<Edition<String>> editions = new HashSet<Edition<String>>();
+ }
+}
Added: branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/DeepGenericsContainment.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/DeepGenericsContainment.java 2006-12-10 19:39:06 UTC (rev 10971)
+++ branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/reflection/java/generics/deep/DeepGenericsContainment.java 2006-12-11 12:30:20 UTC (rev 10972)
@@ -0,0 +1,48 @@
+//$Id: $
+package org.hibernate.test.reflection.java.generics.deep;
+
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.hibernate.reflection.XClass;
+import org.hibernate.reflection.XProperty;
+import org.hibernate.reflection.java.JavaXFactory;
+
+
+/**
+ * @author Paolo Perrotta
+ */
+public class DeepGenericsContainment extends TestCase {
+
+ public static class Contained<T> {
+ T generic;
+ }
+
+ public static class Container {
+ Contained<String> contained;
+ }
+
+ public static class ContainerWithCollection {
+ List<Contained<String>> contained;
+ }
+
+ public void test2StepsGenerics() throws Exception {
+ JavaXFactory factory = new JavaXFactory();
+ XClass container = factory.toXClass( Container.class );
+ XProperty contained = container.getDeclaredProperties( XClass.ACCESS_FIELD ).get( 0 );
+ assertTrue( contained.isTypeResolved() );
+ XProperty generic = contained.getType().getDeclaredProperties( XClass.ACCESS_FIELD ).get( 0 );
+ assertTrue( generic.isTypeResolved() );
+ }
+
+ public void test2StepsGenericsCollection() throws Exception {
+ JavaXFactory factory = new JavaXFactory();
+ XClass container = factory.toXClass( ContainerWithCollection.class );
+ XProperty collection = container.getDeclaredProperties( XClass.ACCESS_FIELD ).get( 0 );
+ assertTrue( collection.isTypeResolved() );
+ XClass elementClass = collection.getElementClass();
+ XProperty generic = elementClass.getDeclaredProperties( XClass.ACCESS_FIELD ).get( 0 );
+ assertTrue( generic.isTypeResolved() );
+ }
+}
17 years, 11 months
Hibernate SVN: r10971 - tags/entitymanager_v3_2_1_GA
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-12-10 14:39:06 -0500 (Sun, 10 Dec 2006)
New Revision: 10971
Added:
tags/entitymanager_v3_2_1_GA/HibernateExt/
Log:
made a copy
Copied: tags/entitymanager_v3_2_1_GA/HibernateExt (from rev 10970, branches/Branch_3_2/HibernateExt)
17 years, 11 months