[hibernate-commits] Hibernate SVN: r11575 - in trunk/Hibernate3/testsuite/src/test: java/org/hibernate/test/bytecode/cglib and 12 other directories.
hibernate-commits at lists.jboss.org
hibernate-commits at lists.jboss.org
Sat May 26 03:34:56 EDT 2007
Author: steve.ebersole at jboss.com
Date: 2007-05-26 03:34:56 -0400 (Sat, 26 May 2007)
New Revision: 11575
Added:
trunk/Hibernate3/testsuite/src/test/unmaintained/org/hibernate/test/hql/
trunk/Hibernate3/testsuite/src/test/unmaintained/org/hibernate/test/hql/ASTQueryTranslatorTest.java
Removed:
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/AllTests.java
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/TestCase.java
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/hql/ASTQueryTranslatorTest.java
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/lazycache/InstrumentCacheTest2.java
Modified:
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/FailureExpectedCollector.java
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/bytecode/cglib/InvocationTargetExceptionTest.java
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/connections/ConnectionManagementTestCase.java
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/dynamicentity/tuplizer/TuplizerDynamicEntityTest.java
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/hql/EJBQLTest.java
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/hql/WithClauseTest.java
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/id/UseIdentifierRollbackTest.java
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/instrument/cases/TestLazyExecutable.java
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/jpa/AbstractJPATest.java
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/keymanytoone/bidir/component/EagerKeyManyToOneTest.java
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/keymanytoone/bidir/component/LazyKeyManyToOneTest.java
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/keymanytoone/bidir/embedded/KeyManyToOneTest.java
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/lazycache/InstrumentCacheTest.java
trunk/Hibernate3/testsuite/src/test/resources/log4j.properties
Log:
ok, thats much better
Deleted: trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/AllTests.java
===================================================================
--- trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/AllTests.java 2007-05-26 07:34:00 UTC (rev 11574)
+++ trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/AllTests.java 2007-05-26 07:34:56 UTC (rev 11575)
@@ -1,445 +0,0 @@
-//$Id: AllTests.java 11496 2007-05-09 03:54:06Z steve.ebersole at jboss.com $
-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;
-import org.hibernate.test.array.ArrayTest;
-import org.hibernate.test.ast.ASTIteratorTest;
-import org.hibernate.test.ast.ASTUtilTest;
-import org.hibernate.test.batchfetch.BatchFetchTest;
-import org.hibernate.test.bidi.AuctionTest;
-import org.hibernate.test.bidi.AuctionTest2;
-import org.hibernate.test.bytecode.BytecodeSuite;
-import org.hibernate.test.cache.CacheSuite;
-import org.hibernate.test.cascade.RefreshTest;
-import org.hibernate.test.cid.CompositeIdTest;
-import org.hibernate.test.collection.CollectionSuite;
-import org.hibernate.test.component.ComponentSuite;
-import org.hibernate.test.compositeelement.CompositeElementTest;
-import org.hibernate.test.connections.ConnectionsSuite;
-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.functional.DialectFunctionalTestsSuite;
-import org.hibernate.test.dialect.unit.DialectUnitTestsSuite;
-import org.hibernate.test.discriminator.DiscriminatorTest;
-import org.hibernate.test.dynamicentity.interceptor.InterceptorDynamicEntityTest;
-import org.hibernate.test.dynamicentity.tuplizer.TuplizerDynamicEntityTest;
-import org.hibernate.test.ecid.EmbeddedCompositeIdTest;
-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.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;
-import org.hibernate.test.idclass.IdClassTest;
-import org.hibernate.test.idprops.IdentifierPropertyReferencesTest;
-import org.hibernate.test.immutable.ImmutableTest;
-import org.hibernate.test.instrument.buildtime.InstrumentTest;
-import org.hibernate.test.instrument.runtime.CGLIBInstrumentationTest;
-import org.hibernate.test.instrument.runtime.JavassistInstrumentationTest;
-import org.hibernate.test.interceptor.InterceptorTest;
-import org.hibernate.test.interfaceproxy.InterfaceProxyTest;
-import org.hibernate.test.iterate.IterateTest;
-import org.hibernate.test.join.JoinTest;
-import org.hibernate.test.joinedsubclass.JoinedSubclassTest;
-import org.hibernate.test.joinfetch.JoinFetchTest;
-import org.hibernate.test.jpa.JPAComplianceSuite;
-import org.hibernate.test.keymanytoone.KeyManyToOneSuite;
-import org.hibernate.test.lazycache.InstrumentCacheTest;
-import org.hibernate.test.lazycache.InstrumentCacheTest2;
-import org.hibernate.test.lazyonetoone.LazyOneToOneTest;
-import org.hibernate.test.legacy.ABCProxyTest;
-import org.hibernate.test.legacy.ABCTest;
-import org.hibernate.test.legacy.CacheTest;
-import org.hibernate.test.legacy.ComponentNotNullTest;
-import org.hibernate.test.legacy.ConfigurationPerformanceTest;
-import org.hibernate.test.legacy.FooBarTest;
-import org.hibernate.test.legacy.FumTest;
-import org.hibernate.test.legacy.IJ2Test;
-import org.hibernate.test.legacy.IJTest;
-import org.hibernate.test.legacy.MapTest;
-import org.hibernate.test.legacy.MasterDetailTest;
-import org.hibernate.test.legacy.MultiTableTest;
-import org.hibernate.test.legacy.NonReflectiveBinderTest;
-import org.hibernate.test.legacy.OneToOneCacheTest;
-import org.hibernate.test.legacy.ParentChildTest;
-import org.hibernate.test.legacy.QueryByExampleTest;
-import org.hibernate.test.legacy.SQLFunctionsTest;
-import org.hibernate.test.legacy.SQLLoaderTest;
-import org.hibernate.test.legacy.StatisticsTest;
-import org.hibernate.test.lob.LobSuite;
-import org.hibernate.test.manytomany.ManyToManyTest;
-import org.hibernate.test.map.MapIndexFormulaTest;
-import org.hibernate.test.mapcompelem.MapCompositeElementTest;
-import org.hibernate.test.mapelemformula.MapElementFormulaTest;
-import org.hibernate.test.mapping.PersistentClassVisitorTest;
-import org.hibernate.test.mapping.ValueVisitorTest;
-import org.hibernate.test.mappingexception.MappingExceptionTest;
-import org.hibernate.test.mixed.MixedTest;
-import org.hibernate.test.naturalid.NaturalIdTest;
-import org.hibernate.test.ondelete.OnDeleteTest;
-import org.hibernate.test.onetomany.OneToManyTest;
-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.OrphanSuite;
-import org.hibernate.test.pagination.PaginationTest;
-import org.hibernate.test.propertyref.PropertyRefSuite;
-import org.hibernate.test.proxy.ProxyTest;
-import org.hibernate.test.querycache.QueryCacheTest;
-import org.hibernate.test.readonly.ReadOnlyTest;
-import org.hibernate.test.rowid.RowIdTest;
-import org.hibernate.test.sorted.SortTest;
-import org.hibernate.test.sql.NativeSqlSupportSuite;
-import org.hibernate.test.stats.SessionStatsTest;
-import org.hibernate.test.stats.StatsTest;
-import org.hibernate.test.subclassfilter.DiscrimSubclassFilterTest;
-import org.hibernate.test.subclassfilter.JoinedSubclassFilterTest;
-import org.hibernate.test.subclassfilter.UnionSubclassFilterTest;
-import org.hibernate.test.subselect.SubselectTest;
-import org.hibernate.test.subselectfetch.SubselectFetchTest;
-import org.hibernate.test.ternary.TernaryTest;
-import org.hibernate.test.timestamp.TimestampTest;
-import org.hibernate.test.tm.CMTTest;
-import org.hibernate.test.typedmanytoone.TypedManyToOneTest;
-import org.hibernate.test.typedonetoone.TypedOneToOneTest;
-import org.hibernate.test.typeparameters.TypeParameterTest;
-import org.hibernate.test.unconstrained.UnconstrainedTest;
-import org.hibernate.test.unidir.BackrefTest;
-import org.hibernate.test.unionsubclass.UnionSubclassTest;
-import org.hibernate.test.usercollection.UserCollectionTypeSuite;
-import org.hibernate.test.util.UtilSuite;
-import org.hibernate.test.version.VersionTest;
-import org.hibernate.test.version.db.DbVersionTest;
-import org.hibernate.test.version.sybase.SybaseTimestampVersioningTest;
-import org.hibernate.test.where.WhereTest;
-import org.hibernate.test.insertordering.InsertOrderingTest;
-import org.hibernate.test.reattachment.ReattachmentSuite;
-
-/**
- * @author Gavin King
- */
-public class AllTests {
-
- /**
- * Returns the entire test suite (both legacy and new
- *
- * @return the entire test suite
- */
- public static Test suite() {
- TestSuite suite = new TestSuite();
- suite.addTest( NewTests.suite() );
- suite.addTest( LegacyTests.suite() );
- return suite;
- }
-
- /**
- * Returns the entire test suite (both legacy and new) w/o filtering
- *
- * @return the entire test suite
- */
- public static Test unfilteredSuite() {
- TestSuite suite = new TestSuite();
- suite.addTest( NewTests.unfilteredSuite() );
- suite.addTest( LegacyTests.unfilteredSuite() );
- return suite;
- }
-
- /**
- * Runs the entire test suite.
- *
- * @param args n/a
- * @see #suite
- */
- public static void main(String args[]) {
- TestRunner.run( suite() );
- }
-
- /**
- * An inner class representing the new test suite.
- */
- public static class NewTests {
-
- /**
- * Returns the new test suite (filtered)
- *
- * @return the new test suite
- */
- public static Test suite() {
- return filter( ( TestSuite ) unfilteredSuite() );
- }
-
- /**
- * Returns the new test suite (unfiltered)
- *
- * @return the new test suite
- */
- public static Test unfilteredSuite() {
- TestSuite suite = new TestSuite("New tests suite");
- suite.addTest( OpsSuite.suite() );
- suite.addTest( NaturalIdTest.suite() );
- suite.addTest( ComponentSuite.suite() );
- suite.addTest( ProxyTest.suite() );
- suite.addTest( VersionTest.suite() );
- suite.addTest( TimestampTest.suite() );
- suite.addTest( InterceptorTest.suite() );
- suite.addTest( EmbeddedCompositeIdTest.suite() );
- suite.addTest( ImmutableTest.suite() );
- suite.addTest( ReadOnlyTest.suite() );
- suite.addTest( IdClassTest.suite() );
- suite.addTest( ArrayTest.suite() );
- suite.addTest( TernaryTest.suite() );
- suite.addTest( CollectionSuite.suite() );
- suite.addTest( IdBagTest.suite() );
- suite.addTest( MapCompositeElementTest.suite() );
- suite.addTest( MapIndexFormulaTest.suite() );
- suite.addTest( MapElementFormulaTest.suite() );
- suite.addTest( BackrefTest.suite() );
- suite.addTest( BatchFetchTest.suite() );
- suite.addTest( CompositeIdTest.suite() );
- suite.addTest( CompositeElementTest.suite() );
- suite.addTest( CompositePropertyRefTest.suite() );
- suite.addTest( FormulaJoinTest.suite() );
- suite.addTest( DiscriminatorTest.suite() );
- suite.addTest( EntityModeSuite.suite() );
- suite.addTest( DynamicFilterTest.suite() );
- suite.addTest( InterfaceProxyTest.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( OneToOneSuite.suite() );
- suite.addTest( OptimisticLockTest.suite() );
- suite.addTest( PropertyRefSuite.suite() );
- suite.addTest( NativeSqlSupportSuite.suite() );
- suite.addTest( CriteriaQueryTest.suite() );
- suite.addTest( SubselectTest.suite() );
- suite.addTest( SubselectFetchTest.suite() );
- suite.addTest( JoinFetchTest.suite() );
- suite.addTest( UnionSubclassTest.suite() );
- suite.addTest( ASTIteratorTest.suite() );
- suite.addTest( HQLSuite.suite() );
- suite.addTest( ASTUtilTest.suite() );
- suite.addTest( CacheSuite.suite() );
- suite.addTest( QueryCacheTest.suite() );
- suite.addTest( CompositeUserTypeTest.suite() );
- suite.addTest( TypeParameterTest.suite() );
- suite.addTest( TypedOneToOneTest.suite() );
- suite.addTest( TypedManyToOneTest.suite() );
- suite.addTest( CMTTest.suite() );
- suite.addTest( MultipleHiLoPerTableGeneratorTest.suite() );
- suite.addTest( UnionSubclassFilterTest.suite() );
- suite.addTest( JoinedSubclassFilterTest.suite() );
- suite.addTest( DiscrimSubclassFilterTest.suite() );
- suite.addTest( UnconstrainedTest.suite() );
- suite.addTest( RowIdTest.suite() );
- suite.addTest( OnDeleteTest.suite() );
- suite.addTest( OrderByTest.suite() );
- suite.addTest( SortTest.suite() );
- suite.addTest( WhereTest.suite() );
- suite.addTest( IterateTest.suite() );
- suite.addTest( RefreshTest.suite() );
- suite.addTest( ExtraLazyTest.suite() );
- suite.addTest( StatsTest.suite() );
- suite.addTest( SessionStatsTest.suite() );
- suite.addTest( ConnectionsSuite.suite() );
- suite.addTest( SQLExceptionConversionTest.suite() );
- suite.addTest( ValueVisitorTest.suite() );
- suite.addTest( PersistentClassVisitorTest.suite() );
- suite.addTest( AuctionTest.suite() );
- suite.addTest( AuctionTest2.suite() );
- suite.addTest( PaginationTest.suite() );
- suite.addTest( MappingExceptionTest.suite() );
- if ( InstrumentTest.isRunnable() ) {
- suite.addTest( InstrumentTest.suite() );
- }
- if ( LazyOneToOneTest.isRunnable() ) {
- suite.addTest( LazyOneToOneTest.suite() );
- }
- if ( InstrumentCacheTest.isRunnable() ) {
- suite.addTest( InstrumentCacheTest.suite() );
- }
- if ( InstrumentCacheTest2.isRunnable() ) {
- suite.addTest( InstrumentCacheTest2.suite() );
- }
- suite.addTest( CGLIBInstrumentationTest.suite() );
- suite.addTest( JavassistInstrumentationTest.suite() );
- suite.addTest( SybaseTimestampVersioningTest.suite() );
- suite.addTest( DbVersionTest.suite() );
- suite.addTest( GeneratedPropertySuite.suite() );
- suite.addTest( GeneratedKeysSuite.suite() );
- suite.addTest( InterceptorDynamicEntityTest.suite() );
- suite.addTest( TuplizerDynamicEntityTest.suite() );
- suite.addTest( BytecodeSuite.suite() );
- suite.addTest( JPAComplianceSuite.suite() );
- suite.addTest( AbstractComponentPropertyRefTest.suite() );
- suite.addTest( AbstractCompositeIdTest.suite() );
- suite.addTest( UtilSuite.suite() );
- suite.addTest( AnyTypeTest.suite() );
- suite.addTest( LobSuite.suite() );
- suite.addTest( IdentifierPropertyReferencesTest.suite() );
- suite.addTest( DeleteTransientEntityTest.suite() );
- suite.addTest( UserCollectionTypeSuite.suite() );
- suite.addTest( KeyManyToOneSuite.suite() );
- suite.addTest( DialectFunctionalTestsSuite.suite() );
- suite.addTest( DialectUnitTestsSuite.suite() );
- suite.addTest( InsertOrderingTest.suite() );
- suite.addTest( ReattachmentSuite.suite() );
-
- return suite;
- }
-
- /**
- * Runs the new test suite
- *
- * @param args n/a
- */
- public static void main(String[] args) {
- TestRunner.run( suite() );
- }
- }
-
- /**
- * An inner class representing the legacy test suite.
- */
- public static class LegacyTests {
-
- /**
- * Returns the legacy test suite
- *
- * @return the legacy test suite
- */
- public static Test suite() {
- return filter( ( TestSuite ) unfilteredSuite() );
- }
-
- /**
- * Returns the legacy test suite
- *
- * @return the legacy test suite
- */
- public static Test unfilteredSuite() {
- TestSuite suite = new TestSuite("Legacy tests suite");
- suite.addTest( FumTest.suite() );
- suite.addTest( MasterDetailTest.suite() );
- suite.addTest( ParentChildTest.suite() );
- suite.addTest( ABCTest.suite() );
- suite.addTest( ABCProxyTest.suite() );
- suite.addTest( SQLFunctionsTest.suite() );
- suite.addTest( SQLLoaderTest.suite() );
- suite.addTest( MultiTableTest.suite() );
- suite.addTest( MapTest.suite() );
- suite.addTest( QueryByExampleTest.suite() );
- suite.addTest( ComponentNotNullTest.suite() );
- suite.addTest( IJTest.suite() );
- suite.addTest( IJ2Test.suite() );
- suite.addTest( FooBarTest.suite() );
- suite.addTest( StatisticsTest.suite() );
- suite.addTest( CacheTest.suite() );
- suite.addTest( OneToOneCacheTest.suite() );
- suite.addTest( NonReflectiveBinderTest.suite() );
- suite.addTest( ConfigurationPerformanceTest.suite() ); // Added to ensure we can utilize the recommended performance tips ;)
- return suite;
- }
-
- /**
- * Run the legacy test suite
- *
- * @param args n/a
- */
- public static void main(String[] args) {
- TestRunner.run( suite() );
- }
- }
-
- private static TestSuite filter(TestSuite testSuite) {
- FilterHandler handler = new FilterHandler();
- TestSuiteVisitor visitor = new TestSuiteVisitor( handler );
- visitor.visit( testSuite );
- return handler.getFilteredTestSuite();
- }
-
- private static class TestSuiteStackEntry {
- public final TestSuite testSuite;
- public final TestSuiteStackEntry parentEntry;
-
- public TestSuiteStackEntry(TestSuite testSuite, TestSuiteStackEntry parentEntry) {
- this.testSuite = testSuite;
- this.parentEntry = parentEntry;
- if ( parentEntry != null ) {
- parentEntry.testSuite.addTest( testSuite );
- }
- }
- }
-
- private static class FilterHandler implements TestSuiteVisitor.Handler {
- private TestSuiteStackEntry topStackElement;
- private TestSuiteStackEntry currentStackElement;
- private Dialect dialect = Dialect.getDialect();
-
- public void handleTestCase(Test test) {
- if ( test instanceof TestCase ) {
- TestCase hibernateTestCase = ( TestCase ) test;
- if ( ! hibernateTestCase.appliesTo( dialect ) ) {
- System.out.println( "skipping test [" + hibernateTestCase.fullTestName() + "] for dialect [" + dialect.getClass().getName() + "]" );
- }
- else {
- currentStackElement.testSuite.addTest( test );
- }
- }
- else {
- currentStackElement.testSuite.addTest( test );
- }
- }
-
- public void startingTestSuite(TestSuite suite) {
- currentStackElement = new TestSuiteStackEntry( instantiateCopy( suite ), currentStackElement );
- if ( topStackElement == null ) {
- topStackElement = currentStackElement;
- }
- }
-
- public void completedTestSuite(TestSuite suite) {
- if ( currentStackElement != null ) {
- currentStackElement = currentStackElement.parentEntry;
- }
- }
-
- 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
Modified: trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/FailureExpectedCollector.java
===================================================================
--- trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/FailureExpectedCollector.java 2007-05-26 07:34:00 UTC (rev 11574)
+++ trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/FailureExpectedCollector.java 2007-05-26 07:34:56 UTC (rev 11575)
@@ -29,7 +29,8 @@
public static Set collectAllFailureExpectedTestNames() {
Set names = new HashSet();
- collectFailureExpectedTestNames( names, ( TestSuite ) AllTests.unfilteredSuite() );
+// todo : need to come up with a new scheme to do this...
+// collectFailureExpectedTestNames( names, ( TestSuite ) AllTests.unfilteredSuite() );
return names;
}
Deleted: trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/TestCase.java
===================================================================
--- trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/TestCase.java 2007-05-26 07:34:00 UTC (rev 11574)
+++ trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/TestCase.java 2007-05-26 07:34:56 UTC (rev 11575)
@@ -1,616 +0,0 @@
-//$Id: TestCase.java 10977 2006-12-12 23:28:04Z steve.ebersole at jboss.com $
-package org.hibernate.test;
-
-import java.sql.Blob;
-import java.sql.Clob;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.AssertionFailedError;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hibernate.HibernateException;
-import org.hibernate.Interceptor;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.cfg.Environment;
-import org.hibernate.dialect.DB2Dialect;
-import org.hibernate.dialect.Dialect;
-import org.hibernate.dialect.DerbyDialect;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.mapping.Collection;
-import org.hibernate.mapping.PersistentClass;
-import org.hibernate.mapping.Property;
-import org.hibernate.mapping.SimpleValue;
-
-public abstract class TestCase extends junit.framework.TestCase {
-
- private static SessionFactory sessions;
- private static Configuration cfg;
- private static Dialect dialect;
- private static Class lastTestClass;
- private org.hibernate.classic.Session session;
-
- public TestCase(String name) {
- super( name );
- }
-
-
- // methods for subclasses to change test environment ~~~~~~~~~~~~~~~~~~~~~~
-
- /**
- * Get the mapping resources to be used to build the configuration.
- * <p/>
- * Resources should be relative to {@link #getBaseForMappings()}
- *
- * @return The mapping resources
- */
- protected abstract String[] getMappings();
-
- /**
- * The base name for relative mapping resources. The default is
- * <tt>org/hibernate/test/</tt>
- *
- * @return the mapping resource base
- */
- protected String getBaseForMappings() {
- return "org/hibernate/test/";
- }
-
- /**
- * Should the database schema be (re)created
- *
- * @return True for auto export (including recreation on test failure).
- */
- protected boolean recreateSchema() {
- return true;
- }
-
- protected boolean dropAfterFailure() {
- return true;
- }
-
- /**
- * Apply any test-specific configuration prior to building the factory.
- *
- * @param cfg The configuration which will be used to construct the factory.
- */
- protected void configure(Configuration cfg) {
- }
-
- protected boolean overrideCacheStrategy() {
- return true;
- }
-
- protected String getCacheConcurrencyStrategy() {
- return "nonstrict-read-write";
- }
-
-
- // methods for subclasses to access environment ~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- /**
- * Get the factory for this test environment.
- *
- * @return The factory.
- */
- protected SessionFactory getSessions() {
- return sessions;
- }
-
- /**
- * Get the factory for this test environment, casted to {@link SessionFactoryImplementor}.
- * <p/>
- * Shorthand for ( {@link SessionFactoryImplementor} ) {@link #getSessions()}...
- *
- * @return The factory
- */
- protected SessionFactoryImplementor sfi() {
- return ( SessionFactoryImplementor ) getSessions();
- }
-
- protected Dialect getDialect() {
- if ( dialect == null ) {
- dialect = Dialect.getDialect();
- }
- return dialect;
- }
-
- protected Configuration getCfg() {
- return cfg;
- }
-
- 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;
- }
-
-
- // JUnit hooks ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- /**
- * The Hibernate test suite tries to only build the db schema once
- * per test class (not test case which = instance) hence all the
- * static vars.
- * <p/>
- * Here is the crux of that attempt. We only build a factory when one was
- * not previously built, or when we start a new test class.
- *
- * @throws Exception
- */
- protected void setUp() throws Exception {
- if ( getSessions() == null || lastTestClass != getClass() ) {
- buildSessionFactory();
- lastTestClass = getClass();
- }
- }
-
-
- private void buildSessionFactory() throws Exception {
- if ( getSessions()!=null ) {
- getSessions().close();
- }
-
- TestCase.dialect = Dialect.getDialect();
- if ( ! appliesTo( getDialect() ) ) {
- return;
- }
-
- try {
-
- TestCase.cfg = new Configuration();
- cfg.setProperty( Environment.CACHE_PROVIDER, "org.hibernate.cache.HashtableCacheProvider" );
- if( recreateSchema() ) {
- cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
- }
- addMappings( getMappings(), cfg );
- configure( cfg );
-
- if ( getCacheConcurrencyStrategy() != null ) {
- Iterator iter = cfg.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() && overrideCacheStrategy() ) {
- cfg.setCacheConcurrencyStrategy(
- clazz.getEntityName(),
- getCacheConcurrencyStrategy()
- );
- }
- }
- iter = cfg.getCollectionMappings();
- while ( iter.hasNext() ) {
- Collection coll = (Collection) iter.next();
- cfg.setCollectionCacheConcurrencyStrategy(
- coll.getRole(),
- getCacheConcurrencyStrategy()
- );
- }
- }
-
- // make sure we use the same dialect...
- cfg.setProperty( Environment.DIALECT, TestCase.dialect.getClass().getName() );
- TestCase.sessions = cfg.buildSessionFactory();
- afterSessionFactoryBuilt();
- }
- catch ( Exception e ) {
- e.printStackTrace();
- throw e;
- }
- }
-
- protected void addMappings(String[] files, Configuration cfg) {
- for ( int i = 0; i < files.length; i++ ) {
- if ( !files[i].startsWith( "net/" ) ) {
- files[i] = getBaseForMappings() + files[i];
- }
- cfg.addResource( files[i], TestCase.class.getClassLoader() );
- }
- }
-
- protected void afterSessionFactoryBuilt() throws Exception {
- // for subclasses to override in order to perform extra "stuff" only
- // when SF (re)built...
- }
-
- protected void runTest() throws Throwable {
- final boolean stats = sessions.getStatistics().isStatisticsEnabled();
- try {
- if ( stats ) {
- sessions.getStatistics().clear();
- }
-
- super.runTest();
-
- if ( stats ) {
- sessions.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 ( dropAfterFailure() && sessions != null ) {
- sessions.close();
- sessions = null;
- }
- }
- catch ( Exception ignore ) {
- }
- throw e;
- }
- }
-
- public void runBare() throws Throwable {
- String sysPropName = "hibernate.test.validatefailureexpected";
- assertNotNull( getName() );
- if ( Boolean.getBoolean( sysPropName ) ) {
- if ( getName().endsWith( "FailureExpected" ) ) {
- Throwable t = null;
- try {
- super.runBare();
- }
- catch ( Throwable afe ) {
- t = afe;
- }
- if ( t == null ) {
- fail( "Test where marked as FailureExpected, but did not fail!" );
- }
- else {
- reportSkip( "ignoring *FailuredExpected methods", "Failed with: " + t.toString() );
- }
- }
- else {
- super.runBare();
- }
- }
- else {
- super.runBare();
- }
- }
-
- protected void assertAllDataRemoved() {
- if ( !recreateSchema() ) {
- return; // no tables were created...
- }
- if ( !Boolean.getBoolean( "hibernate.test.validateDataCleanup" ) ) {
- return;
- }
-
- Session tmpSession = sessions.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
- }
- }
- }
-
- 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 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- protected static final Log SKIP_LOG = LogFactory.getLog("org.hibernate.test.SKIPPED");
-
- public String fullTestName() {
- return this.getName() + " (" + this.getClass().getName() + ")";
- }
-
- protected void reportSkip(String reason, String testDescription) {
- SKIP_LOG.warn( "*** skipping [" + fullTestName() + "] - " + testDescription + " : " + reason, new Exception() );
- }
-
- /**
- * 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 True if all the tests on this class apply to the given dialect (and
- * therefore should be run); false otherwise.
- */
- public boolean appliesTo(Dialect dialect) {
- return true;
- }
-
- /**
- * 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 );
- }
-
-}
\ No newline at end of file
Modified: trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/bytecode/cglib/InvocationTargetExceptionTest.java
===================================================================
--- trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/bytecode/cglib/InvocationTargetExceptionTest.java 2007-05-26 07:34:00 UTC (rev 11574)
+++ trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/bytecode/cglib/InvocationTargetExceptionTest.java 2007-05-26 07:34:56 UTC (rev 11575)
@@ -1,10 +1,8 @@
package org.hibernate.test.bytecode.cglib;
-import org.hibernate.test.TestCase;
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;
Modified: trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/connections/ConnectionManagementTestCase.java
===================================================================
--- trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/connections/ConnectionManagementTestCase.java 2007-05-26 07:34:00 UTC (rev 11574)
+++ trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/connections/ConnectionManagementTestCase.java 2007-05-26 07:34:56 UTC (rev 11575)
@@ -1,12 +1,9 @@
// $Id: ConnectionManagementTestCase.java 10977 2006-12-12 23:28:04Z steve.ebersole at jboss.com $
package org.hibernate.test.connections;
-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;
/**
@@ -110,8 +107,6 @@
/**
* Tests to validate that a session holding JDBC resources will not
* be allowed to serialize.
- *
- * @throws Throwable
*/
public final void testConnectedSerialization() throws Throwable {
prepare();
@@ -137,8 +132,6 @@
/**
* Test that a session which has been manually disconnected will be allowed
* to serialize.
- *
- * @throws Throwable
*/
public final void testManualDisconnectedSerialization() throws Throwable {
prepare();
@@ -156,8 +149,6 @@
/**
* Test that the legacy manual disconnect()/reconnect() chain works as
* expected in the given environment.
- *
- * @throws Throwable
*/
public final void testManualDisconnectChain() throws Throwable {
prepare();
@@ -185,8 +176,6 @@
* expected in the given environment. Similiar to {@link #testManualDisconnectChain}
* expect that here we force the session to acquire and hold JDBC resources
* prior to disconnecting.
- *
- * @throws Throwable
*/
public final void testManualDisconnectWithOpenResources() throws Throwable {
prepare();
@@ -220,8 +209,6 @@
/**
* Test that the basic session usage template works in all environment
* scenarios.
- *
- * @throws Throwable
*/
public void testBasicSessionUsage() throws Throwable {
prepare();
@@ -256,8 +243,6 @@
/**
* Test that session-closed protections work properly in all environments.
- *
- * @throws Throwable
*/
public void testSessionClosedProtections() throws Throwable {
prepare();
Modified: trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/dynamicentity/tuplizer/TuplizerDynamicEntityTest.java
===================================================================
--- trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/dynamicentity/tuplizer/TuplizerDynamicEntityTest.java 2007-05-26 07:34:00 UTC (rev 11574)
+++ trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/dynamicentity/tuplizer/TuplizerDynamicEntityTest.java 2007-05-26 07:34:56 UTC (rev 11575)
@@ -1,6 +1,5 @@
package org.hibernate.test.dynamicentity.tuplizer;
-import org.hibernate.test.TestCase;
import org.hibernate.test.dynamicentity.Company;
import org.hibernate.test.dynamicentity.ProxyHelper;
import org.hibernate.test.dynamicentity.Customer;
Deleted: trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/hql/ASTQueryTranslatorTest.java
===================================================================
--- trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/hql/ASTQueryTranslatorTest.java 2007-05-26 07:34:00 UTC (rev 11574)
+++ trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/hql/ASTQueryTranslatorTest.java 2007-05-26 07:34:56 UTC (rev 11575)
@@ -1,176 +0,0 @@
-// $Id: ASTQueryTranslatorTest.java 8889 2005-12-20 17:35:54Z steveebersole $
-package org.hibernate.test.hql;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * Tests cases where the AST based QueryTranslator does not generate identical SQL.
- *
- * @author josh Dec 6, 2004 9:07:58 AM
- */
-public class ASTQueryTranslatorTest extends QueryTranslatorTestCase {
-
- public ASTQueryTranslatorTest(String x) {
- super( x );
- }
-
- public static Test suite() {
- return new TestSuite( ASTQueryTranslatorTest.class );
- }
-
- protected boolean dropAfterFailure() {
- return false;
- }
-
- // ##### TESTS THAT DON'T PASS BECAUSE THEY GENERATE DIFFERENT, POSSIBLY VALID SQL #####
-
- public void testSelectManyToOne() {
- assertTranslation("select distinct a.zoo from Animal a where a.zoo is not null");
- assertTranslation("select a.zoo from Animal a");
- }
-
- public void testSelectExpression() {
- //old qt cant handle select-clause expressions
- assertTranslation("select a.bodyWeight + m.bodyWeight from Animal a join a.mother m");
- }
-
- public void testFetchProperties() {
- //not implemented in old qt
- assertTranslation("from Animal a fetch all properties join a.offspring o fetch all properties");
- }
-
- public void testOldSyntax() {
- //generates ANSI join instead of theta join
- assertTranslation("from a in class Animal, o in elements(a.offspring), h in class Human");
- }
-
- public void testImplicitJoinInsideOutsideSubselect() {
- // new qt re-uses the joins defined by 's.other.count' path when referenced in the subquery,
- // whereas the old qt reuses only the "root table" (not the already defined join to 'other'):
- // OLD SQL :
- // select simple0_.id_ as col_0_0_
- // from Simple simple0_,
- // Simple simple1_
- // where (simple1_.count_>0
- // and simple0_.other=simple1_.id_)
- // and (simple0_.id_=some(
- // select simple2_.id_
- // from Simple simple2_,
- // Simple simple3_,
- // Simple simple4_
- // where (simple3_.count_=simple4_.count_
- // and simple2_.other=simple3_.id_
- // and simple0_.other=simple4_.id_)
- // ))
- // NEW SQL :
- // select simple0_.id_ as col_0_0_
- // from Simple simple0_,
- // Simple simple1_
- // where (simple1_.count_>0
- // and simple0_.id_=some(
- // select simple2_.id_
- // from Simple simple2_,
- // Simple simple3_
- // where (simple3_.count_=simple1_.count_
- // and simple2_.other=simple3_.id_)
- // )
- // and simple0_.other=simple1_.id_)
- assertTranslation( "from Simple s where s = some( from Simple sim where sim.other.count=s.other.count ) and s.other.count > 0" );
- assertTranslation( "from Simple s where s.other.count > 0 and s = some( from Simple sim where sim.other.count=s.other.count )" );
- }
-
- public void testNakedPropertyRef() {
- // this is needed for ejb3 selects and bulk statements
- // Note: these all fail because the old parser did not have this
- // feature, it just "passes the tokens through" to the SQL.
- assertTranslation( "from Animal where bodyWeight = bodyWeight" );
- assertTranslation( "select bodyWeight from Animal" );
- assertTranslation( "select max(bodyWeight) from Animal" );
- }
-
- public void testNakedComponentPropertyRef() {
- // this is needed for ejb3 selects and bulk statements
- // Note: these all fail because the old parser did not have this
- // feature, it just "passes the tokens through" to the SQL.
- assertTranslation( "from Human where name.first = 'Gavin'" );
- assertTranslation( "select name from Human" );
- assertTranslation( "select upper(h.name.first) from Human as h" );
- assertTranslation( "select upper(name.first) from Human" );
- }
-
- public void testNakedMapIndex() throws Exception {
- assertTranslation( "from Zoo where mammals['dog'].description like '%black%'" );
- }
-
- public void testNakedImplicitJoins() {
- assertTranslation( "from Animal where mother.father = ?" );
- }
-
- public void testDuplicateImplicitJoinInWhere() {
- //new qt has more organized joins
- assertTranslation("from Human h where h.mother.bodyWeight>10 and h.mother.bodyWeight<10");
- }
-
- public void testWhereExpressions() {
- assertTranslation("from User u where u.userName='gavin' and u.human.name.first='Gavin'");
- //new qt has more organized joins
- assertTranslation("from User u where u.human.name.last='King' and u.human.name.first='Gavin'");
- assertTranslation("from Bar bar where bar.baz.name='josh'");
- assertTranslation("from Bar bar where bar.baz.name='josh' and not bar.baz.name='gavin'");
- }
-
- public void testImplicitJoinInSelect() {
- //slightly diff select clause, both correct
- assertTranslation("select foo.long, foo.foo from Foo foo");
- }
-
- public void testSelectStandardFunctions() throws Exception {
- //old parser throws an exception
- assertTranslation( "select current_date(), current_time(), current_timestamp() from Animal" );
- }
-
- public void testSelectClauseImplicitJoin() throws Exception {
- //the old query translator has a bug which results in the wrong return type!
- assertTranslation( "select d.owner.mother from Dog d" );
- }
-
- public void testComplexWhereExpression() throws Exception {
- // classic QT generates lots of extra parens and some extra theta joins.
- assertTranslation( "select distinct s from Simple s\n" +
- "where ( ( s.other.count + 3 ) = (15*2)/2 and s.count = 69) or ( ( s.other.count + 2 ) / 7 ) = 2" );
- }
-
- public void testDuplicateImplicitJoin() throws Exception {
- // old qt generates an extra theta join
- assertTranslation( "from Animal an where an.mother.bodyWeight > 10 and an.mother.bodyWeight < 20" );
- }
-
- public void testKeywordClassNameAndAlias() throws Exception {
- // The old QT throws an exception, the new one doesn't, which is better
- assertTranslation( "from Order order" );
- }
-
- public void testComponent3() throws Exception {
- // The old translator generates duplicate inner joins *and* duplicate theta join clauses in the where statement in this case.
- assertTranslation( "from Dog dog where dog.owner.name.first = 'Gavin' and dog.owner.name.last='King' and dog.owner.bodyWeight<70" );
- }
-
- public void testUncorrelatedSubselectWithJoin() throws Exception {
- // The old translator generates unnecessary inner joins for the Animal subclass of zoo.mammals
- // The new one is working fine now!
- assertTranslation( "from Animal a where a in (select mam from Zoo zoo join zoo.mammals mam)" );
- }
-
- public void testFetch() throws Exception {
- //SQL is correct, new qt is not throwing an exception when it should be (minor issue)
- assertTranslation("from Customer cust left join fetch cust.billingAddress where cust.customerId='abc123'");
- }
-
- public void testImplicitJoin() throws Exception {
- //old qt generates an exception, the new one doesnt
- //this is actually invalid HQL, an implicit join on a many-valued association
- assertTranslation( "from Animal an where an.offspring.mother.bodyWeight > 10" );
- }
-
-}
Modified: trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/hql/EJBQLTest.java
===================================================================
--- trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/hql/EJBQLTest.java 2007-05-26 07:34:00 UTC (rev 11574)
+++ trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/hql/EJBQLTest.java 2007-05-26 07:34:56 UTC (rev 11575)
@@ -7,9 +7,7 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.hql.QueryTranslator;
import org.hibernate.hql.QueryTranslatorFactory;
import org.hibernate.hql.antlr.HqlSqlTokenTypes;
@@ -17,7 +15,6 @@
import org.hibernate.hql.ast.HqlParser;
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;
Modified: trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/hql/WithClauseTest.java
===================================================================
--- trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/hql/WithClauseTest.java 2007-05-26 07:34:00 UTC (rev 11574)
+++ trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/hql/WithClauseTest.java 2007-05-26 07:34:56 UTC (rev 11575)
@@ -1,42 +1,40 @@
// $Id: WithClauseTest.java 10945 2006-12-07 14:50:42Z steve.ebersole at jboss.com $
package org.hibernate.test.hql;
-import org.hibernate.test.TestCase;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.hibernate.HibernateException;
-import org.hibernate.QueryException;
-import org.hibernate.hql.ast.InvalidWithClauseException;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.cfg.Environment;
-
-import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.HibernateException;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.hql.ast.InvalidWithClauseException;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+
/**
* Implementation of WithClauseTest.
*
* @author Steve Ebersole
*/
-public class WithClauseTest extends TestCase {
+public class WithClauseTest extends FunctionalTestCase {
public WithClauseTest(String name) {
super( name );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "hql/Animal.hbm.xml" };
}
public static Test suite() {
- return new TestSuite( WithClauseTest.class );
+ return new FunctionalTestClassTestSuite( WithClauseTest.class );
}
- protected void configure(Configuration cfg) {
+ public void configure(Configuration cfg) {
super.configure( cfg );
}
Modified: trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/id/UseIdentifierRollbackTest.java
===================================================================
--- trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/id/UseIdentifierRollbackTest.java 2007-05-26 07:34:00 UTC (rev 11574)
+++ trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/id/UseIdentifierRollbackTest.java 2007-05-26 07:34:56 UTC (rev 11575)
@@ -1,18 +1,19 @@
//$Id: $
package org.hibernate.test.id;
-import org.hibernate.test.TestCase;
+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.Session;
-import org.hibernate.Transaction;
-import junit.framework.Test;
/**
* @author Emmanuel Bernard
*/
-public class UseIdentifierRollbackTest extends TestCase {
+public class UseIdentifierRollbackTest extends FunctionalTestCase {
public UseIdentifierRollbackTest(String str) {
super(str);
}
Modified: trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/instrument/cases/TestLazyExecutable.java
===================================================================
--- trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/instrument/cases/TestLazyExecutable.java 2007-05-26 07:34:00 UTC (rev 11574)
+++ trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/instrument/cases/TestLazyExecutable.java 2007-05-26 07:34:56 UTC (rev 11575)
@@ -1,16 +1,16 @@
package org.hibernate.test.instrument.cases;
-import org.hibernate.test.TestCase;
-import org.hibernate.test.instrument.cases.AbstractExecutable;
-import org.hibernate.test.instrument.domain.Owner;
-import org.hibernate.test.instrument.domain.Document;
-import org.hibernate.test.instrument.domain.Folder;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
+import junit.framework.TestCase;
+
+import org.hibernate.CacheMode;
import org.hibernate.Hibernate;
import org.hibernate.LockMode;
-import org.hibernate.CacheMode;
+import org.hibernate.Session;
import org.hibernate.SessionFactory;
+import org.hibernate.Transaction;
+import org.hibernate.test.instrument.domain.Document;
+import org.hibernate.test.instrument.domain.Folder;
+import org.hibernate.test.instrument.domain.Owner;
/**
* @author Steve Ebersole
Modified: trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/jpa/AbstractJPATest.java
===================================================================
--- trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/jpa/AbstractJPATest.java 2007-05-26 07:34:00 UTC (rev 11574)
+++ trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/jpa/AbstractJPATest.java 2007-05-26 07:34:56 UTC (rev 11575)
@@ -1,6 +1,5 @@
package org.hibernate.test.jpa;
-import org.hibernate.test.TestCase;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.proxy.EntityNotFoundDelegate;
Modified: trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/keymanytoone/bidir/component/EagerKeyManyToOneTest.java
===================================================================
--- trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/keymanytoone/bidir/component/EagerKeyManyToOneTest.java 2007-05-26 07:34:00 UTC (rev 11574)
+++ trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/keymanytoone/bidir/component/EagerKeyManyToOneTest.java 2007-05-26 07:34:56 UTC (rev 11575)
@@ -2,34 +2,34 @@
import junit.framework.Test;
+import org.hibernate.HibernateException;
import org.hibernate.Session;
-import org.hibernate.HibernateException;
-import org.hibernate.event.def.DefaultLoadEventListener;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
import org.hibernate.event.LoadEvent;
import org.hibernate.event.LoadEventListener;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.cfg.Environment;
+import org.hibernate.event.def.DefaultLoadEventListener;
+import org.hibernate.junit.functional.FunctionalTestCase;
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
-import org.hibernate.test.TestCase;
/**
* @author Steve Ebersole
*/
-public class EagerKeyManyToOneTest extends TestCase {
+public class EagerKeyManyToOneTest extends FunctionalTestCase {
public EagerKeyManyToOneTest(String name) {
super( name );
}
- protected String[] getMappings() {
- return new String[] { "keymanytoone/bidir/component/EagerMapping.hbm.xml" };
- }
-
public static Test suite() {
return new FunctionalTestClassTestSuite( EagerKeyManyToOneTest.class );
}
- protected void configure(Configuration cfg) {
+ public String[] getMappings() {
+ return new String[] { "keymanytoone/bidir/component/EagerMapping.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
super.configure( cfg );
cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
LoadEventListener[] baseListeners = cfg.getEventListeners().getLoadEventListeners();
Modified: trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/keymanytoone/bidir/component/LazyKeyManyToOneTest.java
===================================================================
--- trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/keymanytoone/bidir/component/LazyKeyManyToOneTest.java 2007-05-26 07:34:00 UTC (rev 11574)
+++ trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/keymanytoone/bidir/component/LazyKeyManyToOneTest.java 2007-05-26 07:34:56 UTC (rev 11575)
@@ -2,29 +2,29 @@
import junit.framework.Test;
-import org.hibernate.test.TestCase;
-import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.Session;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
-import org.hibernate.Session;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Steve Ebersole
*/
-public class LazyKeyManyToOneTest extends TestCase {
+public class LazyKeyManyToOneTest extends FunctionalTestCase {
public LazyKeyManyToOneTest(String name) {
super( name );
}
- protected String[] getMappings() {
- return new String[] { "keymanytoone/bidir/component/LazyMapping.hbm.xml" };
- }
-
public static Test suite() {
return new FunctionalTestClassTestSuite( LazyKeyManyToOneTest.class );
}
- protected void configure(Configuration cfg) {
+ public String[] getMappings() {
+ return new String[] { "keymanytoone/bidir/component/LazyMapping.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
super.configure( cfg );
cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
}
Modified: trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/keymanytoone/bidir/embedded/KeyManyToOneTest.java
===================================================================
--- trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/keymanytoone/bidir/embedded/KeyManyToOneTest.java 2007-05-26 07:34:00 UTC (rev 11574)
+++ trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/keymanytoone/bidir/embedded/KeyManyToOneTest.java 2007-05-26 07:34:56 UTC (rev 11575)
@@ -2,29 +2,29 @@
import junit.framework.Test;
-import org.hibernate.test.TestCase;
import org.hibernate.Session;
-import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Steve Ebersole
*/
-public class KeyManyToOneTest extends TestCase {
+public class KeyManyToOneTest extends FunctionalTestCase {
public KeyManyToOneTest(String name) {
super( name );
}
- protected String[] getMappings() {
- return new String[] { "keymanytoone/bidir/embedded/Mapping.hbm.xml" };
- }
-
public static Test suite() {
return new FunctionalTestClassTestSuite( KeyManyToOneTest.class );
}
- protected void configure(Configuration cfg) {
+ public String[] getMappings() {
+ return new String[] { "keymanytoone/bidir/embedded/Mapping.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
super.configure( cfg );
cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
}
Modified: trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/lazycache/InstrumentCacheTest.java
===================================================================
--- trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/lazycache/InstrumentCacheTest.java 2007-05-26 07:34:00 UTC (rev 11574)
+++ trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/lazycache/InstrumentCacheTest.java 2007-05-26 07:34:56 UTC (rev 11575)
@@ -8,19 +8,33 @@
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
+import org.hibernate.dialect.Dialect;
import org.hibernate.intercept.FieldInterceptionHelper;
-import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.DatabaseSpecificFunctionalTestCase;
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class InstrumentCacheTest extends FunctionalTestCase {
+public class InstrumentCacheTest extends DatabaseSpecificFunctionalTestCase {
public InstrumentCacheTest(String str) {
super(str);
}
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( InstrumentCacheTest.class );
+ }
+
+ private boolean isRunnable() {
+ // skip this test if document is not instrumented/enhanced
+ return FieldInterceptionHelper.isInstrumented( new Document() );
+ }
+
+ public boolean appliesTo(Dialect dialect) {
+ return isRunnable();
+ }
+
public String[] getMappings() {
return new String[] { "lazycache/Documents.hbm.xml" };
}
@@ -33,16 +47,11 @@
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() {
+ if ( !isRunnable() ) {
+ reportSkip( "classes not instrumented", "instrumentation tests" );
+ return;
+ }
Session s;
Transaction tx;
@@ -82,5 +91,49 @@
s.close();
}
+ public void testInitFromCache2() {
+ if ( !isRunnable() ) {
+ reportSkip( "classes not instrumented", "instrumentation tests" );
+ return;
+ }
+ Session s;
+ Transaction tx;
+
+ s = getSessions().openSession();
+ tx = s.beginTransaction();
+ s.persist( new Document("HiA", "Hibernate book", "Hibernate is....") );
+ tx.commit();
+ s.close();
+
+ s = getSessions().openSession();
+ tx = s.beginTransaction();
+ s.createQuery("from Document fetch all properties").uniqueResult();
+ tx.commit();
+ s.close();
+
+ getSessions().getStatistics().clear();
+
+ s = getSessions().openSession();
+ tx = s.beginTransaction();
+ Document d = (Document) s.createCriteria(Document.class).uniqueResult();
+ assertFalse( Hibernate.isPropertyInitialized(d, "text") );
+ assertFalse( Hibernate.isPropertyInitialized(d, "summary") );
+ assertEquals( "Hibernate is....", d.getText() );
+ assertTrue( Hibernate.isPropertyInitialized(d, "text") );
+ assertTrue( Hibernate.isPropertyInitialized(d, "summary") );
+ tx.commit();
+ s.close();
+
+ assertEquals( 1, getSessions().getStatistics().getPrepareStatementCount() );
+
+ s = getSessions().openSession();
+ tx = s.beginTransaction();
+ d = (Document) s.get(Document.class, d.getId());
+ assertTrue( Hibernate.isPropertyInitialized(d, "text") );
+ assertTrue( Hibernate.isPropertyInitialized(d, "summary") );
+ tx.commit();
+ s.close();
+ }
+
}
Deleted: trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/lazycache/InstrumentCacheTest2.java
===================================================================
--- trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/lazycache/InstrumentCacheTest2.java 2007-05-26 07:34:00 UTC (rev 11574)
+++ trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/lazycache/InstrumentCacheTest2.java 2007-05-26 07:34:56 UTC (rev 11575)
@@ -1,81 +0,0 @@
-//$Id: InstrumentCacheTest2.java 10977 2006-12-12 23:28:04Z steve.ebersole at jboss.com $
-package org.hibernate.test.lazycache;
-
-import junit.framework.Test;
-
-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.intercept.FieldInterceptionHelper;
-import org.hibernate.junit.functional.FunctionalTestCase;
-import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
-
-/**
- * @author Gavin King
- */
-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;
-
- s = getSessions().openSession();
- tx = s.beginTransaction();
- s.persist( new Document("HiA", "Hibernate book", "Hibernate is....") );
- tx.commit();
- s.close();
-
- s = getSessions().openSession();
- tx = s.beginTransaction();
- s.createQuery("from Document fetch all properties").uniqueResult();
- tx.commit();
- s.close();
-
- getSessions().getStatistics().clear();
-
- s = getSessions().openSession();
- tx = s.beginTransaction();
- Document d = (Document) s.createCriteria(Document.class).uniqueResult();
- assertFalse( Hibernate.isPropertyInitialized(d, "text") );
- assertFalse( Hibernate.isPropertyInitialized(d, "summary") );
- assertEquals( "Hibernate is....", d.getText() );
- assertTrue( Hibernate.isPropertyInitialized(d, "text") );
- assertTrue( Hibernate.isPropertyInitialized(d, "summary") );
- tx.commit();
- s.close();
-
- assertEquals( 1, getSessions().getStatistics().getPrepareStatementCount() );
-
- s = getSessions().openSession();
- tx = s.beginTransaction();
- d = (Document) s.get(Document.class, d.getId());
- assertTrue( Hibernate.isPropertyInitialized(d, "text") );
- assertTrue( Hibernate.isPropertyInitialized(d, "summary") );
- tx.commit();
- s.close();
- }
-
-}
-
Modified: trunk/Hibernate3/testsuite/src/test/resources/log4j.properties
===================================================================
--- trunk/Hibernate3/testsuite/src/test/resources/log4j.properties 2007-05-26 07:34:00 UTC (rev 11574)
+++ trunk/Hibernate3/testsuite/src/test/resources/log4j.properties 2007-05-26 07:34:56 UTC (rev 11575)
@@ -1,41 +1,9 @@
-### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
-### set log levels - for more verbose logging change 'info' to 'debug' ###
log4j.rootLogger=warn, stdout
-log4j.logger.org.hibernate=info
-#log4j.logger.org.hibernate=debug
-
-### log HQL query parser activity
-#log4j.logger.org.hibernate.hql.ast.AST=debug
-
-### log just the SQL
-#log4j.logger.org.hibernate.SQL=debug
-
-### log JDBC bind parameters ###
-log4j.logger.org.hibernate.type=info
-#log4j.logger.org.hibernate.type=debug
-
-### log schema export/update ###
-log4j.logger.org.hibernate.tool.hbm2ddl=debug
-
-### log HQL parse trees
-#log4j.logger.org.hibernate.hql=debug
-
-### log cache activity ###
-#log4j.logger.org.hibernate.cache=debug
-
-### log transaction activity
-#log4j.logger.org.hibernate.transaction=debug
-
-### log JDBC resource acquisition
-#log4j.logger.org.hibernate.jdbc=debug
-
-### enable the following line if you want to track down connection ###
-### leakages when using DriverManagerConnectionProvider ###
-#log4j.logger.org.hibernate.connection.DriverManagerConnectionProvider=trace
+log4j.logger.org.hibernate.test=info
\ No newline at end of file
Copied: trunk/Hibernate3/testsuite/src/test/unmaintained/org/hibernate/test/hql/ASTQueryTranslatorTest.java (from rev 11563, trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/hql/ASTQueryTranslatorTest.java)
===================================================================
--- trunk/Hibernate3/testsuite/src/test/unmaintained/org/hibernate/test/hql/ASTQueryTranslatorTest.java (rev 0)
+++ trunk/Hibernate3/testsuite/src/test/unmaintained/org/hibernate/test/hql/ASTQueryTranslatorTest.java 2007-05-26 07:34:56 UTC (rev 11575)
@@ -0,0 +1,176 @@
+// $Id: ASTQueryTranslatorTest.java 8889 2005-12-20 17:35:54Z steveebersole $
+package org.hibernate.test.hql;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Tests cases where the AST based QueryTranslator does not generate identical SQL.
+ *
+ * @author josh Dec 6, 2004 9:07:58 AM
+ */
+public class ASTQueryTranslatorTest extends QueryTranslatorTestCase {
+
+ public ASTQueryTranslatorTest(String x) {
+ super( x );
+ }
+
+ public static Test suite() {
+ return new TestSuite( ASTQueryTranslatorTest.class );
+ }
+
+ protected boolean dropAfterFailure() {
+ return false;
+ }
+
+ // ##### TESTS THAT DON'T PASS BECAUSE THEY GENERATE DIFFERENT, POSSIBLY VALID SQL #####
+
+ public void testSelectManyToOne() {
+ assertTranslation("select distinct a.zoo from Animal a where a.zoo is not null");
+ assertTranslation("select a.zoo from Animal a");
+ }
+
+ public void testSelectExpression() {
+ //old qt cant handle select-clause expressions
+ assertTranslation("select a.bodyWeight + m.bodyWeight from Animal a join a.mother m");
+ }
+
+ public void testFetchProperties() {
+ //not implemented in old qt
+ assertTranslation("from Animal a fetch all properties join a.offspring o fetch all properties");
+ }
+
+ public void testOldSyntax() {
+ //generates ANSI join instead of theta join
+ assertTranslation("from a in class Animal, o in elements(a.offspring), h in class Human");
+ }
+
+ public void testImplicitJoinInsideOutsideSubselect() {
+ // new qt re-uses the joins defined by 's.other.count' path when referenced in the subquery,
+ // whereas the old qt reuses only the "root table" (not the already defined join to 'other'):
+ // OLD SQL :
+ // select simple0_.id_ as col_0_0_
+ // from Simple simple0_,
+ // Simple simple1_
+ // where (simple1_.count_>0
+ // and simple0_.other=simple1_.id_)
+ // and (simple0_.id_=some(
+ // select simple2_.id_
+ // from Simple simple2_,
+ // Simple simple3_,
+ // Simple simple4_
+ // where (simple3_.count_=simple4_.count_
+ // and simple2_.other=simple3_.id_
+ // and simple0_.other=simple4_.id_)
+ // ))
+ // NEW SQL :
+ // select simple0_.id_ as col_0_0_
+ // from Simple simple0_,
+ // Simple simple1_
+ // where (simple1_.count_>0
+ // and simple0_.id_=some(
+ // select simple2_.id_
+ // from Simple simple2_,
+ // Simple simple3_
+ // where (simple3_.count_=simple1_.count_
+ // and simple2_.other=simple3_.id_)
+ // )
+ // and simple0_.other=simple1_.id_)
+ assertTranslation( "from Simple s where s = some( from Simple sim where sim.other.count=s.other.count ) and s.other.count > 0" );
+ assertTranslation( "from Simple s where s.other.count > 0 and s = some( from Simple sim where sim.other.count=s.other.count )" );
+ }
+
+ public void testNakedPropertyRef() {
+ // this is needed for ejb3 selects and bulk statements
+ // Note: these all fail because the old parser did not have this
+ // feature, it just "passes the tokens through" to the SQL.
+ assertTranslation( "from Animal where bodyWeight = bodyWeight" );
+ assertTranslation( "select bodyWeight from Animal" );
+ assertTranslation( "select max(bodyWeight) from Animal" );
+ }
+
+ public void testNakedComponentPropertyRef() {
+ // this is needed for ejb3 selects and bulk statements
+ // Note: these all fail because the old parser did not have this
+ // feature, it just "passes the tokens through" to the SQL.
+ assertTranslation( "from Human where name.first = 'Gavin'" );
+ assertTranslation( "select name from Human" );
+ assertTranslation( "select upper(h.name.first) from Human as h" );
+ assertTranslation( "select upper(name.first) from Human" );
+ }
+
+ public void testNakedMapIndex() throws Exception {
+ assertTranslation( "from Zoo where mammals['dog'].description like '%black%'" );
+ }
+
+ public void testNakedImplicitJoins() {
+ assertTranslation( "from Animal where mother.father = ?" );
+ }
+
+ public void testDuplicateImplicitJoinInWhere() {
+ //new qt has more organized joins
+ assertTranslation("from Human h where h.mother.bodyWeight>10 and h.mother.bodyWeight<10");
+ }
+
+ public void testWhereExpressions() {
+ assertTranslation("from User u where u.userName='gavin' and u.human.name.first='Gavin'");
+ //new qt has more organized joins
+ assertTranslation("from User u where u.human.name.last='King' and u.human.name.first='Gavin'");
+ assertTranslation("from Bar bar where bar.baz.name='josh'");
+ assertTranslation("from Bar bar where bar.baz.name='josh' and not bar.baz.name='gavin'");
+ }
+
+ public void testImplicitJoinInSelect() {
+ //slightly diff select clause, both correct
+ assertTranslation("select foo.long, foo.foo from Foo foo");
+ }
+
+ public void testSelectStandardFunctions() throws Exception {
+ //old parser throws an exception
+ assertTranslation( "select current_date(), current_time(), current_timestamp() from Animal" );
+ }
+
+ public void testSelectClauseImplicitJoin() throws Exception {
+ //the old query translator has a bug which results in the wrong return type!
+ assertTranslation( "select d.owner.mother from Dog d" );
+ }
+
+ public void testComplexWhereExpression() throws Exception {
+ // classic QT generates lots of extra parens and some extra theta joins.
+ assertTranslation( "select distinct s from Simple s\n" +
+ "where ( ( s.other.count + 3 ) = (15*2)/2 and s.count = 69) or ( ( s.other.count + 2 ) / 7 ) = 2" );
+ }
+
+ public void testDuplicateImplicitJoin() throws Exception {
+ // old qt generates an extra theta join
+ assertTranslation( "from Animal an where an.mother.bodyWeight > 10 and an.mother.bodyWeight < 20" );
+ }
+
+ public void testKeywordClassNameAndAlias() throws Exception {
+ // The old QT throws an exception, the new one doesn't, which is better
+ assertTranslation( "from Order order" );
+ }
+
+ public void testComponent3() throws Exception {
+ // The old translator generates duplicate inner joins *and* duplicate theta join clauses in the where statement in this case.
+ assertTranslation( "from Dog dog where dog.owner.name.first = 'Gavin' and dog.owner.name.last='King' and dog.owner.bodyWeight<70" );
+ }
+
+ public void testUncorrelatedSubselectWithJoin() throws Exception {
+ // The old translator generates unnecessary inner joins for the Animal subclass of zoo.mammals
+ // The new one is working fine now!
+ assertTranslation( "from Animal a where a in (select mam from Zoo zoo join zoo.mammals mam)" );
+ }
+
+ public void testFetch() throws Exception {
+ //SQL is correct, new qt is not throwing an exception when it should be (minor issue)
+ assertTranslation("from Customer cust left join fetch cust.billingAddress where cust.customerId='abc123'");
+ }
+
+ public void testImplicitJoin() throws Exception {
+ //old qt generates an exception, the new one doesnt
+ //this is actually invalid HQL, an implicit join on a many-valued association
+ assertTranslation( "from Animal an where an.offspring.mother.bodyWeight > 10" );
+ }
+
+}
More information about the hibernate-commits
mailing list