HHH-5942 - Migrate to JUnit 4

This commit is contained in:
Steve Ebersole 2011-03-12 12:19:56 -06:00
parent a6f8767a3c
commit 1c203f35ec
68 changed files with 1782 additions and 1746 deletions

View File

@ -70,7 +70,7 @@ libraries = [
// testing
atomikos: 'com.atomikos:transactions-jdbc:3.7.0',
junit: 'junit:junit:3.8.2',
junit: 'junit:junit:4.8.2',
testng: 'org.testng:testng:5.8:jdk15',
jpa_modelgen: 'org.hibernate:hibernate-jpamodelgen:1.1.1.Final',
shrinkwrap_api: 'org.jboss.shrinkwrap:shrinkwrap-api:1.0.0-alpha-6',

View File

@ -69,7 +69,7 @@ public class SequenceHiLoGeneratorNoIncrementTest extends BaseUnitTestCase {
private SequenceHiLoGenerator generator;
@Before
protected void setUp() throws Exception {
public void setUp() throws Exception {
Properties properties = new Properties();
properties.setProperty( SequenceGenerator.SEQUENCE, TEST_SEQUENCE );
properties.setProperty( SequenceHiLoGenerator.MAX_LO, "0" ); // JPA allocationSize of 1
@ -107,7 +107,7 @@ public class SequenceHiLoGeneratorNoIncrementTest extends BaseUnitTestCase {
}
@After
protected void tearDown() throws Exception {
public void tearDown() throws Exception {
if ( sessionFactory != null ) {
sessionFactory.close();
}

View File

@ -1,7 +1,7 @@
//$Id$
package org.hibernate.test.annotations.backquotes;
import static org.hibernate.TestLogger.LOG;
import static org.hibernate.testing.TestLogger.LOG;
import java.io.PrintWriter;
import java.io.StringWriter;
import junit.framework.TestCase;

View File

@ -26,7 +26,7 @@
package org.hibernate.test.annotations.fetchprofile;
import static org.hibernate.TestLogger.LOG;
import static org.hibernate.testing.TestLogger.LOG;
import java.io.InputStream;
import junit.framework.TestCase;
import org.hibernate.MappingException;

View File

@ -1,7 +1,7 @@
// $Id$
package org.hibernate.test.annotations.fkcircularity;
import static org.hibernate.TestLogger.LOG;
import static org.hibernate.testing.TestLogger.LOG;
import java.io.PrintWriter;
import java.io.StringWriter;
import junit.framework.TestCase;

View File

@ -1,6 +1,6 @@
//$Id$
package org.hibernate.test.annotations.id;
import static org.hibernate.TestLogger.LOG;
import static org.hibernate.testing.TestLogger.LOG;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.test.annotations.TestCase;

View File

@ -1,6 +1,6 @@
//$Id$
package org.hibernate.test.annotations.id;
import static org.hibernate.TestLogger.LOG;
import static org.hibernate.testing.TestLogger.LOG;
import java.io.PrintWriter;
import java.io.StringWriter;
import org.hibernate.cfg.AnnotationConfiguration;

View File

@ -1,6 +1,6 @@
//$Id$
package org.hibernate.test.annotations.id.sequences;
import static org.hibernate.TestLogger.LOG;
import static org.hibernate.testing.TestLogger.LOG;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.test.annotations.TestCase;

View File

@ -1,6 +1,6 @@
//$Id$
package org.hibernate.test.annotations.id.sequences;
import static org.hibernate.TestLogger.LOG;
import static org.hibernate.testing.TestLogger.LOG;
import java.io.PrintWriter;
import java.io.StringWriter;
import org.hibernate.cfg.AnnotationConfiguration;

View File

@ -1,6 +1,6 @@
//$Id$
package org.hibernate.test.annotations.immutable;
import static org.hibernate.TestLogger.LOG;
import static org.hibernate.testing.TestLogger.LOG;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.AnnotationException;

View File

@ -1,7 +1,7 @@
// $Id$
package org.hibernate.test.annotations.namingstrategy;
import static org.hibernate.TestLogger.LOG;
import static org.hibernate.testing.TestLogger.LOG;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Iterator;

View File

@ -1,6 +1,6 @@
//$Id$
package org.hibernate.test.annotations.naturalid;
import static org.hibernate.TestLogger.LOG;
import static org.hibernate.testing.TestLogger.LOG;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.Session;

View File

@ -1,7 +1,7 @@
//$Id: A320.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $
package org.hibernate.test.annotations.onetoone.primarykey;
import static org.hibernate.TestLogger.LOG;
import static org.hibernate.testing.TestLogger.LOG;
import junit.framework.TestCase;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.cfg.Environment;

View File

@ -1,6 +1,6 @@
//$Id$
package org.hibernate.test.annotations.reflection;
import static org.hibernate.TestLogger.LOG;
import static org.hibernate.testing.TestLogger.LOG;
import javax.persistence.PostPersist;
import javax.persistence.PrePersist;

View File

@ -1,6 +1,6 @@
//$Id$
package org.hibernate.test.annotations.reflection;
import static org.hibernate.TestLogger.LOG;
import static org.hibernate.testing.TestLogger.LOG;
import javax.persistence.PostPersist;
import javax.persistence.PrePersist;

View File

@ -23,12 +23,10 @@
*/
package org.hibernate.test.common;
import java.sql.ResultSet;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Set;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.jdbc.ColumnNameCache;
import org.hibernate.engine.jdbc.LobCreationContext;
import org.hibernate.engine.jdbc.LobCreator;
import org.hibernate.engine.jdbc.internal.ResultSetWrapperImpl;
@ -41,6 +39,8 @@ import org.hibernate.engine.jdbc.spi.SqlStatementLogger;
import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.service.spi.Stoppable;
import org.hibernate.testing.env.ConnectionProviderBuilder;
/**
* Implementation of the {@link JdbcServices} contract for use by these

View File

@ -33,7 +33,7 @@ import org.hibernate.service.jta.platform.internal.TransactionManagerBasedSynchr
import org.hibernate.service.jta.platform.spi.JtaPlatformException;
import org.hibernate.service.spi.Startable;
import org.hibernate.service.spi.Stoppable;
import org.hibernate.test.common.ConnectionProviderBuilder;
import org.hibernate.testing.env.ConnectionProviderBuilder;
import org.jboss.logging.Logger;
import com.atomikos.icatch.jta.UserTransactionImp;
import com.atomikos.icatch.jta.UserTransactionManager;

View File

@ -35,7 +35,7 @@ import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.service.spi.Stoppable;
import org.hibernate.tool.hbm2ddl.SchemaExport;
import org.hibernate.test.common.ConnectionProviderBuilder;
import org.hibernate.testing.env.ConnectionProviderBuilder;
/**
* Implementation of SuppliedConnectionTest.

View File

@ -54,7 +54,7 @@ import org.hibernate.test.legacy.Fixed;
import org.hibernate.test.legacy.Simple;
import org.hibernate.test.legacy.Single;
import static org.hibernate.TestLogger.LOG;
import static org.hibernate.testing.TestLogger.LOG;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

View File

@ -22,7 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.filter;
import static org.hibernate.TestLogger.LOG;
import static org.hibernate.testing.TestLogger.LOG;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
@ -164,7 +164,7 @@ public class DynamicFilterTest extends BaseCoreFunctionalTestCase {
session.clear();
session.disableFilter("regionlist");
session.disableFilter( "regionlist" );
session.enableFilter( "regionlist" ).setParameterList( "regions", new String[]{"LA", "APAC", "APAC"} );
// Second test retreival through hql with the collection as non-eager with different region list
salespersons = session.createQuery( "select s from Salesperson as s" ).list();
@ -190,7 +190,7 @@ public class DynamicFilterTest extends BaseCoreFunctionalTestCase {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// HQL test
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
LOG.info("Starting HQL filter tests");
LOG.info( "Starting HQL filter tests" );
TestData testData = new TestData();
testData.prepare();
@ -200,13 +200,13 @@ public class DynamicFilterTest extends BaseCoreFunctionalTestCase {
session.enableFilter( "effectiveDate" )
.setParameter( "asOfDate", testData.lastMonth.getTime() );
LOG.info("HQL against Salesperson...");
LOG.info( "HQL against Salesperson..." );
List results = session.createQuery( "select s from Salesperson as s left join fetch s.orders" ).list();
assertTrue( "Incorrect filtered HQL result count [" + results.size() + "]", results.size() == 1 );
Salesperson result = ( Salesperson ) results.get( 0 );
assertTrue( "Incorrect collectionfilter count", result.getOrders().size() == 1 );
LOG.info("HQL against Product...");
LOG.info( "HQL against Product..." );
results = session.createQuery( "from Product as p where p.stockNumber = ?" ).setInteger( 0, 124 ).list();
assertTrue( results.size() == 1 );
@ -225,7 +225,7 @@ public class DynamicFilterTest extends BaseCoreFunctionalTestCase {
Session session = openSession();
session.enableFilter( "heavyProducts" ).setParameter("weightKilograms", 4d);
LOG.info("HQL against Product...");
LOG.info( "HQL against Product..." );
List results = session.createQuery( "from Product").list();
assertEquals( 1, results.size() );
@ -280,7 +280,7 @@ public class DynamicFilterTest extends BaseCoreFunctionalTestCase {
Session session = openSession();
session.beginTransaction();
session.enableFilter( "fulfilledOrders" ).setParameter( "asOfDate", testData.lastMonth.getTime() );
session.enableFilter( "regionlist" ).setParameterList( "regions", new String[] { "APAC" } );
session.enableFilter( "regionlist" ).setParameterList( "regions", new String[] {"APAC"} );
List result = session.createCriteria( Order.class )
.add( Subqueries.in( "steve", subquery ) )
@ -389,43 +389,47 @@ public class DynamicFilterTest extends BaseCoreFunctionalTestCase {
LOG.info("query against Department with a subquery on Salesperson in the APAC reqion...");
List departments = session.createQuery("select d from Department as d where d.id in (select s.department from Salesperson s where s.name = ?)").setString(0, "steve").list();
List departments = session.createQuery(
"select d from Department as d where d.id in (select s.department from Salesperson s where s.name = ?)"
).setString( 0, "steve" ).list();
assertEquals("Incorrect department count", 1, departments.size());
LOG.info("query against Department with a subquery on Salesperson in the FooBar reqion...");
session.enableFilter("region").setParameter("region", "Foobar");
session.enableFilter("region").setParameter( "region", "Foobar" );
departments = session.createQuery("select d from Department as d where d.id in (select s.department from Salesperson s where s.name = ?)").setString(0, "steve").list();
assertEquals("Incorrect department count", 0, departments.size());
assertEquals( "Incorrect department count", 0, departments.size() );
LOG.info("query against Order with a subquery for line items with a subquery line items where the product name is Acme Hair Gel and the quantity is greater than 1 in a given region for a given buyer");
session.enableFilter("region").setParameter("region", "APAC");
session.enableFilter("region").setParameter( "region", "APAC" );
List orders = session.createQuery("select o from Order as o where exists (select li.id from LineItem li, Product as p where p.id = li.product and li.quantity >= ? and p.name = ?) and o.buyer = ?")
.setLong(0, 1L).setString(1, "Acme Hair Gel").setString(2, "gavin").list();
assertEquals("Incorrect orders count", 1, orders.size());
assertEquals( "Incorrect orders count", 1, orders.size() );
LOG.info("query against Order with a subquery for line items with a subquery line items where the product name is Acme Hair Gel and the quantity is greater than 1 in a given region and the product is effective as of last month");
session.enableFilter("region").setParameter("region", "APAC");
session.enableFilter("effectiveDate").setParameter("asOfDate", testData.lastMonth.getTime());
session.enableFilter("effectiveDate").setParameter( "asOfDate", testData.lastMonth.getTime() );
orders = session.createQuery("select o from Order as o where exists (select li.id from LineItem li where li.quantity >= ? and li.product in (select p.id from Product p where p.name = ?)) and o.buyer = ?")
.setLong(0, 1L).setString(1, "Acme Hair Gel").setString(2, "gavin").list();
assertEquals("Incorrect orders count", 1, orders.size());
assertEquals( "Incorrect orders count", 1, orders.size() );
LOG.info("query against Order with a subquery for line items with a subquery line items where the product name is Acme Hair Gel and the quantity is greater than 1 in a given region and the product is effective as of 4 months ago");
LOG.info(
"query against Order with a subquery for line items with a subquery line items where the product name is Acme Hair Gel and the quantity is greater than 1 in a given region and the product is effective as of 4 months ago"
);
session.enableFilter("region").setParameter("region", "APAC");
session.enableFilter("effectiveDate").setParameter("asOfDate", testData.fourMonthsAgo.getTime());
orders = session.createQuery("select o from Order as o where exists (select li.id from LineItem li where li.quantity >= ? and li.product in (select p.id from Product p where p.name = ?)) and o.buyer = ?")
.setLong(0, 1L).setString(1, "Acme Hair Gel").setString(2, "gavin").list();
.setLong( 0, 1L ).setString( 1, "Acme Hair Gel" ).setString( 2, "gavin" ).list();
assertEquals("Incorrect orders count", 0, orders.size());
@ -445,7 +449,7 @@ public class DynamicFilterTest extends BaseCoreFunctionalTestCase {
session.enableFilter("effectiveDate").setParameter("asOfDate", testData.lastMonth.getTime());
orders = session.createQuery("select o from Order as o where exists (select li.id from LineItem li where li.quantity >= ? and li.product in (select p.id from Product p where p.name = ?)) and o.buyer = :buyer")
.setLong(0, 1L).setString(1, "Acme Hair Gel").setString("buyer", "gavin").list();
.setLong( 0, 1L ).setString( 1, "Acme Hair Gel" ).setString( "buyer", "gavin" ).list();
assertEquals("Incorrect orders count", 1, orders.size());

View File

@ -66,7 +66,7 @@ import org.hibernate.type.ComponentType;
import org.hibernate.type.ManyToOneType;
import org.hibernate.type.Type;
import static org.hibernate.TestLogger.LOG;
import static org.hibernate.testing.TestLogger.LOG;
import static org.hibernate.testing.junit4.ExtraAssertions.assertClassAssignability;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;

View File

@ -22,7 +22,6 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.hql;
import static org.hibernate.TestLogger.LOG;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -201,7 +200,7 @@ public class BulkManipulationTest extends BaseCoreFunctionalTestCase {
s.createSQLQuery( "insert into Pickup (id, vin, owner) select id, vin, owner from Car" ).executeUpdate();
l = s.createQuery("from Vehicle").list();
assertEquals(l.size(),5);
assertEquals( l.size(), 5 );
t.commit();
t = s.beginTransaction();
@ -212,13 +211,21 @@ public class BulkManipulationTest extends BaseCoreFunctionalTestCase {
assertEquals(l.size(),4);
Car c = (Car) s.createQuery( "from Car where owner = 'Kirsten'" ).uniqueResult();
c.setOwner("NotKirsten");
assertEquals(0,s.getNamedQuery( "native-delete-car" ).setString( 0, "Kirsten" ).executeUpdate());
assertEquals(1,s.getNamedQuery( "native-delete-car" ).setString( 0, "NotKirsten" ).executeUpdate());
c.setOwner( "NotKirsten" );
assertEquals( 0, s.getNamedQuery( "native-delete-car" ).setString( 0, "Kirsten" ).executeUpdate() );
assertEquals( 1, s.getNamedQuery( "native-delete-car" ).setString( 0, "NotKirsten" ).executeUpdate() );
assertEquals(0,s.createSQLQuery( "delete from SUV where owner = :owner" ).setString( "owner", "NotThere" ).executeUpdate());
assertEquals(1,s.createSQLQuery( "delete from SUV where owner = :owner" ).setString( "owner", "Joe" ).executeUpdate());
assertEquals(
0, s.createSQLQuery( "delete from SUV where owner = :owner" )
.setString( "owner", "NotThere" )
.executeUpdate()
);
assertEquals(
1, s.createSQLQuery( "delete from SUV where owner = :owner" )
.setString( "owner", "Joe" )
.executeUpdate()
);
s.createSQLQuery( "delete from Pickup" ).executeUpdate();
l = s.createQuery("from Vehicle").list();

View File

@ -48,8 +48,8 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.hibernate.testing.env.ConnectionProviderBuilder;
import org.hibernate.testing.junit4.BaseUnitTestCase;
import org.hibernate.test.common.ConnectionProviderBuilder;
import org.hibernate.test.common.JournalingBatchObserver;
import org.hibernate.test.common.JournalingTransactionObserver;
import org.hibernate.test.common.TransactionContextImpl;

View File

@ -26,7 +26,7 @@ package org.hibernate.test.jpa.cascade;
import org.hibernate.Session;
import org.hibernate.TransientObjectException;
import static org.hibernate.TestLogger.LOG;
import static org.hibernate.testing.TestLogger.LOG;
import static org.junit.Assert.fail;
import org.junit.Test;

View File

@ -23,7 +23,7 @@
*/
package org.hibernate.test.legacy;
import static org.hibernate.TestLogger.LOG;
import static org.hibernate.testing.TestLogger.LOG;
import java.io.Serializable;
import java.sql.Connection;
import java.sql.Time;
@ -83,7 +83,7 @@ import org.junit.Test;
import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.RequiresDialectFeature;
import org.hibernate.test.common.ConnectionProviderBuilder;
import org.hibernate.testing.env.ConnectionProviderBuilder;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@ -232,9 +232,9 @@ public class FooBarTest extends LegacyTestCase {
Qux q2 = (Qux) s.load( Qux.class, q.getKey() );
assertTrue( "loaded same object", q==q2 );
assertTrue( "loaded same object", b==b2 );
assertTrue( Math.round( b.getFormula() ) == b.getInt()/2 );
assertTrue( Math.round( b.getFormula() ) == b.getInt() / 2 );
s.delete(q2);
s.delete(b2);
s.delete( b2 );
s.getTransaction().commit();
s.close();
}
@ -245,12 +245,12 @@ public class FooBarTest extends LegacyTestCase {
s.beginTransaction();
Foo foo = new Foo();
foo.setJoinedProp("foo");
s.save(foo);
s.save( foo );
s.flush();
foo.setJoinedProp("bar");
s.flush();
String fid = foo.getKey();
s.delete(foo);
s.delete( foo );
s.getTransaction().commit();
s.close();
@ -375,9 +375,9 @@ public class FooBarTest extends LegacyTestCase {
Session s = openSession();
s.beginTransaction();
Baz bb = (Baz) s.createCriteria(Baz.class).uniqueResult();
assertTrue(bb==null);
assertTrue( bb == null );
Baz baz = new Baz();
s.save(baz);
s.save( baz );
s.getTransaction().commit();
s.close();
@ -385,8 +385,8 @@ public class FooBarTest extends LegacyTestCase {
s.beginTransaction();
Baz b = (Baz) s.createCriteria(Baz.class).uniqueResult();
assertTrue( Hibernate.isInitialized( b.getTopGlarchez() ) );
assertTrue( b.getTopGlarchez().size()==0 );
s.delete(b);
assertTrue( b.getTopGlarchez().size() == 0 );
s.delete( b );
s.getTransaction().commit();
s.close();
}
@ -839,8 +839,8 @@ public class FooBarTest extends LegacyTestCase {
Baz baz = new Baz();
List list = new ArrayList();
list.add( new Fee() );
baz.setFees(list);
s.save(baz);
baz.setFees( list );
s.save( baz );
s.getTransaction().commit();
s.close();
@ -854,7 +854,7 @@ public class FooBarTest extends LegacyTestCase {
s = openSession();
s.beginTransaction();
s.delete(baz);
s.delete( baz );
s.flush();
assertFalse( s.createQuery( "from Fee" ).iterate().hasNext() );
s.getTransaction().commit();
@ -867,7 +867,7 @@ public class FooBarTest extends LegacyTestCase {
list.add( new Fee() );
list.add( new Fee() );
baz.setFees(list);
s.save(baz);
s.save( baz );
s.getTransaction().commit();
s.close();
@ -878,7 +878,7 @@ public class FooBarTest extends LegacyTestCase {
s.getTransaction().commit();
s.close();
assertTrue( baz.getFees().size()==2 );
assertTrue( baz.getFees().size() == 2 );
s = openSession();
s.beginTransaction();
@ -917,7 +917,7 @@ public class FooBarTest extends LegacyTestCase {
Session s = openSession();
s.beginTransaction();
Baz baz = new Baz();
s.save(baz);
s.save( baz );
s.getTransaction().commit();
s.close();
@ -1112,12 +1112,12 @@ public class FooBarTest extends LegacyTestCase {
Collection fooBag = new ArrayList();
fooBag.add( new Foo() );
fooBag.add( new Foo() );
baz.setFooBag(fooBag);
baz.setFooBag( fooBag );
s.save(baz);
s.flush();
fooBag = baz.getFooBag();
s.createQuery( "from Baz baz left join fetch baz.fooBag" ).list();
assertTrue( fooBag==baz.getFooBag() );
assertTrue( fooBag == baz.getFooBag() );
s.getTransaction().commit();
s.close();
@ -1125,10 +1125,10 @@ public class FooBarTest extends LegacyTestCase {
s.beginTransaction();
baz = (Baz) s.load( Baz.class, baz.getCode() );
Object bag = baz.getFooBag();
assertFalse( Hibernate.isInitialized(bag) );
assertFalse( Hibernate.isInitialized( bag ) );
s.createQuery( "from Baz baz left join fetch baz.fooBag" ).list();
assertTrue( bag==baz.getFooBag() );
assertTrue( baz.getFooBag().size()==2 );
assertTrue( baz.getFooBag().size() == 2 );
s.delete(baz);
s.getTransaction().commit();
s.close();
@ -1141,18 +1141,18 @@ public class FooBarTest extends LegacyTestCase {
Baz baz = new Baz();
List l = new ArrayList();
baz.setStringList(l);
l.add("foo");
l.add( "foo" );
Serializable id = s.save(baz);
l.add("bar");
s.flush();
l.add("baz");
l.add( "baz" );
s.getTransaction().commit();
s.close();
s = openSession();
s.beginTransaction();
baz = (Baz) s.load(Baz.class, id);
assertTrue( baz.getStringList().size()==3 && baz.getStringList().contains("bar") );
assertTrue( baz.getStringList().size() == 3 && baz.getStringList().contains( "bar" ) );
s.delete(baz);
s.getTransaction().commit();
s.close();
@ -1163,7 +1163,7 @@ public class FooBarTest extends LegacyTestCase {
Session s = openSession();
s.beginTransaction();
Foo foo = new Foo();
s.save(foo);
s.save( foo );
s.getTransaction().commit();
s.close();
@ -1173,24 +1173,24 @@ public class FooBarTest extends LegacyTestCase {
s.beginTransaction();
FooProxy foo2 = (FooProxy) s.load( Foo.class, foo.getKey() );
foo2.setString("dirty");
foo2.setBoolean( new Boolean(false) );
foo2.setBytes( new byte[] { 1,2,3} );
foo2.setDate(null);
foo2.setShort( new Short("69") );
foo2.setBoolean( new Boolean( false ) );
foo2.setBytes( new byte[] {1, 2, 3} );
foo2.setDate( null );
foo2.setShort( new Short( "69" ) );
s.getTransaction().commit();
s.close();
s = openSession();
s.beginTransaction();
foo2.setString("dirty again");
foo2.setString( "dirty again" );
s.update(foo2);
s.getTransaction().commit();
s.close();
s = openSession();
s.beginTransaction();
foo2.setString("dirty again 2");
s.update(foo2);
foo2.setString( "dirty again 2" );
s.update( foo2 );
s.getTransaction().commit();
s.close();
@ -1200,7 +1200,7 @@ public class FooBarTest extends LegacyTestCase {
s.load( foo3, foo.getKey() );
// There is an interbase bug that causes null integers to return as 0, also numeric precision is <= 15
assertTrue( "update", foo2.equalsFoo(foo3) );
s.delete(foo3);
s.delete( foo3 );
doDelete( s, "from Glarch" );
s.getTransaction().commit();
s.close();
@ -1252,13 +1252,13 @@ public class FooBarTest extends LegacyTestCase {
fooBag.add( new Foo() );
fooBag.add( new Foo() );
baz.setFooBag(fooBag);
s.save(baz);
s.save( baz );
s.flush();
fooBag = baz.getFooBag();
s.createQuery( "from Baz baz left join fetch baz.fooBag" ).list();
assertTrue( Hibernate.isInitialized(fooBag) );
assertTrue( fooBag==baz.getFooBag() );
assertTrue( baz.getFooBag().size()==2 );
assertTrue( Hibernate.isInitialized( fooBag ) );
assertTrue( fooBag == baz.getFooBag() );
assertTrue( baz.getFooBag().size() == 2 );
s.getTransaction().commit();
s.close();
@ -1268,7 +1268,7 @@ public class FooBarTest extends LegacyTestCase {
Object bag = baz.getFooBag();
assertFalse( Hibernate.isInitialized(bag) );
s.createQuery( "from Baz baz left join fetch baz.fooBag" ).list();
assertTrue( Hibernate.isInitialized(bag) );
assertTrue( Hibernate.isInitialized( bag ) );
assertTrue( bag==baz.getFooBag() );
assertTrue( baz.getFooBag().size()==2 );
s.delete(baz);
@ -1569,9 +1569,9 @@ public class FooBarTest extends LegacyTestCase {
s.beginTransaction();
Baz baz = (Baz) s.load(Baz.class, id);
Set foos = baz.getFooSet();
assertTrue( foos.size()==0 );
assertTrue( foos.size() == 0 );
Foo foo = new Foo();
foos.add(foo);
foos.add( foo );
s.save(foo);
s.flush();
s.delete(foo);
@ -1688,7 +1688,7 @@ public class FooBarTest extends LegacyTestCase {
s = openSession();
s.beginTransaction();
//g = (Glarch) s.createQuery( "from Glarch g where g.multiple.count=12" ).list().get(0);
s.createQuery( "from Glarch g where g.multiple.count=12" ).list().get(0);
s.createQuery( "from Glarch g where g.multiple.count=12" ).list().get( 0 );
s.getTransaction().commit();
s.close();
@ -1704,9 +1704,9 @@ public class FooBarTest extends LegacyTestCase {
s = openSession();
s.beginTransaction();
g = (GlarchProxy) s.load(Glarch.class, gid);
assertTrue( g.getMultiple()!=null );
assertTrue( g.getMultiple() != null );
assertEquals( g.getMultiple().count, 12 );
assertSame(g.getMultiple().glarch, g);
assertSame( g.getMultiple().glarch, g );
s.delete(g);
s.getTransaction().commit();
s.close();
@ -1718,8 +1718,8 @@ public class FooBarTest extends LegacyTestCase {
s.beginTransaction();
Baz baz = new Baz();
Set bars = new HashSet();
baz.setCascadingBars(bars);
s.save(baz);
baz.setCascadingBars( bars );
s.save( baz );
s.flush();
baz.getCascadingBars().add( new Bar() );
s.delete(baz);
@ -1734,16 +1734,16 @@ public class FooBarTest extends LegacyTestCase {
Bar bar2 = new Bar();
bar.setName("Bar");
bar2.setName("Bar Two");
bar.setX(10);
bar2.setX(1000);Baz baz = new Baz();
bar.setX( 10 );
bar2.setX( 1000 );Baz baz = new Baz();
baz.setCascadingBars( new HashSet() );
baz.getCascadingBars().add(bar);
bar.setBaz(baz);
Session s = openSession();
Transaction txn = s.beginTransaction();
s.save(baz);
s.save(bar2);
s.save( baz );
s.save( bar2 );
List list = s.createQuery(
"from Bar bar left join bar.baz baz left join baz.cascadingBars b where bar.name like 'Bar %'"
@ -1757,11 +1757,11 @@ public class FooBarTest extends LegacyTestCase {
q = s.createQuery("select bar, b from Bar bar left join bar.baz baz left join baz.cascadingBars b where ( bar.name in (:nameList) or bar.name in (:nameList) ) and bar.string = :stringVal");
HashSet nameList = new HashSet();
nameList.add("bar");
nameList.add("Bar");
nameList.add("Bar Two");
q.setParameterList("nameList", nameList);
q.setParameter("stringVal", "a string");
nameList.add( "bar" );
nameList.add( "Bar" );
nameList.add( "Bar Two" );
q.setParameterList( "nameList", nameList );
q.setParameter( "stringVal", "a string" );
list = q.list();
if ( !(getDialect() instanceof SAPDBDialect) ) assertTrue( list.size()==2 );
@ -1774,19 +1774,19 @@ public class FooBarTest extends LegacyTestCase {
q = s.createQuery("select bar, b from Bar bar inner join bar.baz baz inner join baz.cascadingBars b where bar.name like 'Bar%'");
Object result = q.uniqueResult();
assertTrue( result!=null );
assertTrue( result != null );
q = s.createQuery("select bar, b from Bar bar left join bar.baz baz left join baz.cascadingBars b where bar.name like :name and b.name like :name");
q.setString("name", "Bar%");
q.setString( "name", "Bar%" );
list = q.list();
assertTrue( list.size()==1 );
// This test added for issue HB-297 - there is an named parameter in the Order By clause
q = s.createQuery("select bar from Bar bar order by ((bar.x - :valueX)*(bar.x - :valueX))");
q.setInteger("valueX", bar.getX()+1);
q.setInteger( "valueX", bar.getX() + 1 );
list = q.list();
assertTrue( ((Bar)list.get(0)).getX() == bar.getX());
q.setInteger("valueX", bar2.getX()+1);
assertTrue( ((Bar) list.get( 0 )).getX() == bar.getX() );
q.setInteger( "valueX", bar2.getX() + 1 );
list = q.list();
assertTrue( ((Bar)list.get(0)).getX() == bar2.getX());
@ -1928,7 +1928,7 @@ public class FooBarTest extends LegacyTestCase {
Session s = openSession();
Transaction txn = s.beginTransaction();
Foo f = new Foo();
s.save(f);
s.save( f );
s.flush();
List list = s.createCriteria(Foo.class)
@ -1940,7 +1940,7 @@ public class FooBarTest extends LegacyTestCase {
.setFetchMode("baz", FetchMode.SELECT)
.setFetchMode("abstracts", FetchMode.JOIN)
.list();
assertTrue( list.size()==1 && list.get(0)==f );
assertTrue( list.size() == 1 && list.get( 0 ) == f );
list = s.createCriteria(Foo.class).add(
Restrictions.disjunction()
@ -1950,7 +1950,7 @@ public class FooBarTest extends LegacyTestCase {
)
.add( Restrictions.isNotNull("boolean") )
.list();
assertTrue( list.size()==1 && list.get(0)==f );
assertTrue( list.size() == 1 && list.get( 0 ) == f );
Foo example = new Foo();
example.setString("a STRing");
@ -1963,7 +1963,10 @@ public class FooBarTest extends LegacyTestCase {
.excludeProperty("yesno")
)
.list();
assertTrue( "Example API without like did not work correctly, size was " + list.size(), list.size()==1 && list.get(0)==f );
assertTrue(
"Example API without like did not work correctly, size was " + list.size(),
list.size() == 1 && list.get( 0 ) == f
);
example.setString("rin");
list = s.createCriteria(Foo.class).add(
@ -2001,11 +2004,11 @@ public class FooBarTest extends LegacyTestCase {
.addOrder( Order.asc("date") )
.addOrder( Order.desc("string") )
.list();
assertTrue( list.size()==0 );
assertTrue( list.size() == 0 );
list = s.createCriteria(Foo.class)
.setFetchMode( "component.importantDates", FetchMode.JOIN )
.list();
assertTrue( list.size()==3 );
assertTrue( list.size() == 3 );
list = s.createCriteria(Foo.class)
.setFetchMode( "component.importantDates", FetchMode.JOIN )
@ -2038,9 +2041,9 @@ public class FooBarTest extends LegacyTestCase {
s.save( new Bar() );
list = s.createCriteria(Bar.class)
.list();
assertTrue( list.size()==1 );
assertTrue( list.size() == 1 );
assertTrue( s.createCriteria(Foo.class).list().size()==3 );
s.delete( list.get(0) );
s.delete( list.get( 0 ) );
s.delete( f.getFoo() );
s.delete(f);
@ -2073,28 +2076,28 @@ public class FooBarTest extends LegacyTestCase {
Session s = openSession();
s.beginTransaction();
s.save(foo1);
s.save( foo1 );
s.save(foo2);
baz.setFooArray(arr);
s.save(baz);
baz.setFooArray( arr );
s.save( baz );
s.getTransaction().commit();
s.close();
s = openSession();
s.beginTransaction();
baz = (Baz) s.load( Baz.class, baz.getCode() );
assertTrue( baz.getFooArray().length==1 );
assertTrue( baz.getFooArray().length == 1 );
assertTrue( s.createQuery( "from Baz baz join baz.fooArray foo" ).list().size()==1 );
assertTrue( s.createQuery( "from Foo foo" ).list().size()==2 );
assertTrue( s.createFilter( baz.getFooArray(), "" ).list().size()==1 );
assertTrue( s.createFilter( baz.getFooArray(), "" ).list().size() == 1 );
//assertTrue( s.delete("from java.lang.Object o")==9 );
doDelete( s, "from Foo foo" );
String bazid = baz.getCode();
s.delete(baz);
s.delete( baz );
int rows=s.connection().createStatement().executeUpdate(
"delete from FOO_ARRAY where id_='" + bazid + "' and i>=8"
);
assertTrue(rows==1);
assertTrue( rows == 1 );
s.getTransaction().commit();
s.close();
}
@ -2223,7 +2226,7 @@ public class FooBarTest extends LegacyTestCase {
List list = new ArrayList();
list.add( new Fee() );
list.add( new Fee() );
baz.setFees(list);
baz.setFees( list );
s.save(baz);
t.commit();
s.close();
@ -2231,7 +2234,7 @@ public class FooBarTest extends LegacyTestCase {
s = openSession();
t = s.beginTransaction();
baz = (Baz) s.load( Baz.class, baz.getCode() );
assertTrue( baz.getFees().size()==2 );
assertTrue( baz.getFees().size() == 2 );
s.delete(baz);
assertTrue( !s.createQuery( "from Fee fee" ).iterate().hasNext() );
t.commit();
@ -2416,12 +2419,12 @@ public class FooBarTest extends LegacyTestCase {
while ( iter.hasNext() ) {
if ( iter.next().equals("a new value") ) found = true;
}
assertTrue(found);
baz.setStringArray(null);
assertTrue( found );
baz.setStringArray( null );
s.createQuery( "from Baz baz" ).iterate(); //no flush
iter = s.createQuery( "select elements(baz.stringArray) from Baz baz" ).iterate();
assertTrue( !iter.hasNext() );
baz.getStringList().add("1E1");
baz.getStringList().add( "1E1" );
iter = s.createQuery( "from Foo foo" ).iterate();//no flush
assertTrue( !iter.hasNext() );
iter = s.createQuery( "select elements(baz.stringList) from Baz baz" ).iterate();
@ -2429,8 +2432,8 @@ public class FooBarTest extends LegacyTestCase {
while ( iter.hasNext() ) {
if ( iter.next().equals("1E1") ) found = true;
}
assertTrue(found);
baz.getStringList().remove("1E1");
assertTrue( found );
baz.getStringList().remove( "1E1" );
iter = s.createQuery( "select elements(baz.stringArray) from Baz baz" ).iterate(); //no flush
iter = s.createQuery( "select elements(baz.stringList) from Baz baz" ).iterate();
found = false;
@ -2441,9 +2444,9 @@ public class FooBarTest extends LegacyTestCase {
List newList = new ArrayList();
newList.add("value");
baz.setStringList(newList);
baz.setStringList( newList );
iter = s.createQuery( "from Foo foo" ).iterate();//no flush
baz.setStringList(null);
baz.setStringList( null );
iter = s.createQuery( "select elements(baz.stringList) from Baz baz" ).iterate();
assertTrue( !iter.hasNext() );
@ -2452,7 +2455,7 @@ public class FooBarTest extends LegacyTestCase {
iter = s.createQuery( "select elements(baz.stringList) from Baz baz" ).iterate();
assertTrue( iter.hasNext() );
s.delete(baz);
s.delete( baz );
txn.commit();
s.close();
}
@ -2809,7 +2812,7 @@ public class FooBarTest extends LegacyTestCase {
Foo foo2 = new Foo();
s.load( foo2, foo.getKey() );
// There is an interbase bug that causes null integers to return as 0, also numeric precision is <= 15
assertTrue( "create", foo.equalsFoo(foo2) );
assertTrue( "create", foo.equalsFoo( foo2 ) );
s.delete(foo2);
s.getTransaction().commit();
s.close();
@ -2821,27 +2824,27 @@ public class FooBarTest extends LegacyTestCase {
s.beginTransaction();
Qux q = new Qux("0");
s.save(q);
q.setChild( new Qux("1") );
q.setChild( new Qux( "1" ) );
s.save( q.getChild() );
Qux q2 = new Qux("2");
q2.setChild( q.getChild() );
Qux q3 = new Qux("3");
q.getChild().setChild(q3);
s.save(q3);
s.save( q3 );
Qux q4 = new Qux("4");
q4.setChild(q3);
q4.setChild( q3 );
s.save(q4);
s.save(q2);
s.save( q2 );
s.getTransaction().commit();
s.close();
s = openSession();
s.beginTransaction();
List l = s.createQuery( "from Qux" ).list();
assertTrue( "", l.size()==5);
s.delete( l.get(0) );
s.delete( l.get(1) );
s.delete( l.get(2) );
assertTrue( "", l.size() == 5 );
s.delete( l.get( 0 ) );
s.delete( l.get( 1 ) );
s.delete( l.get( 2 ) );
s.delete( l.get(3) );
s.delete( l.get(4) );
s.getTransaction().commit();
@ -2875,13 +2878,13 @@ public class FooBarTest extends LegacyTestCase {
s.beginTransaction();
Baz baz = new Baz();
baz.setDefaults();
s.save(baz);
s.save( baz );
s.flush();
assertTrue( s.contains(baz) );
s.evict(baz);
s.evict( baz );
assertFalse( s.contains(baz) );
Baz baz2 = (Baz) s.load( Baz.class, baz.getCode() );
assertFalse(baz==baz2);
assertFalse( baz == baz2 );
s.delete(baz2);
s.getTransaction().commit();
s.close();
@ -2894,20 +2897,20 @@ public class FooBarTest extends LegacyTestCase {
Bar bar = new Bar();
s.save(bar);
bar.setAbstracts( new HashSet() );
bar.getAbstracts().add(bar);
bar.getAbstracts().add( bar );
Bar bar2 = new Bar();
bar.getAbstracts().add(bar2);
bar.getAbstracts().add( bar2 );
bar.setFoo(bar);
s.save(bar2);
s.save( bar2 );
s.getTransaction().commit();
s.close();
bar.setAbstracts(null);
bar.setAbstracts( null );
s = openSession();
s.beginTransaction();
s.load( bar, bar.getKey() );
assertTrue( "collection contains self", bar.getAbstracts().size()==2 && bar.getAbstracts().contains(bar) );
assertTrue( "collection contains self", bar.getAbstracts().size() == 2 && bar.getAbstracts().contains( bar ) );
assertTrue( "association to self", bar.getFoo()==bar );
Iterator iter = bar.getAbstracts().iterator();
while ( iter.hasNext() ) {
@ -2984,13 +2987,13 @@ public class FooBarTest extends LegacyTestCase {
s.beginTransaction();
Foo x = new Foo();
Foo y = new Foo();
x.setFoo(y);
y.setFoo(x);
s.save(x);
s.save(y);
x.setFoo( y );
y.setFoo( x );
s.save( x );
s.save( y );
s.flush();
s.delete(y);
s.delete(x);
s.delete( y );
s.delete( x );
s.getTransaction().commit();
s.close();
}
@ -3786,7 +3789,7 @@ public class FooBarTest extends LegacyTestCase {
s = openSession();
s.beginTransaction();
baz = (Baz) s.load( Baz.class, baz.getCode() );
s.delete(baz);
s.delete( baz );
s.getTransaction().commit();
s.close();
}
@ -3798,11 +3801,11 @@ public class FooBarTest extends LegacyTestCase {
Foo foo = new Foo();
foo.setComponent( new FooComponent("foo", 69, null, new FooComponent("bar", 96, null, null) ) );
s.save(foo);
foo.getComponent().setName("IFA");
foo.getComponent().setName( "IFA" );
txn.commit();
s.close();
foo.setComponent(null);
foo.setComponent( null );
s = openSession();
txn = s.beginTransaction();
@ -3812,7 +3815,7 @@ public class FooBarTest extends LegacyTestCase {
foo.getComponent().getName().equals("IFA") &&
foo.getComponent().getSubcomponent().getName().equals("bar")
);
assertTrue( "cascade save via component", foo.getComponent().getGlarch()!=null);
assertTrue( "cascade save via component", foo.getComponent().getGlarch() != null );
foo.getComponent().getSubcomponent().setName("baz");
txn.commit();
s.close();
@ -3834,10 +3837,10 @@ public class FooBarTest extends LegacyTestCase {
s = openSession();
txn = s.beginTransaction();
foo = new Foo();
s.save(foo);
s.save( foo );
foo.setCustom( new String[] { "one", "two" } );
assertTrue( s.createQuery( "from Foo foo where foo.custom.s1 = 'one'" ).list().get(0)==foo );
s.delete(foo);
s.delete( foo );
txn.commit();
s.close();
}
@ -4037,10 +4040,10 @@ public class FooBarTest extends LegacyTestCase {
s.beginTransaction();
One one = new One();
s.save(one);
one.setValue("yada");
one.setValue( "yada" );
Many many = new Many();
many.setOne(one);
s.save(many);
many.setOne( one );
s.save( many );
s.getTransaction().commit();
s.close();
@ -4159,7 +4162,7 @@ public class FooBarTest extends LegacyTestCase {
s.beginTransaction();
foo = (FooProxy) s.createQuery( "from Foo foo" ).list().get(0);
FooProxy foo2 = (FooProxy) s.load( Foo.class, foo.getKey() );
assertTrue("find returns same object as load", foo==foo2);
assertTrue( "find returns same object as load", foo == foo2 );
s.getTransaction().commit();
s.close();
@ -4167,7 +4170,7 @@ public class FooBarTest extends LegacyTestCase {
s.beginTransaction();
foo2 = (FooProxy) s.load( Foo.class, foo.getKey() );
foo = (FooProxy) s.createQuery( "from Foo foo" ).list().get(0);
assertTrue("find returns same object as load", foo==foo2);
assertTrue( "find returns same object as load", foo == foo2 );
doDelete( s, "from Foo foo" );
s.getTransaction().commit();
s.close();
@ -4180,9 +4183,9 @@ public class FooBarTest extends LegacyTestCase {
Foo foo = new Foo();
s.save(foo);
s.flush();
s.connection().createStatement().executeUpdate("update "+getDialect().openQuote()+"foos"+getDialect().closeQuote()+" set long_ = -3");
s.connection().createStatement().executeUpdate( "update " + getDialect().openQuote() + "foos" + getDialect().closeQuote() + " set long_ = -3" );
s.refresh(foo);
assertTrue( foo.getLong().longValue()==-3l );
assertTrue( foo.getLong().longValue() == -3l );
assertTrue( s.getCurrentLockMode(foo)==LockMode.READ );
s.refresh(foo, LockMode.UPGRADE);
if ( getDialect().supportsOuterJoinForUpdate() ) {
@ -4235,10 +4238,10 @@ public class FooBarTest extends LegacyTestCase {
s.close();
s = openSession();
s.beginTransaction();
s.update(v, id);
s.update(v, id);
s.delete(v);
s.delete(v);
s.update( v, id );
s.update( v, id );
s.delete( v );
s.delete( v );
s.getTransaction().commit();
s.close();
}
@ -4248,8 +4251,8 @@ public class FooBarTest extends LegacyTestCase {
Session s = openSession();
s.beginTransaction();
Vetoer v = new Vetoer();
v.setStrings( new String[] { "foo", "bar", "baz" } );
s.save(v); Serializable id = s.save(v);
v.setStrings( new String[] {"foo", "bar", "baz"} );
s.save( v ); Serializable id = s.save(v);
v.getStrings()[1] = "osama";
s.getTransaction().commit();
s.close();
@ -4257,8 +4260,8 @@ public class FooBarTest extends LegacyTestCase {
s = openSession();
s.beginTransaction();
v = (Vetoer) s.load(Vetoer.class, id);
assertTrue( "serializable type", v.getStrings()[1].equals("osama") );
s.delete(v); s.delete(v);
assertTrue( "serializable type", v.getStrings()[1].equals( "osama" ) );
s.delete(v); s.delete( v );
s.flush();
s.getTransaction().commit();
s.close();
@ -4339,12 +4342,12 @@ public class FooBarTest extends LegacyTestCase {
s.createQuery( "from Fo" ).list();
tx.commit();
Connection c = s.disconnect();
assertTrue( c!=null );
s.reconnect(c);
assertTrue( c != null );
s.reconnect( c );
tx = s.beginTransaction();
s.createQuery( "from Fo" ).list();
tx.commit();
assertTrue( s.close()==c );
assertTrue( s.close() == c );
c.close();
}
@ -4368,8 +4371,8 @@ public class FooBarTest extends LegacyTestCase {
s = openSession();
s.beginTransaction();
baz = (Baz) s.load( Baz.class, baz.getCode() );
assertTrue( ( (FooComponent) baz.getTopComponents().get(0) ).getCount()==99 );
s.delete(baz);
assertTrue( ((FooComponent) baz.getTopComponents().get( 0 )).getCount() == 99 );
s.delete( baz );
s.getTransaction().commit();
s.close();
}
@ -4380,17 +4383,17 @@ public class FooBarTest extends LegacyTestCase {
Transaction txn = s.beginTransaction();
Foo foo = new Foo();
Serializable id = s.save(foo);
assertTrue(id!=null);
assertTrue( id != null );
Qux q = new Qux("q");
foo.getDependent().setQux(q);
s.save(q);
q.getFoo().setString("foo2");
s.save( q );
q.getFoo().setString( "foo2" );
//s.flush();
//s.connection().commit();
assertTrue(
s.createQuery( "from Foo foo where foo.dependent.qux.foo.string = 'foo2'" ).iterate().hasNext()
);
s.delete(foo);
s.delete( foo );
txn.commit();
s.close();
}
@ -4452,8 +4455,8 @@ public class FooBarTest extends LegacyTestCase {
s.beginTransaction();
GlarchProxy g = new Glarch();
Foo foo = new Foo();
g.setAny(foo);
Serializable gid = s.save(g);
g.setAny( foo );
Serializable gid = s.save( g );
s.save(foo);
s.getTransaction().commit();
s.close();
@ -4463,7 +4466,7 @@ public class FooBarTest extends LegacyTestCase {
g = (GlarchProxy) s.load(Glarch.class, gid);
assertTrue( g.getAny()!=null && g.getAny() instanceof FooProxy );
s.delete( g.getAny() );
s.delete(g);
s.delete( g );
s.getTransaction().commit();
s.close();
}

View File

@ -22,7 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.legacy;
import static org.hibernate.TestLogger.LOG;
import static org.hibernate.testing.TestLogger.LOG;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;

View File

@ -22,10 +22,10 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.namingstrategy;
import org.hibernate.cfg.Configuration;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.testing.junit.functional.FunctionalTestCase;
import org.junit.Test;

View File

@ -37,8 +37,8 @@ import org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionPr
import org.hibernate.service.jdbc.connections.internal.UserSuppliedConnectionProviderImpl;
import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.testing.env.ConnectionProviderBuilder;
import org.hibernate.testing.junit4.BaseUnitTestCase;
import org.hibernate.test.common.ConnectionProviderBuilder;
/**
* @author Steve Ebersole

View File

@ -36,7 +36,7 @@ import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.hibernate.TestLogger.LOG;
import static org.hibernate.testing.TestLogger.LOG;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

View File

@ -45,7 +45,7 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.hibernate.testing.junit4.BaseUnitTestCase;
import org.hibernate.test.common.ConnectionProviderBuilder;
import org.hibernate.testing.env.ConnectionProviderBuilder;
import org.hibernate.test.common.JournalingTransactionObserver;
import org.hibernate.test.common.TransactionContextImpl;
import org.hibernate.test.common.TransactionEnvironmentImpl;

View File

@ -49,8 +49,8 @@ import org.hibernate.service.internal.ServiceRegistryImpl;
import org.hibernate.service.jta.platform.internal.JtaPlatformInitiator;
import org.hibernate.service.jta.platform.spi.JtaPlatform;
import org.hibernate.testing.env.ConnectionProviderBuilder;
import org.hibernate.testing.junit4.BaseUnitTestCase;
import org.hibernate.test.common.ConnectionProviderBuilder;
import org.hibernate.test.common.JournalingTransactionObserver;
import org.hibernate.test.common.TransactionContextImpl;
import org.hibernate.test.common.TransactionEnvironmentImpl;

View File

@ -49,7 +49,7 @@ import org.junit.Before;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseUnitTestCase;
import org.hibernate.test.common.ConnectionProviderBuilder;
import org.hibernate.testing.env.ConnectionProviderBuilder;
import org.hibernate.test.common.JournalingTransactionObserver;
import org.hibernate.test.common.TransactionContextImpl;
import org.hibernate.test.common.TransactionEnvironmentImpl;

View File

@ -1,5 +1,5 @@
package org.hibernate.test.typeparameters;
import static org.hibernate.TestLogger.LOG;
import static org.hibernate.testing.TestLogger.LOG;
import java.io.Serializable;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

View File

@ -24,7 +24,6 @@
package org.hibernate.test.util;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.testing.junit.UnitTestCase;
import org.junit.Test;

View File

@ -23,7 +23,6 @@
*/
package org.hibernate.testing.junit.functional.annotations;
import static org.hibernate.TestLogger.LOG;
import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

View File

@ -29,7 +29,8 @@ import org.hibernate.HibernateException;
import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.service.spi.Stoppable;
import org.hibernate.service.spi.UnknownUnwrapTypeException;
import org.hibernate.test.common.ConnectionProviderBuilder;
import org.hibernate.testing.env.ConnectionProviderBuilder;
/**
* A {@link ConnectionProvider} implementation adding JTA-style transactionality

View File

@ -22,7 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.testing.tm;
import static org.hibernate.TestLogger.LOG;
import static org.hibernate.testing.TestLogger.LOG;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.LinkedList;

View File

@ -1,6 +1,6 @@
//$Id$
package org.hibernate.ejb.test;
import static org.hibernate.TestLogger.LOG;
import static org.hibernate.testing.TestLogger.LOG;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Calendar;

View File

@ -23,7 +23,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.ejb.test;
import static org.hibernate.TestLogger.LOG;
import static org.hibernate.testing.TestLogger.LOG;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;

View File

@ -1,6 +1,6 @@
//$Id$
package org.hibernate.ejb.test.emops;
import static org.hibernate.TestLogger.LOG;
import static org.hibernate.testing.TestLogger.LOG;
import java.util.Map;
import javax.persistence.EntityManager;
import javax.persistence.OptimisticLockException;

View File

@ -1,6 +1,6 @@
// $Id$
package org.hibernate.ejb.test.exception;
import static org.hibernate.TestLogger.LOG;
import static org.hibernate.testing.TestLogger.LOG;
import java.util.Map;
import javax.persistence.EntityManager;
import javax.persistence.EntityNotFoundException;

View File

@ -1,6 +1,6 @@
//$Id$
package org.hibernate.ejb.test.lock;
import static org.hibernate.TestLogger.LOG;
import static org.hibernate.testing.TestLogger.LOG;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

View File

@ -22,7 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.components;
import static org.hibernate.TestLogger.LOG;
import static org.hibernate.testing.TestLogger.LOG;
import java.math.BigInteger;
import java.util.Arrays;
import javax.persistence.EntityManager;

View File

@ -27,7 +27,7 @@ dependencies {
type = 'jar'
}
}
testCompile(project(':hibernate-core').sourceSets.test.classes)
testCompile( project(':hibernate-testing') )
testCompile([group: 'org.jboss', name: 'jboss-common-core', version: '2.2.14.GA'])
testCompile([group: 'org.jboss.naming', name: 'jnp-client', version: jnpVersion])
testCompile([group: 'org.jboss.naming', name: 'jnpserver', version: jnpVersion])

View File

@ -22,7 +22,9 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.cache.infinispan;
import java.util.Properties;
import org.hibernate.cache.CacheDataDescription;
import org.hibernate.cache.RegionFactory;
import org.hibernate.cache.TransactionalDataRegion;
@ -31,6 +33,8 @@ import org.hibernate.cache.infinispan.InfinispanRegionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.jta.platform.internal.JtaPlatformInitiator;
import org.junit.Test;
import org.hibernate.testing.ServiceRegistryBuilder;
import org.hibernate.test.cache.infinispan.util.CacheTestUtil;
@ -46,25 +50,21 @@ import static org.junit.Assert.assertTrue;
* @since 3.5
*/
public abstract class AbstractEntityCollectionRegionTestCase extends AbstractRegionImplTestCase {
/**
* Creates a Region backed by an PESSIMISTIC locking JBoss Cache, and then ensures that it
* handles calls to buildAccessStrategy as expected when all the various {@link AccessType}s are
* passed as arguments.
*/
@Test
public void testSupportedAccessTypes() throws Exception {
supportedAccessTypeTest();
}
private void supportedAccessTypeTest() throws Exception {
Configuration cfg = CacheTestUtil.buildConfiguration("test", InfinispanRegionFactory.class, true, false);
Configuration cfg = CacheTestUtil.buildConfiguration( "test", InfinispanRegionFactory.class, true, false );
String entityCfg = "entity";
cfg.setProperty(InfinispanRegionFactory.ENTITY_CACHE_RESOURCE_PROP, entityCfg);
cfg.setProperty( InfinispanRegionFactory.ENTITY_CACHE_RESOURCE_PROP, entityCfg );
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
ServiceRegistryBuilder.buildServiceRegistry( cfg.getProperties() ),
cfg,
getCacheTestSupport()
);
supportedAccessTypeTest(regionFactory, cfg.getProperties());
supportedAccessTypeTest( regionFactory, cfg.getProperties() );
}
/**
@ -74,22 +74,20 @@ public abstract class AbstractEntityCollectionRegionTestCase extends AbstractReg
*/
protected abstract void supportedAccessTypeTest(RegionFactory regionFactory, Properties properties);
/**
* Test that the Region properly implements {@link TransactionalDataRegion#isTransactionAware()}.
*
* @throws Exception
*/
@Test
public void testIsTransactionAware() throws Exception {
Configuration cfg = CacheTestUtil.buildConfiguration("test", InfinispanRegionFactory.class, true, false);
Configuration cfg = CacheTestUtil.buildConfiguration( "test", InfinispanRegionFactory.class, true, false );
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
ServiceRegistryBuilder.buildServiceRegistry( cfg.getProperties() ),
cfg,
getCacheTestSupport()
);
TransactionalDataRegion region = (TransactionalDataRegion) createRegion(regionFactory, "test/test", cfg.getProperties(), getCacheDataDescription());
assertTrue("Region is transaction-aware", region.isTransactionAware());
CacheTestUtil.stopRegionFactory(regionFactory, getCacheTestSupport());
cfg = CacheTestUtil.buildConfiguration("test", InfinispanRegionFactory.class, true, false);
TransactionalDataRegion region = (TransactionalDataRegion) createRegion(
regionFactory, "test/test", cfg.getProperties(), getCacheDataDescription()
);
assertTrue( "Region is transaction-aware", region.isTransactionAware() );
CacheTestUtil.stopRegionFactory( regionFactory, getCacheTestSupport() );
cfg = CacheTestUtil.buildConfiguration( "test", InfinispanRegionFactory.class, true, false );
// Make it non-transactional
cfg.getProperties().remove( JtaPlatformInitiator.JTA_PLATFORM );
regionFactory = CacheTestUtil.startRegionFactory(
@ -97,24 +95,29 @@ public abstract class AbstractEntityCollectionRegionTestCase extends AbstractReg
cfg,
getCacheTestSupport()
);
region = (TransactionalDataRegion) createRegion(regionFactory, "test/test", cfg.getProperties(), getCacheDataDescription());
assertFalse("Region is not transaction-aware", region.isTransactionAware());
CacheTestUtil.stopRegionFactory(regionFactory, getCacheTestSupport());
region = (TransactionalDataRegion) createRegion(
regionFactory, "test/test", cfg.getProperties(), getCacheDataDescription()
);
assertFalse( "Region is not transaction-aware", region.isTransactionAware() );
CacheTestUtil.stopRegionFactory( regionFactory, getCacheTestSupport() );
}
@Test
public void testGetCacheDataDescription() throws Exception {
Configuration cfg = CacheTestUtil.buildConfiguration("test", InfinispanRegionFactory.class, true, false);
Configuration cfg = CacheTestUtil.buildConfiguration( "test", InfinispanRegionFactory.class, true, false );
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
ServiceRegistryBuilder.buildServiceRegistry( cfg.getProperties() ),
cfg,
getCacheTestSupport()
);
TransactionalDataRegion region = (TransactionalDataRegion) createRegion(regionFactory, "test/test", cfg.getProperties(), getCacheDataDescription());
TransactionalDataRegion region = (TransactionalDataRegion) createRegion(
regionFactory, "test/test", cfg.getProperties(), getCacheDataDescription()
);
CacheDataDescription cdd = region.getCacheDataDescription();
assertNotNull(cdd);
assertNotNull( cdd );
CacheDataDescription expected = getCacheDataDescription();
assertEquals(expected.isMutable(), cdd.isMutable());
assertEquals(expected.isVersioned(), cdd.isVersioned());
assertEquals(expected.getVersionComparator(), cdd.getVersionComparator());
assertEquals( expected.isMutable(), cdd.isMutable() );
assertEquals( expected.isVersioned(), cdd.isVersioned() );
assertEquals( expected.getVersionComparator(), cdd.getVersionComparator() );
}
}

View File

@ -39,7 +39,7 @@ import org.junit.Test;
import org.hibernate.test.cache.infinispan.util.CacheTestUtil;
import static org.hibernate.TestLogger.LOG;
import static org.hibernate.testing.TestLogger.LOG;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

View File

@ -35,7 +35,7 @@ import org.junit.Before;
import org.hibernate.test.cache.infinispan.util.CacheTestSupport;
import static org.hibernate.TestLogger.LOG;
import static org.hibernate.testing.TestLogger.LOG;
/**
* Base class for all non-functional tests of Infinispan integration.

View File

@ -54,7 +54,7 @@ import org.hibernate.test.cache.infinispan.NodeEnvironment;
import org.hibernate.test.cache.infinispan.functional.cluster.DualNodeJtaTransactionManagerImpl;
import org.hibernate.test.cache.infinispan.util.CacheTestUtil;
import static org.hibernate.TestLogger.LOG;
import static org.hibernate.testing.TestLogger.LOG;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;

View File

@ -22,9 +22,8 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.cache.infinispan.collection;
import org.hibernate.cache.access.AccessType;
import org.junit.Test;
import org.hibernate.cache.access.AccessType;
/**
* Base class for tests of TRANSACTIONAL access.
@ -32,7 +31,6 @@ import org.junit.Test;
* @author <a href="brian.stansberry@jboss.com">Brian Stansberry</a>
*/
public abstract class AbstractReadOnlyAccessTestCase extends AbstractCollectionRegionAccessStrategyTestCase {
@Test
@Override
protected AccessType getAccessType() {
return AccessType.READ_ONLY;

View File

@ -56,6 +56,7 @@ public class TransactionalExtraAPITestCase extends AbstractNonFunctionalTestCase
@Before
public final void prepareLocalAccessStrategy() throws Exception {
environment = new NodeEnvironment( createConfiguration() );
environment.prepare();
// Sleep a bit to avoid concurrent FLUSH problem
avoidConcurrentFlush();

View File

@ -46,7 +46,7 @@ import org.hibernate.test.cache.infinispan.AbstractNonFunctionalTestCase;
import org.hibernate.test.cache.infinispan.NodeEnvironment;
import org.hibernate.test.cache.infinispan.util.CacheTestUtil;
import static org.hibernate.testing.TestingLogger.LOG;
import static org.hibernate.testing.TestLogger.LOG;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

View File

@ -32,7 +32,7 @@ import org.hibernate.cache.access.AccessType;
import junit.framework.AssertionFailedError;
import static org.hibernate.TestLogger.LOG;
import static org.hibernate.testing.TestLogger.LOG;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

View File

@ -20,13 +20,12 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.hibernate.test.cache.infinispan.entity;
import org.hibernate.cache.EntityRegion;
import org.hibernate.cache.access.AccessType;
import org.hibernate.cache.access.EntityRegionAccessStrategy;
import org.hibernate.cache.access.SoftLock;
import org.hibernate.cache.infinispan.InfinispanRegionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.internal.ServiceRegistryImpl;
import org.junit.After;
import org.junit.Before;
@ -61,6 +60,7 @@ public class TransactionalExtraAPITestCase extends AbstractNonFunctionalTestCase
@Before
public final void prepareLocalAccessStrategy() throws Exception {
environment = new NodeEnvironment( createConfiguration() );
environment.prepare();
// Sleep a bit to avoid concurrent FLUSH problem
avoidConcurrentFlush();

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.cache.infinispan.functional;
import java.io.Serializable;
import java.util.Map;
@ -56,6 +57,9 @@ public class BasicTransactionalTestCase extends SingleNodeTestCase {
@Test
public void testEntityCache() throws Exception {
Statistics stats = sessionFactory().getStatistics();
stats.clear();
Item item = new Item( "chris", "Chris's Item" );
beginTx();
try {
@ -78,7 +82,6 @@ public class BasicTransactionalTestCase extends SingleNodeTestCase {
try {
Session s = openSession();
Item found = (Item) s.load( Item.class, item.getId() );
Statistics stats = s.getSessionFactory().getStatistics();
log.info( stats.toString() );
assertEquals( item.getDescription(), found.getDescription() );
assertEquals( 0, stats.getSecondLevelCacheMissCount() );
@ -96,6 +99,9 @@ public class BasicTransactionalTestCase extends SingleNodeTestCase {
@Test
public void testCollectionCache() throws Exception {
Statistics stats = sessionFactory().getStatistics();
stats.clear();
Item item = new Item( "chris", "Chris's Item" );
Item another = new Item( "another", "Owned Item" );
item.addItem( another );
@ -133,7 +139,6 @@ public class BasicTransactionalTestCase extends SingleNodeTestCase {
beginTx();
try {
Session s = openSession();
Statistics stats = s.getSessionFactory().getStatistics();
SecondLevelCacheStatistics cStats = stats.getSecondLevelCacheStatistics( Item.class.getName() + ".items" );
Item loadedWithCachedCollection = (Item) s.load( Item.class, item.getId() );
stats.logSummary();
@ -154,6 +159,9 @@ public class BasicTransactionalTestCase extends SingleNodeTestCase {
@Test
public void testStaleWritesLeaveCacheConsistent() throws Exception {
Statistics stats = sessionFactory().getStatistics();
stats.clear();
VersionedItem item = null;
Transaction txn = null;
Session s = null;
@ -203,8 +211,7 @@ public class BasicTransactionalTestCase extends SingleNodeTestCase {
}
// check the version value in the cache...
SecondLevelCacheStatistics slcs = sessionFactory().getStatistics()
.getSecondLevelCacheStatistics( VersionedItem.class.getName() );
SecondLevelCacheStatistics slcs = stats.getSecondLevelCacheStatistics( VersionedItem.class.getName() );
Object entry = slcs.getEntries().get( item.getId() );
Long cachedVersionValue;
@ -231,6 +238,16 @@ public class BasicTransactionalTestCase extends SingleNodeTestCase {
@Test
public void testQueryCacheInvalidation() throws Exception {
Statistics stats = sessionFactory().getStatistics();
stats.clear();
SecondLevelCacheStatistics slcs = stats.getSecondLevelCacheStatistics( Item.class.getName() );
sessionFactory().getCache().evictEntityRegion( Item.class.getName() );
assertEquals( 0, slcs.getPutCount() );
assertEquals( 0, slcs.getElementCountInMemory() );
assertEquals( 0, slcs.getEntries().size() );
Session s = null;
Transaction t = null;
Item i = null;
@ -253,13 +270,10 @@ public class BasicTransactionalTestCase extends SingleNodeTestCase {
commitOrRollbackTx();
}
SecondLevelCacheStatistics slcs = s.getSessionFactory()
.getStatistics()
.getSecondLevelCacheStatistics( Item.class.getName() );
assertEquals( slcs.getPutCount(), 1 );
assertEquals( slcs.getElementCountInMemory(), 1 );
assertEquals( slcs.getEntries().size(), 1 );
assertEquals( 1, slcs.getPutCount() );
assertEquals( 1, slcs.getElementCountInMemory() );
assertEquals( 1, slcs.getEntries().size() );
beginTx();
try {
@ -305,6 +319,9 @@ public class BasicTransactionalTestCase extends SingleNodeTestCase {
@Test
public void testQueryCache() throws Exception {
Statistics stats = sessionFactory().getStatistics();
stats.clear();
Session s;
Item item = new Item( "chris", "Chris's Item" );
@ -344,7 +361,6 @@ public class BasicTransactionalTestCase extends SingleNodeTestCase {
beginTx();
try {
s = openSession();
Statistics stats = s.getSessionFactory().getStatistics();
s.createQuery( "from Item" ).setCacheable( true ).list();
assertEquals( 1, stats.getQueryCacheHitCount() );
s.createQuery( "delete from Item" ).executeUpdate();
@ -360,6 +376,9 @@ public class BasicTransactionalTestCase extends SingleNodeTestCase {
@Test
public void testQueryCacheHitInSameTransaction() throws Exception {
Statistics stats = sessionFactory().getStatistics();
stats.clear();
Session s = null;
Item item = new Item( "galder", "Galder's Item" );
@ -386,7 +405,6 @@ public class BasicTransactionalTestCase extends SingleNodeTestCase {
beginTx();
try {
s = openSession();
Statistics stats = s.getSessionFactory().getStatistics();
s.createQuery( "from Item" ).setCacheable( true ).list();
s.createQuery( "from Item" ).setCacheable( true ).list();
assertEquals( 1, stats.getQueryCacheHitCount() );

View File

@ -52,6 +52,8 @@ import org.hibernate.dialect.Dialect;
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.stat.Statistics;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
@ -115,6 +117,7 @@ public class JndiRegionFactoryTestCase extends SingleNodeTestCase {
cfg.setProperty( "java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces" );
}
@Test
public void testRedeployment() throws Exception {
addEntityCheckCache( sessionFactory() );
sessionFactory().close();

View File

@ -22,7 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.cache.infinispan.functional.classloader;
import static org.hibernate.TestLogger.LOG;
import static org.hibernate.testing.TestLogger.LOG;
import java.util.HashSet;
import java.util.Set;
import org.hibernate.cache.infinispan.util.CacheHelper;

View File

@ -34,11 +34,13 @@ import org.hibernate.cache.StandardQueryCache;
import org.hibernate.cache.infinispan.InfinispanRegionFactory;
import org.hibernate.cfg.Configuration;
import static org.hibernate.TestLogger.LOG;
import static org.hibernate.testing.TestLogger.LOG;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@ -70,29 +72,28 @@ public class IsolatedClassLoaderTest extends DualNodeTestCase {
private Cache remoteQueryCache;
private CacheAccessListener remoteQueryListener;
private static ClassLoader originalClassLoader;
private static ClassLoader originalTCCL;
@BeforeClass
public static void prepareClassLoader() {
originalClassLoader = Thread.currentThread().getContextClassLoader();
ClassLoader parent = originalClassLoader == null
? IsolatedClassLoaderTest.class.getClassLoader()
: originalClassLoader;
ClassLoader selectedTCCL = new SelectedClassnameClassLoader(
new String[] {
org.hibernate.test.cache.infinispan.functional.classloader.Account.class.getName(),
org.hibernate.test.cache.infinispan.functional.classloader.AccountHolder.class.getName()
},
originalTCCL = Thread.currentThread().getContextClassLoader();
final String packageName = IsolatedClassLoaderTest.class.getPackage().getName();
final String[] isolatedClassNames = new String[] { packageName + "Account", packageName + "AccountHolder" };
final SelectedClassnameClassLoader visible = new SelectedClassnameClassLoader(
isolatedClassNames,
null,
null,
parent
originalTCCL
);
Thread.currentThread().setContextClassLoader( selectedTCCL );
Thread.currentThread().setContextClassLoader( visible );
}
@AfterClass
public static void resetClassLoader() {
Thread.currentThread().setContextClassLoader( originalClassLoader );
ClusterAwareRegionFactory.clearCacheManagers();
DualNodeJtaTransactionManagerImpl.cleanupTransactions();
DualNodeJtaTransactionManagerImpl.cleanupTransactionManagers();
Thread.currentThread().setContextClassLoader( originalTCCL );
}
@Override

View File

@ -22,7 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.cache.infinispan.functional.classloader;
import static org.hibernate.TestLogger.LOG;
import static org.hibernate.testing.TestLogger.LOG;
import java.io.ByteArrayOutputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

View File

@ -24,11 +24,15 @@
package org.hibernate.test.cache.infinispan.functional.cluster;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Map;
import org.hibernate.HibernateException;
import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.service.spi.Configurable;
import org.hibernate.service.spi.Stoppable;
import org.hibernate.service.spi.UnknownUnwrapTypeException;
import org.hibernate.test.common.ConnectionProviderBuilder;
import org.hibernate.testing.env.ConnectionProviderBuilder;
/**
* A {@link ConnectionProvider} implementation adding JTA-style transactionality around the returned
@ -36,7 +40,7 @@ import org.hibernate.test.common.ConnectionProviderBuilder;
*
* @author Brian Stansberry
*/
public class DualNodeConnectionProviderImpl implements ConnectionProvider {
public class DualNodeConnectionProviderImpl implements ConnectionProvider, Configurable {
private static ConnectionProvider actualConnectionProvider = ConnectionProviderBuilder.buildConnectionProvider();
private String nodeId;
private boolean isTransactional;
@ -104,4 +108,9 @@ public class DualNodeConnectionProviderImpl implements ConnectionProvider {
public boolean supportsAggressiveRelease() {
return true;
}
@Override
public void configure(Map configurationValues) {
nodeId = (String) configurationValues.get( "nodeId" );
}
}

View File

@ -39,7 +39,7 @@ import org.junit.Test;
import org.hibernate.test.cache.infinispan.functional.classloader.Account;
import org.hibernate.test.cache.infinispan.functional.classloader.ClassLoaderTestDAO;
import static org.hibernate.TestLogger.LOG;
import static org.hibernate.testing.TestLogger.LOG;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

View File

@ -48,7 +48,7 @@ import junit.framework.AssertionFailedError;
import org.hibernate.test.cache.infinispan.AbstractGeneralDataRegionTestCase;
import org.hibernate.test.cache.infinispan.util.CacheTestUtil;
import static org.hibernate.TestLogger.LOG;
import static org.hibernate.testing.TestLogger.LOG;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

View File

@ -27,7 +27,8 @@ import org.hibernate.HibernateException;
import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.service.spi.Stoppable;
import org.hibernate.service.spi.UnknownUnwrapTypeException;
import org.hibernate.test.common.ConnectionProviderBuilder;
import org.hibernate.testing.env.ConnectionProviderBuilder;
/**
* XaConnectionProvider.

View File

@ -31,7 +31,7 @@ import org.infinispan.Cache;
import org.hibernate.cache.RegionFactory;
import static org.hibernate.TestLogger.LOG;
import static org.hibernate.testing.TestLogger.LOG;
/**
* Support class for tracking and cleaning up objects used in tests.

View File

@ -1,3 +1,26 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
apply plugin: 'java'
dependencies {

View File

@ -25,7 +25,7 @@ package org.hibernate.testing;
import org.hibernate.testing.junit4.SkipMarker;
import static org.hibernate.testing.TestingLogger.LOG;
import static org.hibernate.testing.TestLogger.LOG;
/**
* Well-known-location lookup for the test-skip log...

View File

@ -21,16 +21,15 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate;
package org.hibernate.testing;
import org.jboss.logging.BasicLogger;
import org.jboss.logging.Logger;
import org.jboss.logging.MessageLogger;
/**
* Defines internationalized messages for all modules part of hibernate-core.
* Logging support for the hibernate-testing module
*/
@MessageLogger( projectCode = "HHH" )
public interface TestLogger extends BasicLogger {
public static final TestLogger LOG = Logger.getMessageLogger(TestLogger.class, TestLogger.class.getName());
}

View File

@ -1,35 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.testing;
import org.jboss.logging.BasicLogger;
import org.jboss.logging.Logger;
import org.jboss.logging.MessageLogger;
/**
* Logging support for the hibernate-testing module
*/
@MessageLogger( projectCode = "HHH" )
public interface TestingLogger extends BasicLogger {
public static final TestingLogger LOG = Logger.getMessageLogger(TestingLogger.class, TestingLogger.class.getName());
}

View File

@ -1,7 +1,7 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as
* Copyright (c) 2010-2011, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
@ -21,8 +21,10 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.common;
package org.hibernate.testing.env;
import java.util.Properties;
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.H2Dialect;
@ -30,7 +32,7 @@ import org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionPr
import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
/**
* TODO : javadoc
* Defines the JDBC connection information (currently H2) used by Hibernate for unit (not functional!) tests
*
* @author Steve Ebersole
*/