Re-enabled additional tests
This commit is contained in:
parent
05ea5d2c79
commit
8dbac8d44c
|
@ -6,7 +6,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//$Id: Employee.java 6298 2005-04-03 03:56:22Z oneovthafew $
|
//$Id: Employee.java 6298 2005-04-03 03:56:22Z oneovthafew $
|
||||||
package org.hibernate.test.unconstrained;
|
package org.hibernate.orm.test.unconstrained;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -10,7 +10,7 @@
|
||||||
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
||||||
|
|
||||||
<hibernate-mapping
|
<hibernate-mapping
|
||||||
package="org.hibernate.test.unconstrained"
|
package="org.hibernate.orm.test.unconstrained"
|
||||||
default-access="field">
|
default-access="field">
|
||||||
|
|
||||||
<class name="Person"
|
<class name="Person"
|
|
@ -6,7 +6,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//$Id: Person.java 6298 2005-04-03 03:56:22Z oneovthafew $
|
//$Id: Person.java 6298 2005-04-03 03:56:22Z oneovthafew $
|
||||||
package org.hibernate.test.unconstrained;
|
package org.hibernate.orm.test.unconstrained;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -4,7 +4,7 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.unconstrained;
|
package org.hibernate.orm.test.unconstrained;
|
||||||
|
|
||||||
import javax.persistence.criteria.CriteriaBuilder;
|
import javax.persistence.criteria.CriteriaBuilder;
|
||||||
import javax.persistence.criteria.CriteriaQuery;
|
import javax.persistence.criteria.CriteriaQuery;
|
||||||
|
@ -12,36 +12,55 @@ import javax.persistence.criteria.JoinType;
|
||||||
import javax.persistence.criteria.Root;
|
import javax.persistence.criteria.Root;
|
||||||
|
|
||||||
import org.hibernate.Hibernate;
|
import org.hibernate.Hibernate;
|
||||||
|
import org.hibernate.cache.spi.CacheImplementor;
|
||||||
|
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.orm.junit.DomainModel;
|
||||||
import org.junit.Test;
|
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||||
|
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||||
|
import org.junit.jupiter.api.AfterEach;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
|
||||||
import static org.junit.Assert.assertNull;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Gavin King
|
* @author Gavin King
|
||||||
*/
|
*/
|
||||||
public class UnconstrainedTest extends BaseCoreFunctionalTestCase {
|
@DomainModel(
|
||||||
@Override
|
xmlMappings = "org/hibernate/orm/test/unconstrained/Person.hbm.xml"
|
||||||
public String[] getMappings() {
|
)
|
||||||
return new String[] { "unconstrained/Person.hbm.xml" };
|
@SessionFactory
|
||||||
}
|
public class UnconstrainedTest {
|
||||||
|
|
||||||
@Test
|
@BeforeEach
|
||||||
public void testUnconstrainedNoCache() {
|
public void setUp(SessionFactoryScope scope) {
|
||||||
inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
Person p = new Person( "gavin" );
|
Person p = new Person( "gavin" );
|
||||||
p.setEmployeeId( "123456" );
|
p.setEmployeeId( "123456" );
|
||||||
session.persist( p );
|
session.persist( p );
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
sessionFactory().getCache().evictEntityRegion( Person.class );
|
@AfterEach
|
||||||
|
public void tearDown(SessionFactoryScope scope) {
|
||||||
|
scope.inTransaction(
|
||||||
|
session ->
|
||||||
|
session.createQuery( "delete from Person" ).executeUpdate()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
inTransaction(
|
@Test
|
||||||
|
public void testUnconstrainedNoCache(SessionFactoryScope scope) {
|
||||||
|
|
||||||
|
final CacheImplementor cache = scope.getSessionFactory().getCache();
|
||||||
|
cache.evictEntityRegion( Person.class );
|
||||||
|
|
||||||
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
Person p = session.get( Person.class, "gavin" );
|
Person p = session.get( Person.class, "gavin" );
|
||||||
assertNull( p.getEmployee() );
|
assertNull( p.getEmployee() );
|
||||||
|
@ -49,9 +68,9 @@ public class UnconstrainedTest extends BaseCoreFunctionalTestCase {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
sessionFactory().getCache().evictEntityRegion( Person.class );
|
cache.evictEntityRegion( Person.class );
|
||||||
|
|
||||||
inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
Person p = session.get( Person.class, "gavin" );
|
Person p = session.get( Person.class, "gavin" );
|
||||||
assertTrue( Hibernate.isInitialized( p.getEmployee() ) );
|
assertTrue( Hibernate.isInitialized( p.getEmployee() ) );
|
||||||
|
@ -62,18 +81,13 @@ public class UnconstrainedTest extends BaseCoreFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUnconstrainedOuterJoinFetch() {
|
public void testUnconstrainedOuterJoinFetch(SessionFactoryScope scope) {
|
||||||
inTransaction(
|
|
||||||
session -> {
|
|
||||||
Person p = new Person( "gavin" );
|
|
||||||
p.setEmployeeId( "123456" );
|
|
||||||
session.persist( p );
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
sessionFactory().getCache().evictEntityRegion( Person.class );
|
final CacheImplementor cache = scope.getSessionFactory().getCache();
|
||||||
|
|
||||||
inTransaction(
|
cache.evictEntityRegion( Person.class );
|
||||||
|
|
||||||
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
CriteriaBuilder criteriaBuilder = session.getCriteriaBuilder();
|
CriteriaBuilder criteriaBuilder = session.getCriteriaBuilder();
|
||||||
CriteriaQuery<Person> criteria = criteriaBuilder.createQuery( Person.class );
|
CriteriaQuery<Person> criteria = criteriaBuilder.createQuery( Person.class );
|
||||||
|
@ -90,10 +104,9 @@ public class UnconstrainedTest extends BaseCoreFunctionalTestCase {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
cache.evictEntityRegion( Person.class );
|
||||||
|
|
||||||
sessionFactory().getCache().evictEntityRegion( Person.class );
|
scope.inTransaction(
|
||||||
|
|
||||||
inTransaction(
|
|
||||||
session -> {
|
session -> {
|
||||||
CriteriaBuilder criteriaBuilder = session.getCriteriaBuilder();
|
CriteriaBuilder criteriaBuilder = session.getCriteriaBuilder();
|
||||||
CriteriaQuery<Person> criteria = criteriaBuilder.createQuery( Person.class );
|
CriteriaQuery<Person> criteria = criteriaBuilder.createQuery( Person.class );
|
||||||
|
@ -114,16 +127,9 @@ public class UnconstrainedTest extends BaseCoreFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUnconstrained() {
|
public void testUnconstrained(SessionFactoryScope scope) {
|
||||||
inTransaction(
|
|
||||||
session -> {
|
|
||||||
Person p = new Person( "gavin" );
|
|
||||||
p.setEmployeeId( "123456" );
|
|
||||||
session.persist( p );
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
Person p = session.get( Person.class, "gavin" );
|
Person p = session.get( Person.class, "gavin" );
|
||||||
assertNull( p.getEmployee() );
|
assertNull( p.getEmployee() );
|
||||||
|
@ -131,7 +137,7 @@ public class UnconstrainedTest extends BaseCoreFunctionalTestCase {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
Person p = session.get( Person.class, "gavin" );
|
Person p = session.get( Person.class, "gavin" );
|
||||||
assertTrue( Hibernate.isInitialized( p.getEmployee() ) );
|
assertTrue( Hibernate.isInitialized( p.getEmployee() ) );
|
Loading…
Reference in New Issue