mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-28 06:49:09 +00:00
Re-enable additional tests
This commit is contained in:
parent
7fa5d45175
commit
b436392167
@ -4,7 +4,7 @@
|
||||
* 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.mapping.usertypes;
|
||||
package org.hibernate.orm.test.mapping.usertypes;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.PreparedStatement;
|
@ -8,7 +8,7 @@
|
||||
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
||||
|
||||
<hibernate-mapping>
|
||||
<class name="org.hibernate.test.mapping.usertypes.TestEntity"
|
||||
<class name="org.hibernate.orm.test.mapping.usertypes.TestEntity"
|
||||
table="TestTable">
|
||||
<id name="id" column="ID" type="integer">
|
||||
<generator class="uuid"/>
|
@ -4,7 +4,7 @@
|
||||
* 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.mapping.usertypes;
|
||||
package org.hibernate.orm.test.mapping.usertypes;
|
||||
|
||||
public class TestEntity {
|
||||
private int id;
|
@ -4,7 +4,7 @@
|
||||
* 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.mapping.usertypes;
|
||||
package org.hibernate.orm.test.mapping.usertypes;
|
||||
|
||||
public enum TestEnum {
|
||||
FOO,
|
@ -8,7 +8,7 @@
|
||||
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
||||
|
||||
<hibernate-mapping>
|
||||
<typedef name="testenumtype" class="org.hibernate.test.mapping.usertypes.EnumUserType">
|
||||
<param name="enumClassName">org.hibernate.test.mapping.usertypes.TestEnum</param>
|
||||
<typedef name="testenumtype" class="org.hibernate.orm.test.mapping.usertypes.EnumUserType">
|
||||
<param name="enumClassName">org.hibernate.orm.test.mapping.usertypes.TestEnum</param>
|
||||
</typedef>
|
||||
</hibernate-mapping>
|
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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.mapping.usertypes;
|
||||
|
||||
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
|
||||
import org.hibernate.testing.ServiceRegistryBuilder;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.orm.junit.BaseUnitTest;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Test for read-order independent resolution of user-defined types
|
||||
* Testcase for issue HHH-7300
|
||||
*
|
||||
* @author Stefan Schulze
|
||||
*/
|
||||
@TestForIssue(jiraKey = "HHH-7300")
|
||||
@BaseUnitTest
|
||||
public class UserTypeMappingTest {
|
||||
|
||||
private Configuration cfg;
|
||||
private ServiceRegistry serviceRegistry;
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
cfg = new Configuration();
|
||||
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( cfg.getProperties() );
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
if ( serviceRegistry != null ) {
|
||||
ServiceRegistryBuilder.destroy( serviceRegistry );
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFirstTypeThenEntity() {
|
||||
cfg.addResource( "org/hibernate/orm/test/mapping/usertypes/TestEnumType.hbm.xml" )
|
||||
.addResource( "org/hibernate/orm/test/mapping/usertypes/TestEntity.hbm.xml" );
|
||||
SessionFactory sessions = cfg.buildSessionFactory( serviceRegistry );
|
||||
assertNotNull( sessions );
|
||||
sessions.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFirstEntityThenType() {
|
||||
cfg.addResource( "org/hibernate/orm/test/mapping/usertypes/TestEntity.hbm.xml" )
|
||||
.addResource( "org/hibernate/orm/test/mapping/usertypes/TestEnumType.hbm.xml" );
|
||||
|
||||
SessionFactory sessions = cfg.buildSessionFactory( serviceRegistry );
|
||||
assertNotNull( sessions );
|
||||
sessions.close();
|
||||
}
|
||||
|
||||
}
|
@ -7,7 +7,7 @@
|
||||
|
||||
//$Id: Document.java 8670 2005-11-25 17:36:29Z epbernard $
|
||||
|
||||
package org.hibernate.test.mixed;
|
||||
package org.hibernate.orm.test.mixed;
|
||||
import java.sql.Blob;
|
||||
import java.util.Calendar;
|
||||
|
@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
//$Id: DocumentInterceptor.java 8670 2005-11-25 17:36:29Z epbernard $
|
||||
package org.hibernate.test.mixed;
|
||||
package org.hibernate.orm.test.mixed;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Calendar;
|
@ -7,7 +7,7 @@
|
||||
|
||||
//$Id: Folder.java 8670 2005-11-25 17:36:29Z epbernard $
|
||||
|
||||
package org.hibernate.test.mixed;
|
||||
package org.hibernate.orm.test.mixed;
|
||||
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
||||
|
||||
<hibernate-mapping
|
||||
|
||||
package="org.hibernate.test.mixed">
|
||||
package="org.hibernate.orm.test.mixed">
|
||||
|
||||
|
||||
<class name="Item"
|
@ -7,7 +7,7 @@
|
||||
|
||||
//$Id: Item.java 8670 2005-11-25 17:36:29Z epbernard $
|
||||
|
||||
package org.hibernate.test.mixed;
|
||||
package org.hibernate.orm.test.mixed;
|
||||
|
||||
|
||||
|
@ -0,0 +1,131 @@
|
||||
/*
|
||||
* 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.mixed;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.dialect.SybaseDialect;
|
||||
|
||||
import org.hibernate.testing.SkipLog;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||
import org.hibernate.testing.orm.junit.SkipForDialect;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
/**
|
||||
* @author Gavin King
|
||||
*/
|
||||
@SkipForDialect(dialectClass = SybaseDialect.class, version = 1500)
|
||||
@DomainModel(xmlMappings = "org/hibernate/orm/test/mixed/Item.hbm.xml")
|
||||
@SessionFactory
|
||||
public class MixedTest {
|
||||
|
||||
@Test
|
||||
public void testMixedInheritance(SessionFactoryScope scope) {
|
||||
Document doc = new Document();
|
||||
SecureDocument doc2 = new SecureDocument();
|
||||
try (final Session session = scope.getSessionFactory()
|
||||
.withOptions()
|
||||
.interceptor( new DocumentInterceptor() )
|
||||
.openSession()) {
|
||||
session.beginTransaction();
|
||||
try {
|
||||
Folder f = new Folder();
|
||||
f.setName( "/" );
|
||||
session.save( f );
|
||||
|
||||
doc.setName( "Hibernate in Action" );
|
||||
doc.setContent( session.getLobHelper().createBlob( "blah blah blah".getBytes() ) );
|
||||
doc.setParent( f );
|
||||
session.save( doc );
|
||||
|
||||
doc2.setName( "Secret" );
|
||||
doc2.setContent( session.getLobHelper().createBlob( "wxyz wxyz".getBytes() ) );
|
||||
// SybaseASE15Dialect only allows 7-bits in a byte to be inserted into a tinyint
|
||||
// column (0 <= val < 128)
|
||||
doc2.setPermissionBits( (byte) 127 );
|
||||
doc2.setOwner( "gavin" );
|
||||
doc2.setParent( f );
|
||||
session.save( doc2 );
|
||||
session.getTransaction().commit();
|
||||
}
|
||||
finally {
|
||||
if ( session.getTransaction().isActive() ) {
|
||||
session.getTransaction().rollback();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Long did = doc.getId();
|
||||
Long d2id = doc2.getId();
|
||||
|
||||
if ( !scope.getSessionFactory().getDialect().supportsExpectedLobUsagePattern() ) {
|
||||
SkipLog.reportSkip( "database/driver does not support expected LOB usage pattern", "LOB support" );
|
||||
return;
|
||||
}
|
||||
|
||||
try (final Session session = scope.getSessionFactory()
|
||||
.withOptions()
|
||||
.interceptor( new DocumentInterceptor() )
|
||||
.openSession()) {
|
||||
session.beginTransaction();
|
||||
try {
|
||||
Item id = session.load( Item.class, did );
|
||||
assertEquals( did, id.getId() );
|
||||
assertEquals( "Hibernate in Action", id.getName() );
|
||||
assertEquals( "/", id.getParent().getName() );
|
||||
|
||||
Item id2 = session.load( Item.class, d2id );
|
||||
assertEquals( d2id, id2.getId() );
|
||||
assertEquals( "Secret", id2.getName() );
|
||||
assertEquals( "/", id2.getParent().getName() );
|
||||
|
||||
id.setName( "HiA" );
|
||||
|
||||
SecureDocument d2 = session.load( SecureDocument.class, d2id );
|
||||
d2.setOwner( "max" );
|
||||
|
||||
session.flush();
|
||||
|
||||
session.clear();
|
||||
|
||||
Document d = session.load( Document.class, did );
|
||||
assertEquals( did, d.getId() );
|
||||
assertEquals( "HiA", d.getName() );
|
||||
assertNotNull( d.getContent() );
|
||||
assertEquals( "/", d.getParent().getName() );
|
||||
assertNotNull( d.getCreated() );
|
||||
assertNotNull( d.getModified() );
|
||||
|
||||
d2 = session.load( SecureDocument.class, d2id );
|
||||
assertEquals( d2id, d2.getId() );
|
||||
assertEquals( "Secret", d2.getName() );
|
||||
assertNotNull( d2.getContent() );
|
||||
assertEquals( "max", d2.getOwner() );
|
||||
assertEquals( "/", d2.getParent().getName() );
|
||||
// SybaseASE15Dialect only allows 7-bits in a byte to be inserted into a tinyint
|
||||
// column (0 <= val < 128)
|
||||
assertEquals( (byte) 127, d2.getPermissionBits() );
|
||||
assertNotNull( d2.getCreated() );
|
||||
assertNotNull( d2.getModified() );
|
||||
|
||||
session.delete( d.getParent() );
|
||||
session.delete( d );
|
||||
session.delete( d2 );
|
||||
}
|
||||
finally {
|
||||
if ( session.getTransaction().isActive() ) {
|
||||
session.getTransaction().rollback();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
//$Id: SecureDocument.java 8670 2005-11-25 17:36:29Z epbernard $
|
||||
|
||||
package org.hibernate.test.mixed;
|
||||
package org.hibernate.orm.test.mixed;
|
||||
|
||||
|
||||
|
@ -1,72 +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.mapping.usertypes;
|
||||
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.testing.ServiceRegistryBuilder;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Test for read-order independent resolution of user-defined types
|
||||
* Testcase for issue HHH-7300
|
||||
* @author Stefan Schulze
|
||||
*/
|
||||
@TestForIssue(jiraKey = "HHH-7300")
|
||||
public class UserTypeMappingTest extends BaseUnitTestCase{
|
||||
|
||||
private Configuration cfg;
|
||||
private ServiceRegistry serviceRegistry;
|
||||
|
||||
@Before
|
||||
public void setup(){
|
||||
cfg=new Configuration();
|
||||
Properties p = new Properties();
|
||||
p.put( Environment.DIALECT, "org.hibernate.dialect.HSQLDialect" );
|
||||
p.put( "hibernate.connection.driver_class", "org.h2.Driver" );
|
||||
p.put( "hibernate.connection.url", "jdbc:h2:mem:" );
|
||||
p.put( "hibernate.connection.username", "sa" );
|
||||
p.put( "hibernate.connection.password", "" );
|
||||
cfg.setProperties(p);
|
||||
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( cfg.getProperties() );
|
||||
}
|
||||
|
||||
public void tearDown(){
|
||||
if(serviceRegistry!=null){
|
||||
ServiceRegistryBuilder.destroy( serviceRegistry );
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFirstTypeThenEntity(){
|
||||
cfg.addResource("org/hibernate/test/mapping/usertypes/TestEnumType.hbm.xml")
|
||||
.addResource("org/hibernate/test/mapping/usertypes/TestEntity.hbm.xml");
|
||||
SessionFactory sessions=cfg.buildSessionFactory(serviceRegistry);
|
||||
Assert.assertNotNull(sessions);
|
||||
sessions.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFirstEntityThenType(){
|
||||
cfg.addResource("org/hibernate/test/mapping/usertypes/TestEntity.hbm.xml")
|
||||
.addResource("org/hibernate/test/mapping/usertypes/TestEnumType.hbm.xml");
|
||||
|
||||
SessionFactory sessions=cfg.buildSessionFactory(serviceRegistry);
|
||||
Assert.assertNotNull(sessions);
|
||||
sessions.close();
|
||||
}
|
||||
|
||||
}
|
@ -1,112 +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.mixed;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.dialect.SybaseASE15Dialect;
|
||||
|
||||
import org.hibernate.testing.SkipForDialect;
|
||||
import org.hibernate.testing.SkipLog;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* @author Gavin King
|
||||
*/
|
||||
@SkipForDialect( SybaseASE15Dialect.class )
|
||||
public class MixedTest extends BaseCoreFunctionalTestCase {
|
||||
@Override
|
||||
public String[] getMappings() {
|
||||
return new String[]{"mixed/Item.hbm.xml"};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMixedInheritance() {
|
||||
Session s = openSession( new DocumentInterceptor() );
|
||||
Transaction t = s.beginTransaction();
|
||||
Folder f = new Folder();
|
||||
f.setName( "/" );
|
||||
s.save( f );
|
||||
|
||||
Document d = new Document();
|
||||
d.setName( "Hibernate in Action" );
|
||||
d.setContent( s.getLobHelper().createBlob( "blah blah blah".getBytes() ) );
|
||||
d.setParent( f );
|
||||
Long did = (Long) s.save( d );
|
||||
|
||||
SecureDocument d2 = new SecureDocument();
|
||||
d2.setName( "Secret" );
|
||||
d2.setContent( s.getLobHelper().createBlob( "wxyz wxyz".getBytes() ) );
|
||||
// SybaseASE15Dialect only allows 7-bits in a byte to be inserted into a tinyint
|
||||
// column (0 <= val < 128)
|
||||
d2.setPermissionBits( (byte) 127 );
|
||||
d2.setOwner( "gavin" );
|
||||
d2.setParent( f );
|
||||
Long d2id = (Long) s.save( d2 );
|
||||
|
||||
t.commit();
|
||||
s.close();
|
||||
|
||||
if ( ! getDialect().supportsExpectedLobUsagePattern() ) {
|
||||
SkipLog.reportSkip( "database/driver does not support expected LOB usage pattern", "LOB support" );
|
||||
return;
|
||||
}
|
||||
|
||||
s = openSession( new DocumentInterceptor() );
|
||||
t = s.beginTransaction();
|
||||
Item id = (Item) s.load( Item.class, did );
|
||||
assertEquals( did, id.getId() );
|
||||
assertEquals( "Hibernate in Action", id.getName() );
|
||||
assertEquals( "/", id.getParent().getName() );
|
||||
|
||||
Item id2 = (Item) s.load( Item.class, d2id );
|
||||
assertEquals( d2id, id2.getId() );
|
||||
assertEquals( "Secret", id2.getName() );
|
||||
assertEquals( "/", id2.getParent().getName() );
|
||||
|
||||
id.setName( "HiA" );
|
||||
|
||||
d2 = (SecureDocument) s.load( SecureDocument.class, d2id );
|
||||
d2.setOwner( "max" );
|
||||
|
||||
s.flush();
|
||||
|
||||
s.clear();
|
||||
|
||||
d = (Document) s.load( Document.class, did );
|
||||
assertEquals( did, d.getId() );
|
||||
assertEquals( "HiA", d.getName() );
|
||||
assertNotNull( d.getContent() );
|
||||
assertEquals( "/", d.getParent().getName() );
|
||||
assertNotNull( d.getCreated() );
|
||||
assertNotNull( d.getModified() );
|
||||
|
||||
d2 = (SecureDocument) s.load( SecureDocument.class, d2id );
|
||||
assertEquals( d2id, d2.getId() );
|
||||
assertEquals( "Secret", d2.getName() );
|
||||
assertNotNull( d2.getContent() );
|
||||
assertEquals( "max", d2.getOwner() );
|
||||
assertEquals( "/", d2.getParent().getName() );
|
||||
// SybaseASE15Dialect only allows 7-bits in a byte to be inserted into a tinyint
|
||||
// column (0 <= val < 128)
|
||||
assertEquals( (byte) 127, d2.getPermissionBits() );
|
||||
assertNotNull( d2.getCreated() );
|
||||
assertNotNull( d2.getModified() );
|
||||
|
||||
s.delete( d.getParent() );
|
||||
s.delete( d );
|
||||
s.delete( d2 );
|
||||
|
||||
t.commit();
|
||||
s.close();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user