FailureExpectedWithNewMetamodel cleanup
This commit is contained in:
parent
4f66feea77
commit
c3e8f4a007
|
@ -28,12 +28,10 @@ import java.util.List;
|
|||
import org.hibernate.Criteria;
|
||||
import org.hibernate.Session;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Tests that when using cached prepared statement with batching enabled doesn't bleed over into new transactions.
|
||||
|
|
|
@ -53,6 +53,15 @@ def osgiDescription() {
|
|||
return pomDescription()
|
||||
}
|
||||
|
||||
test {
|
||||
testLogging {
|
||||
// make test events logged as LIFECYCLE so they show up in console
|
||||
// this, e.g., allows us to see the name of each test as Gradle starts
|
||||
// it, so we can see where (if) the build hangs in tests
|
||||
events "started", "skipped", "failed"
|
||||
}
|
||||
}
|
||||
|
||||
jar {
|
||||
manifest {
|
||||
mainAttributes( 'Main-Class': 'org.hibernate.Version' )
|
||||
|
|
|
@ -45,6 +45,8 @@ import org.hibernate.service.StandardServiceInitiators;
|
|||
import org.hibernate.service.internal.ProvidedService;
|
||||
import org.hibernate.service.spi.ServiceContributor;
|
||||
|
||||
import static org.hibernate.jaxb.spi.cfg.JaxbHibernateConfiguration.JaxbSessionFactory.JaxbProperty;
|
||||
|
||||
/**
|
||||
* Builder for standard {@link org.hibernate.service.ServiceRegistry} instances.
|
||||
*
|
||||
|
@ -101,6 +103,10 @@ public class StandardServiceRegistryBuilder {
|
|||
return bootstrapServiceRegistry;
|
||||
}
|
||||
|
||||
public ConfigLoader getConfigLoader() {
|
||||
return configLoader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read settings from a {@link java.util.Properties} file by resource name.
|
||||
*
|
||||
|
@ -157,12 +163,7 @@ public class StandardServiceRegistryBuilder {
|
|||
*/
|
||||
@SuppressWarnings( {"unchecked"})
|
||||
public StandardServiceRegistryBuilder configure(String resourceName) {
|
||||
final JaxbHibernateConfiguration configurationElement = configLoader.loadConfigXmlResource( resourceName );
|
||||
for ( JaxbHibernateConfiguration.JaxbSessionFactory.JaxbProperty xmlProperty : configurationElement.getSessionFactory().getProperty() ) {
|
||||
settings.put( xmlProperty.getName(), xmlProperty.getValue() );
|
||||
}
|
||||
|
||||
return this;
|
||||
return configure( configLoader.loadConfigXmlResource( resourceName ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -176,12 +177,7 @@ public class StandardServiceRegistryBuilder {
|
|||
*/
|
||||
@SuppressWarnings( {"unchecked"})
|
||||
public StandardServiceRegistryBuilder configure(File file) {
|
||||
final JaxbHibernateConfiguration configurationElement = configLoader.loadConfigFile( file );
|
||||
for ( JaxbHibernateConfiguration.JaxbSessionFactory.JaxbProperty xmlProperty : configurationElement.getSessionFactory().getProperty() ) {
|
||||
settings.put( xmlProperty.getName(), xmlProperty.getValue() );
|
||||
}
|
||||
|
||||
return this;
|
||||
return configure( configLoader.loadConfigFile( file ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -196,13 +192,35 @@ public class StandardServiceRegistryBuilder {
|
|||
@SuppressWarnings( {"unchecked"})
|
||||
public StandardServiceRegistryBuilder configure(URL configFileUrl) {
|
||||
final JaxbHibernateConfiguration configurationElement = configLoader.loadConfig( configFileUrl );
|
||||
for ( JaxbHibernateConfiguration.JaxbSessionFactory.JaxbProperty xmlProperty : configurationElement.getSessionFactory().getProperty() ) {
|
||||
for ( JaxbProperty xmlProperty : configurationElement.getSessionFactory().getProperty() ) {
|
||||
settings.put( xmlProperty.getName(), xmlProperty.getValue() );
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads configuration values from the JAXB representation of the legacy {@code cfg.xml} XML format.
|
||||
*
|
||||
* @param jaxbHibernateConfiguration The JAXB model
|
||||
*
|
||||
* @return this, for method chaining
|
||||
*
|
||||
* @see #loadProperties(String)
|
||||
*/
|
||||
@SuppressWarnings( {"unchecked"})
|
||||
public StandardServiceRegistryBuilder configure(JaxbHibernateConfiguration jaxbHibernateConfiguration) {
|
||||
for ( JaxbProperty xmlProperty : jaxbHibernateConfiguration.getSessionFactory().getProperty() ) {
|
||||
String settingName = xmlProperty.getName();
|
||||
if ( !settingName.startsWith( "hibernate." ) ) {
|
||||
settingName = "hibernate." + settingName;
|
||||
}
|
||||
settings.put( settingName, xmlProperty.getValue() );
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply a setting value.
|
||||
*
|
||||
|
|
|
@ -57,7 +57,9 @@ import org.hibernate.engine.ResultSetMappingDefinition;
|
|||
import org.hibernate.engine.spi.NamedQueryDefinition;
|
||||
import org.hibernate.engine.spi.NamedSQLQueryDefinition;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.internal.util.xml.XmlDocument;
|
||||
import org.hibernate.jaxb.spi.cfg.JaxbHibernateConfiguration;
|
||||
import org.hibernate.mapping.AuxiliaryDatabaseObject;
|
||||
import org.hibernate.metamodel.MetadataBuilder;
|
||||
import org.hibernate.metamodel.MetadataSources;
|
||||
|
@ -74,6 +76,8 @@ import org.hibernate.usertype.UserType;
|
|||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import static org.hibernate.jaxb.spi.cfg.JaxbHibernateConfiguration.JaxbSessionFactory.JaxbMapping;
|
||||
|
||||
/**
|
||||
* An instance of <tt>Configuration</tt> allows the application
|
||||
* to specify properties and mapping documents to be used when
|
||||
|
@ -249,8 +253,7 @@ public class Configuration {
|
|||
* @see #configure(String)
|
||||
*/
|
||||
public Configuration configure() throws HibernateException {
|
||||
standardServiceRegistryBuilder.configure();
|
||||
return this;
|
||||
return configure( StandardServiceRegistryBuilder.DEFAULT_CFG_RESOURCE_NAME );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -264,10 +267,34 @@ public class Configuration {
|
|||
* @throws HibernateException Generally indicates we cannot find the named resource
|
||||
*/
|
||||
public Configuration configure(String resource) throws HibernateException {
|
||||
standardServiceRegistryBuilder.configure( resource );
|
||||
final JaxbHibernateConfiguration jaxbHibernateConfiguration = standardServiceRegistryBuilder.getConfigLoader()
|
||||
.loadConfigXmlResource( resource );
|
||||
doConfigure( jaxbHibernateConfiguration );
|
||||
return this;
|
||||
}
|
||||
|
||||
private void doConfigure(JaxbHibernateConfiguration jaxbHibernateConfiguration) {
|
||||
standardServiceRegistryBuilder.configure( jaxbHibernateConfiguration );
|
||||
|
||||
for ( JaxbMapping jaxbMapping : jaxbHibernateConfiguration.getSessionFactory().getMapping() ) {
|
||||
if ( StringHelper.isNotEmpty( jaxbMapping.getClazz() ) ) {
|
||||
addResource( jaxbMapping.getClazz().replace( '.', '/' ) + ".hbm.xml" );
|
||||
}
|
||||
else if ( StringHelper.isNotEmpty( jaxbMapping.getFile() ) ) {
|
||||
addFile( jaxbMapping.getFile() );
|
||||
}
|
||||
else if ( StringHelper.isNotEmpty( jaxbMapping.getJar() ) ) {
|
||||
addJar( new File( jaxbMapping.getJar() ) );
|
||||
}
|
||||
else if ( StringHelper.isNotEmpty( jaxbMapping.getPackage() ) ) {
|
||||
addPackage( jaxbMapping.getPackage() );
|
||||
}
|
||||
else if ( StringHelper.isNotEmpty( jaxbMapping.getResource() ) ) {
|
||||
addResource( jaxbMapping.getResource() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the mappings and properties specified in the given document. The format of the document is defined in
|
||||
* <tt>hibernate-configuration-3.0.dtd</tt>.
|
||||
|
@ -279,7 +306,9 @@ public class Configuration {
|
|||
* @throws HibernateException Generally indicates a problem access the url
|
||||
*/
|
||||
public Configuration configure(URL url) throws HibernateException {
|
||||
standardServiceRegistryBuilder.configure( url );
|
||||
final JaxbHibernateConfiguration jaxbHibernateConfiguration = standardServiceRegistryBuilder.getConfigLoader()
|
||||
.loadConfig( url );
|
||||
doConfigure( jaxbHibernateConfiguration );
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -294,7 +323,9 @@ public class Configuration {
|
|||
* @throws HibernateException Generally indicates a problem access the file
|
||||
*/
|
||||
public Configuration configure(File configFile) throws HibernateException {
|
||||
standardServiceRegistryBuilder.configure( configFile );
|
||||
final JaxbHibernateConfiguration jaxbHibernateConfiguration = standardServiceRegistryBuilder.getConfigLoader()
|
||||
.loadConfigFile( configFile );
|
||||
doConfigure( jaxbHibernateConfiguration );
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,10 +61,14 @@ import org.hibernate.metamodel.spi.binding.Caching;
|
|||
import org.hibernate.metamodel.spi.binding.IdentifierGeneratorDefinition;
|
||||
import org.hibernate.metamodel.spi.binding.InheritanceType;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class EntityHierarchySourceImpl implements EntityHierarchySource {
|
||||
private static final Logger log = Logger.getLogger( EntityHierarchySourceImpl.class );
|
||||
|
||||
private final RootEntitySourceImpl rootEntitySource;
|
||||
private InheritanceType hierarchyInheritanceType = InheritanceType.NO_INHERITANCE;
|
||||
private final Caching caching;
|
||||
|
@ -256,7 +260,17 @@ public class EntityHierarchySourceImpl implements EntityHierarchySource {
|
|||
);
|
||||
}
|
||||
else {
|
||||
throw makeMappingException( "could not determine source of discriminator mapping" );
|
||||
log.debug( "No source for discriminator column/formula found" );
|
||||
return new ColumnAttributeSourceImpl(
|
||||
rootEntitySource.sourceMappingDocument(),
|
||||
null, // root table
|
||||
"class", // the default discriminator column name per-legacy hbm binding
|
||||
sizeSource,
|
||||
discriminatorElement.isInsert() ? TruthValue.TRUE : TruthValue.FALSE,
|
||||
discriminatorElement.isInsert() ? TruthValue.TRUE : TruthValue.FALSE,
|
||||
discriminatorElement.isNotNull() ? TruthValue.FALSE : TruthValue.TRUE
|
||||
);
|
||||
// throw makeMappingException( "could not determine source of discriminator mapping" );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2014, 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.metamodel.spi.binding.cid;
|
||||
|
||||
import javax.persistence.Embeddable;
|
||||
import javax.persistence.EmbeddedId;
|
||||
import javax.persistence.Entity;
|
||||
|
||||
import org.hibernate.id.EntityIdentifierNature;
|
||||
import org.hibernate.metamodel.spi.binding.AttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.AttributeBindingContainer;
|
||||
import org.hibernate.metamodel.spi.binding.BasicAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.EmbeddedAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.EntityBinding;
|
||||
import org.hibernate.metamodel.spi.binding.SingularAttributeBinding;
|
||||
|
||||
import org.hibernate.testing.junit4.BaseAnnotationBindingTestCase;
|
||||
import org.hibernate.testing.junit4.Resources;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hibernate.testing.junit4.ExtraAssertions.assertTyping;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class BasicEmbeddedIdTest extends BaseAnnotationBindingTestCase {
|
||||
@Embeddable
|
||||
public static class CoursePK {
|
||||
public String department;
|
||||
public String code;
|
||||
}
|
||||
|
||||
@Entity
|
||||
public static class Course {
|
||||
@EmbeddedId
|
||||
private CoursePK key;
|
||||
private String title;
|
||||
}
|
||||
|
||||
@Test
|
||||
@Resources( annotatedClasses = {CoursePK.class, Course.class} )
|
||||
public void testBasicUsage() {
|
||||
EntityBinding courseBinding = getEntityBinding( Course.class );
|
||||
assertEquals( 2, courseBinding.getAttributeBindingClosureSpan() );
|
||||
|
||||
EmbeddedAttributeBinding keyBinding = locateAttributeBinding( courseBinding, "key", EmbeddedAttributeBinding.class );
|
||||
assertEquals( 2, keyBinding.getEmbeddableBinding().attributeBindingSpan() );
|
||||
|
||||
assertEquals(
|
||||
EntityIdentifierNature.AGGREGATED_COMPOSITE,
|
||||
courseBinding.getHierarchyDetails().getEntityIdentifier().getNature()
|
||||
);
|
||||
SingularAttributeBinding identifierAttribute = courseBinding.getHierarchyDetails().getEntityIdentifier().getAttributeBinding();
|
||||
// NOTE : same does '=='
|
||||
assertSame( keyBinding, identifierAttribute );
|
||||
|
||||
BasicAttributeBinding titleBinding = locateAttributeBinding( courseBinding, "title", BasicAttributeBinding.class );
|
||||
}
|
||||
|
||||
private <T extends AttributeBinding> T locateAttributeBinding(
|
||||
AttributeBindingContainer attributeContainer,
|
||||
String attributeName,
|
||||
Class<T> expectedType) {
|
||||
AttributeBinding attributeBinding = attributeContainer.locateAttributeBinding( attributeName );
|
||||
assertNotNull( "Could not locate attribute named " + attributeName, attributeBinding );
|
||||
return assertTyping( expectedType, attributeBinding );
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -23,20 +23,19 @@
|
|||
*/
|
||||
package org.hibernate.test.annotations.access.xml;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.AccessType;
|
||||
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.metamodel.MetadataSources;
|
||||
import org.hibernate.property.BasicPropertyAccessor;
|
||||
import org.hibernate.property.DirectPropertyAccessor;
|
||||
import org.hibernate.tuple.entity.EntityTuplizer;
|
||||
|
||||
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||
import org.hibernate.tuple.entity.EntityTuplizer;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -59,6 +58,7 @@ public class XmlAccessTest extends BaseUnitTestCase {
|
|||
// without any xml configuration we have field access
|
||||
assertAccessType( factory, classUnderTest, AccessType.FIELD );
|
||||
factory.close();
|
||||
|
||||
// now with an additional xml configuration file changing the default access type for Tourist using basic
|
||||
configFiles = new ArrayList<String>();
|
||||
configFiles.add( "org/hibernate/test/annotations/access/xml/Tourist.xml" );
|
||||
|
@ -184,15 +184,15 @@ public class XmlAccessTest extends BaseUnitTestCase {
|
|||
private SessionFactoryImplementor buildSessionFactory(List<Class<?>> classesUnderTest, List<String> configFiles) {
|
||||
assert classesUnderTest != null;
|
||||
assert configFiles != null;
|
||||
Configuration cfg = new Configuration();
|
||||
|
||||
MetadataSources metadataSources = new MetadataSources();
|
||||
for ( Class<?> clazz : classesUnderTest ) {
|
||||
cfg.addAnnotatedClass( clazz );
|
||||
metadataSources.addAnnotatedClass( clazz );
|
||||
}
|
||||
for ( String configFile : configFiles ) {
|
||||
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream( configFile );
|
||||
cfg.addInputStream( is );
|
||||
metadataSources.addResource( configFile );
|
||||
}
|
||||
return ( SessionFactoryImplementor ) cfg.buildSessionFactory();
|
||||
return ( SessionFactoryImplementor ) metadataSources.buildMetadata().buildSessionFactory();
|
||||
}
|
||||
|
||||
// uses the first getter of the tupelizer for the assertions
|
||||
|
|
|
@ -27,16 +27,16 @@ import java.util.ArrayList;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.Query;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.criterion.Disjunction;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
|
||||
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
@ -46,7 +46,10 @@ import static org.junit.Assert.assertNotNull;
|
|||
*
|
||||
* @author Emmanuel Bernard
|
||||
*/
|
||||
@FailureExpectedWithNewMetamodel
|
||||
@FailureExpectedWithNewMetamodel(
|
||||
message = "Problem processing one of the composite ids, but as there are sooooooooooo many its " +
|
||||
"hard to tell which specifically causes the problem"
|
||||
)
|
||||
public class CompositeIdTest extends BaseCoreFunctionalTestCase {
|
||||
@Test
|
||||
public void testOneToOneInCompositePk() throws Exception {
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
package org.hibernate.test.cfg.cache;
|
||||
|
||||
import org.hibernate.cfg.Configuration;
|
||||
|
||||
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -36,6 +38,9 @@ public class CacheConfigurationTest extends BaseUnitTestCase {
|
|||
public static final String CFG_XML = "org/hibernate/test/cfg/cache/hibernate.cfg.xml";
|
||||
|
||||
@Test
|
||||
@FailureExpectedWithNewMetamodel(
|
||||
message = "problem handling 'spread' hbm inheritance with explicit extends XML attribute"
|
||||
)
|
||||
public void testCacheConfiguration() throws Exception {
|
||||
// we only care if the SF builds successfully.
|
||||
Configuration cfg = new Configuration().configure(CFG_XML);
|
||||
|
|
|
@ -23,18 +23,17 @@
|
|||
*/
|
||||
package org.hibernate.test.collection.lazynocascade;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
||||
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* @author Vasily Kochnev
|
||||
*/
|
||||
@FailureExpectedWithNewMetamodel
|
||||
public class LazyAssociationNoCascadeTest extends BaseCoreFunctionalTestCase {
|
||||
|
||||
public String[] getMappings() {
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
package org.hibernate.test.cache;
|
||||
|
||||
import net.sf.ehcache.CacheManager;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.cache.ehcache.management.impl.EhcacheStatsImpl;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
|
@ -13,13 +15,19 @@ import static org.junit.Assert.assertThat;
|
|||
* @author Alex Snaps
|
||||
*/
|
||||
public class EhcacheStatsImplTest {
|
||||
|
||||
private static CacheManager manager;
|
||||
private static EhcacheStatsImpl stats;
|
||||
|
||||
@BeforeClass
|
||||
public static void createCache() throws Exception {
|
||||
CacheManager manager = CacheManager.getInstance();
|
||||
manager = CacheManager.getInstance();
|
||||
stats = new EhcacheStatsImpl( manager );
|
||||
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void stopCache() {
|
||||
manager.shutdown();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -1,52 +1,72 @@
|
|||
package org.hibernate.test.cache;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.cache.ehcache.internal.strategy.ItemValueExtractor;
|
||||
import org.hibernate.cache.spi.access.SoftLock;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.stat.QueryStatistics;
|
||||
import org.hibernate.stat.SecondLevelCacheStatistics;
|
||||
import org.hibernate.stat.Statistics;
|
||||
|
||||
import org.hibernate.testing.AfterClassOnce;
|
||||
import org.hibernate.testing.BeforeClassOnce;
|
||||
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
||||
import org.hibernate.testing.OnExpectedFailure;
|
||||
import org.hibernate.testing.OnFailure;
|
||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||
import org.hibernate.test.domain.Event;
|
||||
import org.hibernate.test.domain.EventManager;
|
||||
import org.hibernate.test.domain.Item;
|
||||
import org.hibernate.test.domain.Person;
|
||||
import org.hibernate.test.domain.PhoneNumber;
|
||||
import org.hibernate.test.domain.VersionedItem;
|
||||
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
* @author Chris Dennis
|
||||
* @author Brett Meyer
|
||||
*/
|
||||
@FailureExpectedWithNewMetamodel
|
||||
public class HibernateCacheTest extends BaseCoreFunctionalTestCase {
|
||||
public class HibernateCacheTest extends BaseUnitTestCase {
|
||||
private SessionFactory sessionFactory;
|
||||
|
||||
@BeforeClassOnce
|
||||
public void before() {
|
||||
System.setProperty( "derby.system.home", "target/derby" );
|
||||
sessionFactory = new Configuration()
|
||||
.configure( "hibernate-config/hibernate.cfg.xml" )
|
||||
.setProperty( AvailableSettings.GENERATE_STATISTICS, "true" )
|
||||
.setProperty( AvailableSettings.HBM2DDL_AUTO, "create-drop" )
|
||||
.buildSessionFactory();
|
||||
}
|
||||
|
||||
@AfterClassOnce
|
||||
public void after() {
|
||||
if ( sessionFactory != null ) {
|
||||
sessionFactory.close();
|
||||
}
|
||||
}
|
||||
|
||||
@OnFailure
|
||||
@OnExpectedFailure
|
||||
public void handleFailure() {
|
||||
after();
|
||||
before();
|
||||
}
|
||||
|
||||
private static final String REGION_PREFIX = "hibernate.test.";
|
||||
|
||||
@Override
|
||||
protected void configure(Configuration config) {
|
||||
System.setProperty( "derby.system.home", "target/derby" );
|
||||
config.configure( "hibernate-config/hibernate.cfg.xml" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void afterSessionFactoryBuilt() {
|
||||
sessionFactory().getStatistics().setStatisticsEnabled( true );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryCacheInvalidation() throws Exception {
|
||||
Session s = sessionFactory().openSession();
|
||||
|
@ -99,6 +119,10 @@ public class HibernateCacheTest extends BaseCoreFunctionalTestCase {
|
|||
s.close();
|
||||
}
|
||||
|
||||
private SessionFactory sessionFactory() {
|
||||
return sessionFactory;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmptySecondLevelCacheEntry() throws Exception {
|
||||
sessionFactory().evictEntity( Item.class.getName() );
|
||||
|
@ -181,6 +205,10 @@ public class HibernateCacheTest extends BaseCoreFunctionalTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
@FailureExpectedWithNewMetamodel(
|
||||
message="Attempts to bind too many jdbc parameters during insert of PhoneNumber; the issue " +
|
||||
"is the mishandling of virtual attributes such as _identifierMapper and backrefs"
|
||||
)
|
||||
public void testGeneralUsage() {
|
||||
EventManager mgr = new EventManager( sessionFactory() );
|
||||
Statistics stats = sessionFactory().getStatistics();
|
||||
|
|
Loading…
Reference in New Issue