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;
@ -389,7 +389,9 @@ 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());
@ -419,7 +421,9 @@ public class DynamicFilterTest extends BaseCoreFunctionalTestCase {
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());

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;
@ -217,8 +216,16 @@ public class BulkManipulationTest extends BaseCoreFunctionalTestCase {
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;
@ -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(

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,11 +50,7 @@ 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();
}
@ -74,11 +74,7 @@ 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 );
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
@ -86,7 +82,9 @@ public abstract class AbstractEntityCollectionRegionTestCase extends AbstractReg
cfg,
getCacheTestSupport()
);
TransactionalDataRegion region = (TransactionalDataRegion) createRegion(regionFactory, "test/test", cfg.getProperties(), getCacheDataDescription());
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 );
@ -97,11 +95,14 @@ public abstract class AbstractEntityCollectionRegionTestCase extends AbstractReg
cfg,
getCacheTestSupport()
);
region = (TransactionalDataRegion) createRegion(regionFactory, "test/test", cfg.getProperties(), getCacheDataDescription());
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 );
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
@ -109,7 +110,9 @@ public abstract class AbstractEntityCollectionRegionTestCase extends AbstractReg
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 );
CacheDataDescription expected = getCacheDataDescription();

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
*/