HHH-5623 - Baseline on JDK 1.6

This commit is contained in:
Steve Ebersole 2010-10-08 13:40:21 -05:00
parent 28a6acdcda
commit 794d07f564
6 changed files with 205 additions and 204 deletions

View File

@ -111,12 +111,13 @@
<build>
<plugins>
<!--
<plugin>
<!-- Needed in order to load the proper 'artifact handler' for the 'jdocbook-style' packaging -->
<groupId>org.jboss.maven.plugins</groupId>
<artifactId>maven-jdocbook-style-plugin</artifactId>
<extensions>true</extensions>
</plugin>
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
@ -191,6 +192,7 @@
</plugins>
<pluginManagement>
<plugins>
<!--
<plugin>
<groupId>org.jboss.maven.plugins</groupId>
<artifactId>maven-jdocbook-plugin</artifactId>
@ -228,8 +230,10 @@
<options>
<xincludeSupported>true</xincludeSupported>
<xmlTransformerType>saxon</xmlTransformerType>
-->
<!-- needed for uri-resolvers; can be ommitted if using 'current' uri scheme -->
<!-- could also locate the docbook dependency and inspect its version... -->
<!--
<docbookVersion>1.72.0</docbookVersion>
<localeSeparator>-</localeSeparator>
</options>
@ -240,6 +244,7 @@
<artifactId>maven-jdocbook-style-plugin</artifactId>
<version>2.0.0</version>
</plugin>
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>

View File

@ -4,10 +4,9 @@ import java.util.HashSet;
import java.util.Set;
/**
* @author Paco Hernández
* @author Paco Hern<EFBFBD>ndez
*/
public class Car implements java.io.Serializable {
private long id;
private String model;
private CarType carType;

View File

@ -1,10 +1,9 @@
package org.hibernate.test.entitymode.dom4j.many2one;
/**
* @author Paco Hernández
* @author Paco Hern<EFBFBD>ndez
*/
public class CarPart implements java.io.Serializable {
private long id;
private String partName;

View File

@ -1,10 +1,9 @@
package org.hibernate.test.entitymode.dom4j.many2one;
/**
* @author Paco Hernández
* @author Paco Hern<EFBFBD>ndez
*/
public class CarType implements java.io.Serializable {
private long id;
private String typeName;

View File

@ -17,7 +17,6 @@ import org.hibernate.testing.junit.functional.FunctionalTestClassTestSuite;
* @author Paco Hern<EFBFBD>ndez
*/
public class Dom4jManyToOneTest extends FunctionalTestCase {
public Dom4jManyToOneTest(String str) {
super( str );
}

View File

@ -1,196 +1,196 @@
//$Id: $
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Middleware LLC 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 Middleware LLC.
*
* 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.test.lob;
import java.sql.Blob;
import junit.framework.AssertionFailedError;
import junit.framework.Test;
import org.hibernate.Hibernate;
import org.hibernate.LockMode;
import org.hibernate.Session;
import org.hibernate.dialect.Dialect;
import org.hibernate.testing.junit.functional.DatabaseSpecificFunctionalTestCase;
import org.hibernate.testing.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.util.ArrayHelper;
/**
* Tests lazy materialization of data mapped by
* {@link org.hibernate.type.BlobType}, as well as bounded and unbounded
* materialization and mutation.
*
* @author Steve Ebersole
*/
public class BlobLocatorTest extends DatabaseSpecificFunctionalTestCase {
private static final int BLOB_SIZE = 10000;
public BlobLocatorTest(String name) {
super( name );
}
public String[] getMappings() {
return new String[] { "lob/LobMappings.hbm.xml" };
}
public static Test suite() {
return new FunctionalTestClassTestSuite( BlobLocatorTest.class );
}
public boolean appliesTo(Dialect dialect) {
if ( ! dialect.supportsExpectedLobUsagePattern() ) {
reportSkip( "database/driver does not support expected LOB usage pattern", "LOB support" );
return false;
}
return true;
}
public void testBoundedBlobLocatorAccess() throws Throwable {
byte[] original = buildRecursively( BLOB_SIZE, true );
byte[] changed = buildRecursively( BLOB_SIZE, false );
Session s = openSession();
s.beginTransaction();
LobHolder entity = new LobHolder();
entity.setBlobLocator( s.getLobHelper().createBlob( original ) );
s.save( entity );
s.getTransaction().commit();
s.close();
s = openSession();
s.beginTransaction();
entity = ( LobHolder ) s.get( LobHolder.class, entity.getId() );
assertEquals( BLOB_SIZE, entity.getBlobLocator().length() );
assertEquals( original, extractData( entity.getBlobLocator() ) );
s.getTransaction().commit();
s.close();
// test mutation via setting the new clob data...
if ( supportsLobValueChangePropogation() ) {
s = openSession();
s.beginTransaction();
entity = ( LobHolder ) s.get( LobHolder.class, entity.getId(), LockMode.UPGRADE );
entity.getBlobLocator().truncate( 1 );
entity.getBlobLocator().setBytes( 1, changed );
s.getTransaction().commit();
s.close();
s = openSession();
s.beginTransaction();
entity = ( LobHolder ) s.get( LobHolder.class, entity.getId(), LockMode.UPGRADE );
assertNotNull( entity.getBlobLocator() );
assertEquals( BLOB_SIZE, entity.getBlobLocator().length() );
assertEquals( changed, extractData( entity.getBlobLocator() ) );
entity.getBlobLocator().truncate( 1 );
entity.getBlobLocator().setBytes( 1, original );
s.getTransaction().commit();
s.close();
}
// test mutation via supplying a new clob locator instance...
s = openSession();
s.beginTransaction();
entity = ( LobHolder ) s.get( LobHolder.class, entity.getId(), LockMode.UPGRADE );
assertNotNull( entity.getBlobLocator() );
assertEquals( BLOB_SIZE, entity.getBlobLocator().length() );
assertEquals( original, extractData( entity.getBlobLocator() ) );
entity.setBlobLocator( s.getLobHelper().createBlob( changed ) );
s.getTransaction().commit();
s.close();
s = openSession();
s.beginTransaction();
entity = ( LobHolder ) s.get( LobHolder.class, entity.getId() );
assertEquals( BLOB_SIZE, entity.getBlobLocator().length() );
assertEquals( changed, extractData( entity.getBlobLocator() ) );
s.delete( entity );
s.getTransaction().commit();
s.close();
}
public void testUnboundedBlobLocatorAccess() throws Throwable {
if ( ! supportsUnboundedLobLocatorMaterialization() ) {
return;
}
// Note: unbounded mutation of the underlying lob data is completely
// unsupported; most databases would not allow such a construct anyway.
// Thus here we are only testing materialization...
byte[] original = buildRecursively( BLOB_SIZE, true );
Session s = openSession();
s.beginTransaction();
LobHolder entity = new LobHolder();
entity.setBlobLocator( Hibernate.createBlob( original ) );
s.save( entity );
s.getTransaction().commit();
s.close();
// load the entity with the clob locator, and close the session/transaction;
// at that point it is unbounded...
s = openSession();
s.beginTransaction();
entity = ( LobHolder ) s.get( LobHolder.class, entity.getId() );
s.getTransaction().commit();
s.close();
assertEquals( BLOB_SIZE, entity.getBlobLocator().length() );
assertEquals( original, extractData( entity.getBlobLocator() ) );
s = openSession();
s.beginTransaction();
s.delete( entity );
s.getTransaction().commit();
s.close();
}
private byte[] extractData(Blob blob) throws Throwable {
return blob.getBytes( 1, ( int ) blob.length() );
}
private byte[] buildRecursively(int size, boolean on) {
byte[] data = new byte[size];
data[0] = mask( on );
for ( int i = 0; i < size; i++ ) {
data[i] = mask( on );
on = !on;
}
return data;
}
private byte mask(boolean on) {
return on ? ( byte ) 1 : ( byte ) 0;
}
public static void assertEquals(byte[] val1, byte[] val2) {
if ( !ArrayHelper.isEquals( val1, val2 ) ) {
throw new AssertionFailedError( "byte arrays did not match" );
}
}
}
//$Id: $
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Middleware LLC 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 Middleware LLC.
*
* 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.test.lob;
import java.sql.Blob;
import junit.framework.AssertionFailedError;
import junit.framework.Test;
import org.hibernate.Hibernate;
import org.hibernate.LockMode;
import org.hibernate.Session;
import org.hibernate.dialect.Dialect;
import org.hibernate.testing.junit.functional.DatabaseSpecificFunctionalTestCase;
import org.hibernate.testing.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.util.ArrayHelper;
/**
* Tests lazy materialization of data mapped by
* {@link org.hibernate.type.BlobType}, as well as bounded and unbounded
* materialization and mutation.
*
* @author Steve Ebersole
*/
public class BlobLocatorTest extends DatabaseSpecificFunctionalTestCase {
private static final int BLOB_SIZE = 10000;
public BlobLocatorTest(String name) {
super( name );
}
public String[] getMappings() {
return new String[] { "lob/LobMappings.hbm.xml" };
}
public static Test suite() {
return new FunctionalTestClassTestSuite( BlobLocatorTest.class );
}
public boolean appliesTo(Dialect dialect) {
if ( ! dialect.supportsExpectedLobUsagePattern() ) {
reportSkip( "database/driver does not support expected LOB usage pattern", "LOB support" );
return false;
}
return true;
}
public void testBoundedBlobLocatorAccess() throws Throwable {
byte[] original = buildRecursively( BLOB_SIZE, true );
byte[] changed = buildRecursively( BLOB_SIZE, false );
Session s = openSession();
s.beginTransaction();
LobHolder entity = new LobHolder();
entity.setBlobLocator( s.getLobHelper().createBlob( original ) );
s.save( entity );
s.getTransaction().commit();
s.close();
s = openSession();
s.beginTransaction();
entity = ( LobHolder ) s.get( LobHolder.class, entity.getId() );
assertEquals( BLOB_SIZE, entity.getBlobLocator().length() );
assertEquals( original, extractData( entity.getBlobLocator() ) );
s.getTransaction().commit();
s.close();
// test mutation via setting the new clob data...
if ( supportsLobValueChangePropogation() ) {
s = openSession();
s.beginTransaction();
entity = ( LobHolder ) s.get( LobHolder.class, entity.getId(), LockMode.UPGRADE );
entity.getBlobLocator().truncate( 1 );
entity.getBlobLocator().setBytes( 1, changed );
s.getTransaction().commit();
s.close();
s = openSession();
s.beginTransaction();
entity = ( LobHolder ) s.get( LobHolder.class, entity.getId(), LockMode.UPGRADE );
assertNotNull( entity.getBlobLocator() );
assertEquals( BLOB_SIZE, entity.getBlobLocator().length() );
assertEquals( changed, extractData( entity.getBlobLocator() ) );
entity.getBlobLocator().truncate( 1 );
entity.getBlobLocator().setBytes( 1, original );
s.getTransaction().commit();
s.close();
}
// test mutation via supplying a new clob locator instance...
s = openSession();
s.beginTransaction();
entity = ( LobHolder ) s.get( LobHolder.class, entity.getId(), LockMode.UPGRADE );
assertNotNull( entity.getBlobLocator() );
assertEquals( BLOB_SIZE, entity.getBlobLocator().length() );
assertEquals( original, extractData( entity.getBlobLocator() ) );
entity.setBlobLocator( s.getLobHelper().createBlob( changed ) );
s.getTransaction().commit();
s.close();
s = openSession();
s.beginTransaction();
entity = ( LobHolder ) s.get( LobHolder.class, entity.getId() );
assertEquals( BLOB_SIZE, entity.getBlobLocator().length() );
assertEquals( changed, extractData( entity.getBlobLocator() ) );
s.delete( entity );
s.getTransaction().commit();
s.close();
}
public void testUnboundedBlobLocatorAccess() throws Throwable {
if ( ! supportsUnboundedLobLocatorMaterialization() ) {
return;
}
// Note: unbounded mutation of the underlying lob data is completely
// unsupported; most databases would not allow such a construct anyway.
// Thus here we are only testing materialization...
byte[] original = buildRecursively( BLOB_SIZE, true );
Session s = openSession();
s.beginTransaction();
LobHolder entity = new LobHolder();
entity.setBlobLocator( Hibernate.getLobCreator( s ).createBlob( original ) );
s.save( entity );
s.getTransaction().commit();
s.close();
// load the entity with the clob locator, and close the session/transaction;
// at that point it is unbounded...
s = openSession();
s.beginTransaction();
entity = ( LobHolder ) s.get( LobHolder.class, entity.getId() );
s.getTransaction().commit();
s.close();
assertEquals( BLOB_SIZE, entity.getBlobLocator().length() );
assertEquals( original, extractData( entity.getBlobLocator() ) );
s = openSession();
s.beginTransaction();
s.delete( entity );
s.getTransaction().commit();
s.close();
}
private byte[] extractData(Blob blob) throws Throwable {
return blob.getBytes( 1, ( int ) blob.length() );
}
private byte[] buildRecursively(int size, boolean on) {
byte[] data = new byte[size];
data[0] = mask( on );
for ( int i = 0; i < size; i++ ) {
data[i] = mask( on );
on = !on;
}
return data;
}
private byte mask(boolean on) {
return on ? ( byte ) 1 : ( byte ) 0;
}
public static void assertEquals(byte[] val1, byte[] val2) {
if ( !ArrayHelper.isEquals( val1, val2 ) ) {
throw new AssertionFailedError( "byte arrays did not match" );
}
}
}