Re-enabled additional tests

This commit is contained in:
Andrea Boriero 2021-08-18 10:15:03 +02:00 committed by Christian Beikov
parent 8d6ada3357
commit 6f32391ed7
12 changed files with 169 additions and 137 deletions

View File

@ -6,7 +6,7 @@
*/ */
//$Id: Account.java 6029 2005-03-06 16:34:16Z oneovthafew $ //$Id: Account.java 6029 2005-03-06 16:34:16Z oneovthafew $
package org.hibernate.test.propertyref.inheritence.discrim; package org.hibernate.orm.test.propertyref.inheritence.discrim;
/** /**

View File

@ -6,7 +6,7 @@
*/ */
//$Id: Customer.java 6029 2005-03-06 16:34:16Z oneovthafew $ //$Id: Customer.java 6029 2005-03-06 16:34:16Z oneovthafew $
package org.hibernate.test.propertyref.inheritence.discrim; package org.hibernate.orm.test.propertyref.inheritence.discrim;
/** /**

View File

@ -9,7 +9,7 @@
"-//Hibernate/Hibernate Mapping DTD 3.0//EN" "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="org.hibernate.test.propertyref.inheritence.discrim"> <hibernate-mapping package="org.hibernate.orm.test.propertyref.inheritence.discrim">
<class name="Person" discriminator-value="null" table="D_SBCLS_PROPREF_PERS"> <class name="Person" discriminator-value="null" table="D_SBCLS_PROPREF_PERS">
<id name="id"> <id name="id">

View File

@ -6,7 +6,7 @@
*/ */
//$Id: Person.java 6029 2005-03-06 16:34:16Z oneovthafew $ //$Id: Person.java 6029 2005-03-06 16:34:16Z oneovthafew $
package org.hibernate.test.propertyref.inheritence.discrim; package org.hibernate.orm.test.propertyref.inheritence.discrim;

View File

@ -0,0 +1,79 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* 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>.
*/
package org.hibernate.orm.test.propertyref.inheritence.discrim;
import org.hibernate.Hibernate;
import org.hibernate.testing.orm.junit.DomainModel;
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.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author Gavin King
*/
@DomainModel(
xmlMappings = "org/hibernate/orm/test/propertyref/inheritence/discrim/Person.hbm.xml"
)
@SessionFactory
public class SubclassPropertyRefTest {
@BeforeEach
public void setUp(SessionFactoryScope scope){
scope.inTransaction(
session -> {
Customer c = new Customer();
c.setName( "Emmanuel" );
c.setCustomerId( "C123-456" );
c.setPersonId( "P123-456" );
Account a = new Account();
a.setCustomer( c );
a.setPerson( c );
a.setType( 'X' );
session.persist( c );
session.persist( a );
}
);
}
@AfterEach
public void tearDown(SessionFactoryScope scope){
scope.inTransaction(
session -> {
session.createQuery( "delete from Account" ).executeUpdate();
session.createQuery( "delete from Person" ).executeUpdate();
}
);
}
@Test
public void testOneToOnePropertyRef(SessionFactoryScope scope) {
scope.inTransaction(
session -> {
Account a = (Account) session.createQuery(
"from Account acc join fetch acc.customer join fetch acc.person" )
.uniqueResult();
assertNotNull( a.getCustomer() );
assertTrue( Hibernate.isInitialized( a.getCustomer() ) );
assertNotNull( a.getPerson() );
assertTrue( Hibernate.isInitialized( a.getPerson() ) );
Customer c = (Customer) session.createQuery( "from Customer" ).uniqueResult();
assertSame( a.getCustomer(), c );
assertSame( a.getPerson(), c );
session.delete( a );
session.delete( a.getCustomer() );
session.delete( a.getPerson() );
}
);
}
}

View File

@ -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.propertyref.inheritence.union; package org.hibernate.orm.test.propertyref.inheritence.union;
/** /**

View File

@ -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.propertyref.inheritence.union; package org.hibernate.orm.test.propertyref.inheritence.union;
/** /**

View File

@ -9,7 +9,7 @@
"-//Hibernate/Hibernate Mapping DTD 3.0//EN" "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="org.hibernate.test.propertyref.inheritence.union"> <hibernate-mapping package="org.hibernate.orm.test.propertyref.inheritence.union">
<class name="Person" table="U_SBCLS_PROPREF_PERS"> <class name="Person" table="U_SBCLS_PROPREF_PERS">
<id name="id"> <id name="id">

View File

@ -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.propertyref.inheritence.union; package org.hibernate.orm.test.propertyref.inheritence.union;
/** /**

View File

@ -0,0 +1,82 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* 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>.
*/
package org.hibernate.orm.test.propertyref.inheritence.union;
import org.hibernate.Hibernate;
import org.hibernate.testing.orm.junit.DomainModel;
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.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author Gavin King
*/
@DomainModel(
xmlMappings = "org/hibernate/orm/test/propertyref/inheritence/union/Person.hbm.xml"
)
@SessionFactory
public class UnionSubclassPropertyRefTest {
@BeforeEach
public void setUp(SessionFactoryScope scope) {
scope.inTransaction(
session -> {
Customer c = new Customer();
c.setName( "Emmanuel" );
c.setCustomerId( "C123-456" );
c.setPersonId( "P123-456" );
Account a = new Account();
a.setCustomer( c );
a.setPerson( c );
a.setType( 'X' );
session.persist( c );
session.persist( a );
}
);
}
@AfterEach
public void tearDown(SessionFactoryScope scope) {
scope.inTransaction(
session -> {
session.createQuery( "delete from Account" ).executeUpdate();
session.createQuery( "delete from Person" ).executeUpdate();
session.createQuery( "delete from Customer" ).executeUpdate();
}
);
}
@Test
public void testOneToOnePropertyRef(SessionFactoryScope scope) {
scope.inTransaction(
session -> {
Account a = (Account) session.createQuery(
"from Account acc join fetch acc.customer join fetch acc.person" )
.uniqueResult();
assertNotNull( a.getCustomer() );
assertTrue( Hibernate.isInitialized( a.getCustomer() ) );
assertNotNull( a.getPerson() );
assertTrue( Hibernate.isInitialized( a.getPerson() ) );
Customer c = (Customer) session.createQuery( "from Customer" ).uniqueResult();
assertSame( a.getCustomer(), c );
assertSame( a.getPerson(), c );
session.delete( a );
session.delete( a.getCustomer() );
session.delete( a.getPerson() );
}
);
}
}

View File

@ -1,65 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* 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>.
*/
package org.hibernate.test.propertyref.inheritence.discrim;
import org.junit.Test;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* @author Gavin King
*/
public class SubclassPropertyRefTest extends BaseCoreFunctionalTestCase {
@Override
public String[] getMappings() {
return new String[] { "propertyref/inheritence/discrim/Person.hbm.xml" };
}
@Test
public void testOneToOnePropertyRef() {
Session s = openSession();
Transaction t = s.beginTransaction();
Customer c = new Customer();
c.setName( "Emmanuel" );
c.setCustomerId( "C123-456" );
c.setPersonId( "P123-456" );
Account a = new Account();
a.setCustomer( c );
a.setPerson( c );
a.setType( 'X' );
s.persist( c );
s.persist( a );
t.commit();
s.close();
s = openSession();
t = s.beginTransaction();
a = ( Account ) s.createQuery( "from Account acc join fetch acc.customer join fetch acc.person" )
.uniqueResult();
assertNotNull( a.getCustomer() );
assertTrue( Hibernate.isInitialized( a.getCustomer() ) );
assertNotNull( a.getPerson() );
assertTrue( Hibernate.isInitialized( a.getPerson() ) );
c = ( Customer ) s.createQuery( "from Customer" ).uniqueResult();
assertSame( c, a.getCustomer() );
assertSame( c, a.getPerson() );
s.delete( a );
s.delete( a.getCustomer() );
s.delete( a.getPerson() );
t.commit();
s.close();
}
}

View File

@ -1,64 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* 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>.
*/
package org.hibernate.test.propertyref.inheritence.union;
import org.junit.Test;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* @author Gavin King
*/
public class UnionSubclassPropertyRefTest extends BaseCoreFunctionalTestCase {
@Override
public String[] getMappings() {
return new String[] { "propertyref/inheritence/union/Person.hbm.xml" };
}
@Test
public void testOneToOnePropertyRef() {
Session s = openSession();
Transaction t = s.beginTransaction();
Customer c = new Customer();
c.setName( "Emmanuel" );
c.setCustomerId( "C123-456" );
c.setPersonId( "P123-456" );
Account a = new Account();
a.setCustomer( c );
a.setPerson( c );
a.setType( 'X' );
s.persist( c );
s.persist( a );
t.commit();
s.close();
s = openSession();
t = s.beginTransaction();
a = ( Account ) s.createQuery( "from Account acc join fetch acc.customer join fetch acc.person" )
.uniqueResult();
assertNotNull( a.getCustomer() );
assertTrue( Hibernate.isInitialized( a.getCustomer() ) );
assertNotNull( a.getPerson() );
assertTrue( Hibernate.isInitialized( a.getPerson() ) );
c = ( Customer ) s.createQuery( "from Customer" ).uniqueResult();
assertSame( c, a.getCustomer() );
assertSame( c, a.getPerson() );
s.delete( a );
s.delete( a.getCustomer() );
s.delete( a.getPerson() );
t.commit();
s.close();
}
}