HHH-5942 - Migrate to JUnit 4

This commit is contained in:
Steve Ebersole 2011-03-13 19:58:48 -05:00
parent 20a120ef6c
commit df4df47b95
148 changed files with 4686 additions and 2496 deletions

6
.gitignore vendored
View File

@ -5,8 +5,10 @@
.gradle
# Build output directies
target
build
/target
*/target
/build
*/build
# IntelliJ specific files/directories
out

View File

@ -1,32 +1,65 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.TimeZone;
import org.hibernate.Hibernate;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.StaleStateException;
import org.hibernate.Transaction;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.tool.hbm2ddl.SchemaExport;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
/**
* @author Emmanuel Bernard
*/
public class EntityTest extends TestCase {
private DateFormat df;
public EntityTest(String x) {
super( x );
df = SimpleDateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG);
}
public class EntityTest extends BaseCoreFunctionalTestCase {
private DateFormat df = SimpleDateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG);
@Test
public void testLoad() throws Exception {
//put an object in DB
assertEquals( "Flight", getCfg().getClassMapping( Flight.class.getName() ).getTable().getName() );
assertEquals( "Flight", configuration().getClassMapping( Flight.class.getName() ).getTable().getName() );
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -53,6 +86,7 @@ public class EntityTest extends TestCase {
s.close();
}
@Test
public void testColumn() throws Exception {
//put an object in DB
Session s = openSession();
@ -119,6 +153,7 @@ public class EntityTest extends TestCase {
s.close();
}
@Test
public void testColumnUnique() throws Exception {
Session s;
Transaction tx;
@ -152,6 +187,7 @@ public class EntityTest extends TestCase {
}
}
@Test
public void testUniqueConstraint() throws Exception {
int id = 5;
Session s;
@ -199,6 +235,7 @@ public class EntityTest extends TestCase {
}
}
@Test
public void testVersion() throws Exception {
// put an object in DB
Session s = openSession();
@ -246,9 +283,9 @@ public class EntityTest extends TestCase {
if ( tx != null ) tx.rollback();
s.close();
}
}
@Test
public void testFieldAccess() throws Exception {
Session s;
Transaction tx;
@ -275,8 +312,9 @@ public class EntityTest extends TestCase {
s.close();
}
@Test
public void testEntityName() throws Exception {
assertEquals( "Corporation", getCfg().getClassMapping( Company.class.getName() ).getTable().getName() );
assertEquals( "Corporation", configuration().getClassMapping( Company.class.getName() ).getTable().getName() );
Session s = openSession();
Transaction tx = s.beginTransaction();
Company comp = new Company();
@ -295,6 +333,7 @@ public class EntityTest extends TestCase {
}
@Test
public void testNonGetter() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -318,6 +357,7 @@ public class EntityTest extends TestCase {
s.close();
}
@Test
public void testTemporalType() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -351,6 +391,7 @@ public class EntityTest extends TestCase {
s.close();
}
@Test
public void testBasic() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -372,9 +413,7 @@ public class EntityTest extends TestCase {
}
}
/**
* @see org.hibernate.test.annotations.TestCase#getAnnotatedClasses()
*/
@Override
protected Class[] getAnnotatedClasses() {
return new Class[]{
Flight.class,
@ -383,5 +422,26 @@ public class EntityTest extends TestCase {
};
}
// tests are leaving data around, so drop/recreate schema for now. this is wha the old tests did
@Override
protected boolean createSchema() {
return false;
}
@Before
public void runCreateSchema() {
schemaExport().create( false, true );
}
private SchemaExport schemaExport() {
return new SchemaExport( serviceRegistry().getService( JdbcServices.class ), configuration() );
}
@After
public void runDropSchema() {
schemaExport().drop( false, true );
}
}

View File

@ -1,21 +1,48 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.test.annotations.inheritance.Carrot;
import org.hibernate.test.annotations.inheritance.Tomato;
import org.hibernate.test.annotations.inheritance.Vegetable;
import org.hibernate.test.annotations.inheritance.VegetablePk;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
/**
* @author Emmanuel Bernard
*/
public class JoinedSubclassTest extends TestCase {
public JoinedSubclassTest(String x) {
super( x );
}
public class JoinedSubclassTest extends BaseCoreFunctionalTestCase {
@Test
public void testDefaultValues() {
Session s;
Transaction tx;
@ -39,6 +66,7 @@ public class JoinedSubclassTest extends TestCase {
s.close();
}
@Test
public void testDeclaredValues() {
Session s;
Transaction tx;
@ -66,6 +94,7 @@ public class JoinedSubclassTest extends TestCase {
s.close();
}
@Test
public void testCompositePk() throws Exception {
Session s;
Transaction tx;
@ -91,6 +120,7 @@ public class JoinedSubclassTest extends TestCase {
s.close();
}
@Override
protected Class[] getAnnotatedClasses() {
return new Class[]{
Boat.class,

View File

@ -1,151 +0,0 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010, 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.test.annotations;
import java.io.InputStream;
import org.hibernate.HibernateException;
import org.hibernate.Interceptor;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.testing.junit.functional.annotations.HibernateTestCase;
/**
* A base class for all annotation tests.
*
* @author Emmnauel Bernand
* @author Hardy Ferentschik
*/
public abstract class TestCase extends HibernateTestCase {
protected static SessionFactory sessions;
private Session session;
public TestCase() {
super();
}
public TestCase(String name) {
super( name );
}
public Session openSession() throws HibernateException {
session = getSessions().openSession();
return session;
}
public Session openSession(Interceptor interceptor) throws HibernateException {
session = getSessions().openSession( interceptor );
return session;
}
protected SessionFactory getSessions() {
if ( sessions == null ) {
try {
buildConfiguration();
}
catch ( Exception e ) {
throw new HibernateException( e );
}
}
return sessions;
}
protected SessionFactoryImplementor sfi() {
return (SessionFactoryImplementor) getSessions();
}
@Override
protected void buildConfiguration() throws Exception {
if ( sessions != null ) {
sessions.close();
}
try {
setCfg( new AnnotationConfiguration() );
// by default use the new id generator scheme...
cfg.setProperty( Configuration.USE_NEW_ID_GENERATOR_MAPPINGS, "true" );
configure( cfg );
if ( recreateSchema() ) {
cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
}
for ( String aPackage : getAnnotatedPackages() ) {
( ( AnnotationConfiguration ) getCfg() ).addPackage( aPackage );
}
for ( Class<?> aClass : getAnnotatedClasses() ) {
( ( AnnotationConfiguration ) getCfg() ).addAnnotatedClass( aClass );
}
for ( String xmlFile : getXmlFiles() ) {
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream( xmlFile );
getCfg().addInputStream( is );
}
sessions = getCfg().buildSessionFactory( getServiceRegistry() );
}
catch ( Exception e ) {
e.printStackTrace();
throw e;
}
}
@Override
protected void handleUnclosedResources() {
if ( session != null && session.isOpen() ) {
if ( session.isConnected() ) {
session.doWork( new RollbackWork() );
}
session.close();
session = null;
fail( "unclosed session" );
}
else {
session = null;
}
}
@Override
protected void closeResources() {
try {
if ( session != null && session.isOpen() ) {
if ( session.isConnected() ) {
session.doWork( new RollbackWork() );
}
session.close();
}
}
catch ( Exception ignore ) {
}
try {
if ( sessions != null ) {
sessions.close();
sessions = null;
}
}
catch ( Exception ignore ) {
}
super.closeResources();
}
}

View File

@ -1,14 +1,45 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.access;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
/**
* @author Emmanuel Bernard
*/
public class AccessTest extends TestCase {
public class AccessTest extends BaseCoreFunctionalTestCase {
@Test
public void testSuperclassOverriding() throws Exception {
Furniture fur = new Furniture();
fur.setColor( "Black" );
@ -28,6 +59,7 @@ public class AccessTest extends TestCase {
s.close();
}
@Test
public void testSuperclassNonOverriding() throws Exception {
Furniture fur = new Furniture();
fur.setGod( "Buddha" );

View File

@ -1,4 +1,3 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
@ -23,19 +22,30 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.access.jpa;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.test.annotations.access.Closet;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
/**
* @author Emmanuel Bernard
* @author Hardy Ferentschik
*/
public class AccessTest extends TestCase {
public class AccessTest extends BaseCoreFunctionalTestCase {
@Test
public void testDefaultConfigurationModeIsInherited() throws Exception {
User john = new User();
john.setFirstname( "John" );
@ -62,6 +72,7 @@ public class AccessTest extends TestCase {
s.close();
}
@Test
public void testSuperclassOverriding() throws Exception {
Furniture fur = new Furniture();
fur.setColor( "Black" );
@ -81,6 +92,7 @@ public class AccessTest extends TestCase {
s.close();
}
@Test
public void testSuperclassNonOverriding() throws Exception {
Furniture fur = new Furniture();
fur.setGod( "Buddha" );
@ -97,6 +109,7 @@ public class AccessTest extends TestCase {
s.close();
}
@Test
public void testPropertyOverriding() throws Exception {
Furniture fur = new Furniture();
fur.weight = 3;
@ -114,6 +127,7 @@ public class AccessTest extends TestCase {
}
@Test
public void testNonOverridenSubclass() throws Exception {
Chair chair = new Chair();
chair.setPillow( "Blue" );
@ -128,9 +142,9 @@ public class AccessTest extends TestCase {
s.delete( chair );
tx.commit();
s.close();
}
@Test
public void testOverridenSubclass() throws Exception {
BigBed bed = new BigBed();
bed.size = 5;
@ -147,9 +161,9 @@ public class AccessTest extends TestCase {
s.delete( bed );
tx.commit();
s.close();
}
@Test
public void testFieldsOverriding() throws Exception {
Gardenshed gs = new Gardenshed();
gs.floors = 4;
@ -165,9 +179,9 @@ public class AccessTest extends TestCase {
s.delete( gs );
tx.commit();
s.close();
}
@Test
public void testEmbeddableUsesAccessStrategyOfContainingClass() throws Exception {
Circle circle = new Circle();
Color color = new Color( 5, 10, 15 );
@ -191,6 +205,7 @@ public class AccessTest extends TestCase {
s.close();
}
@Test
public void testEmbeddableExplicitAccessStrategy() throws Exception {
Square square = new Square();
Position pos = new Position( 10, 15 );
@ -214,6 +229,7 @@ public class AccessTest extends TestCase {
s.close();
}
@Override
protected Class[] getAnnotatedClasses() {
return new Class[] {
Bed.class,

View File

@ -1,11 +1,42 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.any;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.test.annotations.TestCase;
public class AnyTest extends TestCase {
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
public class AnyTest extends BaseCoreFunctionalTestCase {
@Test
public void testDefaultAnyAssociation() {
Session s = openSession();
Transaction t = s.beginTransaction();
@ -52,6 +83,7 @@ public class AnyTest extends TestCase {
s.close();
}
@Test
public void testManyToAnyWithMap() throws Exception {
Session s = openSession();
@ -89,6 +121,7 @@ public class AnyTest extends TestCase {
}
@Test
public void testMetaDataUseWithManyToAny() throws Exception {
Session s = openSession();
Transaction t = s.beginTransaction();
@ -149,6 +182,7 @@ public class AnyTest extends TestCase {
};
}
@Override
protected String[] getAnnotatedPackages() {
return new String[] {
"org.hibernate.test.annotations.any"

View File

@ -1,15 +1,44 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.array;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.test.annotations.array.Contest.Month;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
/**
* @author Emmanuel Bernard
*/
public class ArrayTest extends TestCase {
public class ArrayTest extends BaseCoreFunctionalTestCase {
@Test
public void testOneToMany() throws Exception {
Session s;
Transaction tx;
@ -39,15 +68,8 @@ public class ArrayTest extends TestCase {
s.close();
}
public ArrayTest(String x) {
super( x );
}
@SuppressWarnings("unchecked")
@Override
protected Class[] getAnnotatedClasses() {
return new Class[]{
Competitor.class,
Contest.class
};
return new Class[] { Competitor.class, Contest.class };
}
}

View File

@ -21,18 +21,26 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.beanvalidation;
import java.math.BigDecimal;
import javax.validation.ConstraintViolationException;
import java.math.BigDecimal;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
/**
* @author Emmanuel Bernard
*/
public class BeanValidationAutoTest extends TestCase {
public class BeanValidationAutoTest extends BaseCoreFunctionalTestCase {
@Test
public void testListeners() {
CupHolder ch = new CupHolder();
ch.setRadius( new BigDecimal( "12" ) );
@ -50,6 +58,7 @@ public class BeanValidationAutoTest extends TestCase {
s.close();
}
@Override
protected Class<?>[] getAnnotatedClasses() {
return new Class<?>[] {
CupHolder.class

View File

@ -21,21 +21,29 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.beanvalidation;
import java.math.BigDecimal;
import javax.validation.ConstraintViolationException;
import java.math.BigDecimal;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
/**
* @author Emmanuel Bernard
*/
public class BeanValidationDisabledTest extends TestCase {
public class BeanValidationDisabledTest extends BaseCoreFunctionalTestCase {
@Test
public void testListeners() {
CupHolder ch = new CupHolder();
ch.setRadius( new BigDecimal( "12" ) );
@ -52,8 +60,9 @@ public class BeanValidationDisabledTest extends TestCase {
s.close();
}
@Test
public void testDDLDisabled() {
PersistentClass classMapping = getCfg().getClassMapping( Address.class.getName() );
PersistentClass classMapping = configuration().getClassMapping( Address.class.getName() );
Column countryColumn = (Column) classMapping.getProperty( "country" ).getColumnIterator().next();
assertTrue( "DDL constraints are applied", countryColumn.isNullable() );
}
@ -64,6 +73,7 @@ public class BeanValidationDisabledTest extends TestCase {
cfg.setProperty( "javax.persistence.validation.mode", "none" );
}
@Override
protected Class<?>[] getAnnotatedClasses() {
return new Class<?>[] {
Address.class,

View File

@ -21,22 +21,30 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.beanvalidation;
import java.lang.annotation.Annotation;
import java.math.BigDecimal;
import javax.validation.ConstraintViolationException;
import javax.validation.constraints.NotNull;
import javax.validation.groups.Default;
import java.lang.annotation.Annotation;
import java.math.BigDecimal;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
/**
* @author Emmanuel Bernard
*/
public class BeanValidationGroupsTest extends TestCase {
public class BeanValidationGroupsTest extends BaseCoreFunctionalTestCase {
@Test
public void testListeners() {
CupHolder ch = new CupHolder();
ch.setRadius( new BigDecimal( "12" ) );
@ -96,6 +104,7 @@ public class BeanValidationGroupsTest extends TestCase {
cfg.setProperty( "hibernate.validator.apply_to_ddl", "false" );
}
@Override
protected Class<?>[] getAnnotatedClasses() {
return new Class<?>[] {
CupHolder.class

View File

@ -21,23 +21,31 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.beanvalidation;
import java.math.BigDecimal;
import java.util.Locale;
import javax.validation.ConstraintViolationException;
import javax.validation.MessageInterpolator;
import javax.validation.Validation;
import javax.validation.ValidatorFactory;
import java.math.BigDecimal;
import java.util.Locale;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
/**
* @author Emmanuel Bernard
*/
public class BeanValidationProvidedFactoryTest extends TestCase {
public class BeanValidationProvidedFactoryTest extends BaseCoreFunctionalTestCase {
@Test
public void testListeners() {
CupHolder ch = new CupHolder();
ch.setRadius( new BigDecimal( "12" ) );
@ -56,6 +64,7 @@ public class BeanValidationProvidedFactoryTest extends TestCase {
s.close();
}
@Override
protected Class<?>[] getAnnotatedClasses() {
return new Class<?>[] {
CupHolder.class

View File

@ -21,12 +21,20 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.beanvalidation;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
/**
* Test verifying that DDL constraints get applied when Bean Validation / Hibernate Validator are enabled.
@ -34,10 +42,10 @@ import org.hibernate.test.annotations.TestCase;
* @author Emmanuel Bernard
* @author Hardy Ferentschik
*/
public class DDLTest extends TestCase {
public class DDLTest extends BaseCoreFunctionalTestCase {
@Test
public void testBasicDDL() {
PersistentClass classMapping = getCfg().getClassMapping( Address.class.getName() );
PersistentClass classMapping = configuration().getClassMapping( Address.class.getName() );
Column stateColumn = (Column) classMapping.getProperty( "state" ).getColumnIterator().next();
assertEquals( stateColumn.getLength(), 3 );
Column zipColumn = (Column) classMapping.getProperty( "zip" ).getColumnIterator().next();
@ -45,37 +53,38 @@ public class DDLTest extends TestCase {
assertFalse( zipColumn.isNullable() );
}
@Test
public void testApplyOnIdColumn() throws Exception {
PersistentClass classMapping = getCfg().getClassMapping( Tv.class.getName() );
PersistentClass classMapping = configuration().getClassMapping( Tv.class.getName() );
Column serialColumn = (Column) classMapping.getIdentifierProperty().getColumnIterator().next();
assertEquals( "Validator annotation not applied on ids", 2, serialColumn.getLength() );
}
/**
* HHH-5281
*
* @throws Exception in case the test fails
*/
@Test
@TestForIssue( jiraKey = "HHH-5281" )
public void testLengthConstraint() throws Exception {
PersistentClass classMapping = getCfg().getClassMapping( Tv.class.getName() );
PersistentClass classMapping = configuration().getClassMapping( Tv.class.getName() );
Column modelColumn = (Column) classMapping.getProperty( "model" ).getColumnIterator().next();
assertEquals( modelColumn.getLength(), 5 );
}
@Test
public void testApplyOnManyToOne() throws Exception {
PersistentClass classMapping = getCfg().getClassMapping( TvOwner.class.getName() );
PersistentClass classMapping = configuration().getClassMapping( TvOwner.class.getName() );
Column serialColumn = (Column) classMapping.getProperty( "tv" ).getColumnIterator().next();
assertEquals( "Validator annotations not applied on associations", false, serialColumn.isNullable() );
}
@Test
public void testSingleTableAvoidNotNull() throws Exception {
PersistentClass classMapping = getCfg().getClassMapping( Rock.class.getName() );
PersistentClass classMapping = configuration().getClassMapping( Rock.class.getName() );
Column serialColumn = (Column) classMapping.getProperty( "bit" ).getColumnIterator().next();
assertTrue( "Notnull should not be applied on single tables", serialColumn.isNullable() );
}
@Test
public void testNotNullOnlyAppliedIfEmbeddedIsNotNullItself() throws Exception {
PersistentClass classMapping = getCfg().getClassMapping( Tv.class.getName() );
PersistentClass classMapping = configuration().getClassMapping( Tv.class.getName() );
Property property = classMapping.getProperty( "tuner.frequency" );
Column serialColumn = (Column) property.getColumnIterator().next();
assertEquals(
@ -89,6 +98,7 @@ public class DDLTest extends TestCase {
);
}
@Override
protected Class<?>[] getAnnotatedClasses() {
return new Class<?>[] {
Address.class,

View File

@ -21,24 +21,32 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.beanvalidation;
import java.math.BigDecimal;
import javax.validation.ConstraintViolationException;
import java.math.BigDecimal;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.RequiresDialectFeature;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.fail;
/**
* @author Vladimir Klyushnikov
* @author Hardy Ferentschik
*/
public class DDLWithoutCallbackTest extends TestCase {
public class DDLWithoutCallbackTest extends BaseCoreFunctionalTestCase {
@Test
@RequiresDialectFeature(DialectChecks.SupportsColumnCheck.class)
public void testListeners() {
CupHolder ch = new CupHolder();
@ -46,6 +54,7 @@ public class DDLWithoutCallbackTest extends TestCase {
assertDatabaseConstraintViolationThrown( ch );
}
@Test
@RequiresDialectFeature(DialectChecks.SupportsColumnCheck.class)
public void testMinAndMaxChecksGetApplied() {
MinMax minMax = new MinMax( 1 );
@ -63,6 +72,7 @@ public class DDLWithoutCallbackTest extends TestCase {
s.close();
}
@Test
@RequiresDialectFeature(DialectChecks.SupportsColumnCheck.class)
public void testRangeChecksGetApplied() {
Range range = new Range( 1 );
@ -80,8 +90,9 @@ public class DDLWithoutCallbackTest extends TestCase {
s.close();
}
@Test
public void testDDLEnabled() {
PersistentClass classMapping = getCfg().getClassMapping( Address.class.getName() );
PersistentClass classMapping = configuration().getClassMapping( Address.class.getName() );
Column countryColumn = (Column) classMapping.getProperty( "country" ).getColumnIterator().next();
assertFalse( "DDL constraints are not applied", countryColumn.isNullable() );
}
@ -92,6 +103,7 @@ public class DDLWithoutCallbackTest extends TestCase {
cfg.setProperty( "javax.persistence.validation.mode", "ddl" );
}
@Override
protected Class<?>[] getAnnotatedClasses() {
return new Class<?>[] {
Address.class,

View File

@ -21,20 +21,28 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.beanvalidation;
import java.math.BigDecimal;
import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException;
import java.math.BigDecimal;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
/**
* @author Emmanuel Bernard
*/
public class HibernateTraversableResolverTest extends TestCase {
public class HibernateTraversableResolverTest extends BaseCoreFunctionalTestCase {
@Test
public void testNonLazyAssocFieldWithConstraintsFailureExpected() {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -54,6 +62,7 @@ public class HibernateTraversableResolverTest extends TestCase {
s.close();
}
@Test
public void testEmbedded() {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -82,6 +91,7 @@ public class HibernateTraversableResolverTest extends TestCase {
s.close();
}
@Test
public void testToOneAssocNotValidated() {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -106,6 +116,7 @@ public class HibernateTraversableResolverTest extends TestCase {
s.close();
}
@Test
public void testCollectionAssocNotValidated() {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -135,6 +146,7 @@ public class HibernateTraversableResolverTest extends TestCase {
s.close();
}
@Test
public void testEmbeddedCollection() {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -162,6 +174,7 @@ public class HibernateTraversableResolverTest extends TestCase {
s.close();
}
@Test
public void testAssocInEmbeddedNotValidated() {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -201,6 +214,7 @@ public class HibernateTraversableResolverTest extends TestCase {
cfg.setProperty( "hibernate.validator.autoregister_listeners", "false" );
}
@Override
protected Class<?>[] getAnnotatedClasses() {
return new Class<?>[] {
Button.class,

View File

@ -1,51 +1,68 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.bytecode;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.test.annotations.TestCase;
/**
* @author Emmanuel Bernard
*/
public class ProxyBreakingTest extends TestCase {
static {
System.setProperty( "hibernate.bytecode.provider", "javassist" );
}
public void testProxiedBridgeMethod() throws Exception {
//bridge methods should not be proxied
Session s = openSession();
Transaction tx = s.beginTransaction();
Hammer h = new Hammer();
s.save(h);
s.flush();
s.clear();
assertNotNull( "The proxy creation failure is breaking things", h.getId() );
h = (Hammer) s.load( Hammer.class, h.getId() );
assertFalse( Hibernate.isInitialized( h ) );
tx.rollback();
s.close();
}
public ProxyBreakingTest(String name) {
super( name );
}
protected Class[] getAnnotatedClasses() {
return new Class[0];
}
protected String[] getXmlFiles() {
return new String[] {
"org/hibernate/test/annotations/bytecode/Hammer.hbm.xml"
};
}
@Override
protected void configure(Configuration cfg) {
super.configure( cfg.setProperty( "hibernate.bytecode.provider", "javassist" ) );
}
}
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
/**
* @author Emmanuel Bernard
*/
public class ProxyBreakingTest extends BaseCoreFunctionalTestCase {
@Test
public void testProxiedBridgeMethod() throws Exception {
//bridge methods should not be proxied
Session s = openSession();
Transaction tx = s.beginTransaction();
Hammer h = new Hammer();
s.save(h);
s.flush();
s.clear();
assertNotNull( "The proxy creation failure is breaking things", h.getId() );
h = (Hammer) s.load( Hammer.class, h.getId() );
assertFalse( Hibernate.isInitialized( h ) );
tx.rollback();
s.close();
}
@Override
protected Class[] getAnnotatedClasses() {
return new Class[0];
}
@Override
protected String[] getXmlFiles() {
return new String[] {
"org/hibernate/test/annotations/bytecode/Hammer.hbm.xml"
};
}
}

View File

@ -29,15 +29,24 @@ import java.util.ArrayList;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
/**
* Check some of the individual cascade styles
*
* @todo do something for refresh
*
* @author Emmanuel Bernard
*/
//FIXME do somthing for refresh
public class CascadeTest extends TestCase {
public class CascadeTest extends BaseCoreFunctionalTestCase {
@Test
public void testPersist() {
Session s;
Transaction tx;
@ -58,6 +67,7 @@ public class CascadeTest extends TestCase {
s.close();
}
@Test
public void testMerge() {
Session s;
Transaction tx;
@ -95,6 +105,7 @@ public class CascadeTest extends TestCase {
s.close();
}
@Test
public void testRemove() {
Session s;
Transaction tx;
@ -126,6 +137,7 @@ public class CascadeTest extends TestCase {
s.close();
}
@Test
public void testDetach() {
Session s;
Transaction tx;
@ -160,10 +172,7 @@ public class CascadeTest extends TestCase {
s.close();
}
public CascadeTest(String x) {
super( x );
}
@Override
protected Class[] getAnnotatedClasses() {
return new Class[]{
Mouth.class,

View File

@ -1,26 +1,53 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.cid;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
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.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
/**
* test some composite id functionalities
*
* @author Emmanuel Bernard
*/
public class CompositeIdTest extends TestCase {
public CompositeIdTest(String x) {
super( x );
}
public class CompositeIdTest extends BaseCoreFunctionalTestCase {
@Test
public void testOneToOneInCompositePk() throws Exception {
Session s;
Transaction tx;
@ -50,6 +77,7 @@ public class CompositeIdTest extends TestCase {
* This feature is not supported by the EJB3
* this is an hibernate extension
*/
@Test
public void testManyToOneInCompositePk() throws Exception {
Session s;
Transaction tx;
@ -92,6 +120,7 @@ public class CompositeIdTest extends TestCase {
* This feature is not supported by the EJB3
* this is an hibernate extension
*/
@Test
public void testManyToOneInCompositePkAndSubclass() throws Exception {
Session s;
Transaction tx;
@ -131,6 +160,7 @@ public class CompositeIdTest extends TestCase {
s.close();
}
@Test
public void testManyToOneInCompositeId() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -162,6 +192,7 @@ public class CompositeIdTest extends TestCase {
s.close();
}
@Test
public void testManyToOneInCompositeIdClass() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -187,6 +218,7 @@ public class CompositeIdTest extends TestCase {
s.close();
}
@Test
public void testSecondaryTableWithCompositeId() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -220,6 +252,7 @@ public class CompositeIdTest extends TestCase {
s.close();
}
@Test
public void testSecondaryTableWithIdClass() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -250,6 +283,7 @@ public class CompositeIdTest extends TestCase {
s.close();
}
@Test
public void testQueryInAndComposite() {
Session s = openSession( );
@ -271,6 +305,8 @@ public class CompositeIdTest extends TestCase {
transaction.rollback();
s.close();
}
@Test
public void testQueryInAndCompositeWithHQL() {
Session s = openSession( );
Transaction transaction = s.beginTransaction();
@ -288,7 +324,6 @@ public class CompositeIdTest extends TestCase {
s.close();
}
private void createData(Session s){
SomeEntity someEntity = new SomeEntity();
someEntity.setId( new SomeEntityId( ) );
@ -325,6 +360,8 @@ public class CompositeIdTest extends TestCase {
someEntity.setProp( "cc3" );
s.persist( someEntity );
}
@Override
protected Class[] getAnnotatedClasses() {
return new Class[] {
Parent.class,

View File

@ -22,15 +22,22 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.cid.keymanytoone;
import org.hibernate.Session;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.fail;
/**
* TODO : javadoc
*
* @author Steve Ebersole
*/
public class EagerKeyManyToOneTest extends TestCase {
public class EagerKeyManyToOneTest extends BaseCoreFunctionalTestCase {
public static final String CARD_ID = "cardId";
public static final String KEY_ID = "keyId";
@ -39,6 +46,8 @@ public class EagerKeyManyToOneTest extends TestCase {
return new Class[] { Card.class, CardField.class, Key.class, PrimaryKey.class };
}
@Test
@TestForIssue( jiraKey = "HHH-4147" )
public void testLoadEntityWithEagerFetchingToKeyManyToOneReferenceBackToSelf() {
// based on the core testsuite test of same name in org.hibernate.test.keymanytoone.bidir.component.EagerKeyManyToOneTest
// meant to test against regression relating to http://opensource.atlassian.com/projects/hibernate/browse/HHH-2277

View File

@ -1,29 +1,60 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.collectionelement;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import org.hibernate.Filter;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.mapping.Collection;
import org.hibernate.mapping.Column;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.test.annotations.Country;
import org.hibernate.test.annotations.TestCase;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
/**
* @author Emmanuel Bernard
* @author Hardy Ferentschik
*/
@SuppressWarnings("unchecked")
public class CollectionElementTest extends TestCase {
public class CollectionElementTest extends BaseCoreFunctionalTestCase {
@Test
public void testSimpleElement() throws Exception {
assertEquals(
"BoyFavoriteNumbers",
getCfg().getCollectionMapping( Boy.class.getName() + '.' + "favoriteNumbers" )
configuration().getCollectionMapping( Boy.class.getName() + '.' + "favoriteNumbers" )
.getCollectionTable().getName()
);
Session s = openSession();
@ -72,6 +103,7 @@ public class CollectionElementTest extends TestCase {
s.close();
}
@Test
public void testCompositeElement() throws Exception {
Session s = openSession();
s.getTransaction().begin();
@ -97,6 +129,7 @@ public class CollectionElementTest extends TestCase {
s.close();
}
@Test
public void testAttributedJoin() throws Exception {
Session s = openSession();
s.getTransaction().begin();
@ -124,13 +157,13 @@ public class CollectionElementTest extends TestCase {
s.delete( s.get( Country.class, country.getId() ) );
tx.commit();
s.close();
}
@Test
public void testLazyCollectionofElements() throws Exception {
assertEquals(
"BoyFavoriteNumbers",
getCfg().getCollectionMapping( Boy.class.getName() + '.' + "favoriteNumbers" )
configuration().getCollectionMapping( Boy.class.getName() + '.' + "favoriteNumbers" )
.getCollectionTable().getName()
);
Session s = openSession();
@ -170,6 +203,7 @@ public class CollectionElementTest extends TestCase {
s.close();
}
@Test
public void testFetchEagerAndFilter() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -199,6 +233,7 @@ public class CollectionElementTest extends TestCase {
s.close();
}
@Test
public void testMapKeyType() throws Exception {
Matrix m = new Matrix();
m.getMvalues().put( 1, 1.1f );
@ -208,11 +243,12 @@ public class CollectionElementTest extends TestCase {
s.flush();
s.clear();
m = (Matrix) s.get( Matrix.class, m.getId() );
assertEquals( 1.1f, m.getMvalues().get( 1 ) );
assertEquals( 1.1f, m.getMvalues().get( 1 ), 0.01f );
tx.rollback();
s.close();
}
@Test
public void testDefaultValueColumnForBasic() throws Exception {
isDefaultValueCollectionColumnPresent( Boy.class.getName(), "hatedNames" );
isDefaultValueCollectionColumnPresent( Boy.class.getName(), "preferredNames" );
@ -220,6 +256,7 @@ public class CollectionElementTest extends TestCase {
isDefaultValueCollectionColumnPresent( Boy.class.getName(), "scorePerPreferredName");
}
@Test
public void testDefaultFKNameForElementCollection() throws Exception {
isCollectionColumnPresent( Boy.class.getName(), "hatedNames", "Boy_id" );
}
@ -233,7 +270,7 @@ public class CollectionElementTest extends TestCase {
}
private void isCollectionColumnPresent(String collectionOwner, String propertyName, String columnName) {
final Collection collection = getCfg().getCollectionMapping( collectionOwner + "." + propertyName );
final Collection collection = configuration().getCollectionMapping( collectionOwner + "." + propertyName );
final Iterator columnIterator = collection.getCollectionTable().getColumnIterator();
boolean hasDefault = false;
while ( columnIterator.hasNext() ) {
@ -243,6 +280,7 @@ public class CollectionElementTest extends TestCase {
assertTrue( "Could not find " + columnName, hasDefault );
}
@Override
protected Class[] getAnnotatedClasses() {
return new Class[] {
Boy.class,

View File

@ -1,17 +1,41 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.collectionelement;
import java.util.HashSet;
import java.util.Iterator;
import junit.framework.Assert;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.test.annotations.TestCase;
public class OrderByTest extends TestCase {
import org.junit.Test;
import junit.framework.Assert;
/**
* Test @OrderBy on the Widgets.name field.
*
*/
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
public class OrderByTest extends BaseCoreFunctionalTestCase {
@Test
public void testOrderByName() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -50,6 +74,7 @@ public class OrderByTest extends TestCase {
s.close();
}
@Test
public void testOrderByWithDottedNotation() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -101,6 +126,7 @@ public class OrderByTest extends TestCase {
}
@Override
protected Class[] getAnnotatedClasses() {
return new Class[] {
Products.class,

View File

@ -1,24 +1,47 @@
//$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.collectionelement.deepcollectionelements;
import org.hibernate.test.annotations.TestCase;
import org.hibernate.cfg.Configuration;
import org.junit.Test;
import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.ServiceRegistryBuilder;
import org.hibernate.testing.junit4.BaseUnitTestCase;
/**
* @author Emmanuel Bernard
*/
//TEST not used: wait for ANN-591 and HHH-3157
public class DeepCollectionElementTest extends TestCase {
@FailureExpected( jiraKey = "HHH-3157" )
public class DeepCollectionElementTest extends BaseUnitTestCase {
@Test
public void testInitialization() throws Exception {
//test only the SF creation
}
protected Class[] getAnnotatedClasses() {
return new Class[] {
//A.class,
//B.class,
//C.class
};
Configuration configuration = new Configuration();
configuration.addAnnotatedClass( A.class );
configuration.addAnnotatedClass( B.class );
configuration.addAnnotatedClass( C.class );
configuration.buildSessionFactory( ServiceRegistryBuilder.buildServiceRegistry( configuration.getProperties() ) );
}
}

View File

@ -1,13 +1,41 @@
//$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.collectionelement.indexedCollection;
import org.hibernate.Session;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
/**
* @author Emmanuel Bernard
*/
public class IndexedCollectionOfElementsTest extends TestCase {
public class IndexedCollectionOfElementsTest extends BaseCoreFunctionalTestCase {
@Test
public void testIndexedCollectionOfElements() throws Exception {
Sale sale = new Sale();
Contact contact = new Contact();
@ -23,6 +51,7 @@ public class IndexedCollectionOfElementsTest extends TestCase {
s.close();
}
@Override
protected Class[] getAnnotatedClasses() {
return new Class[] {
Sale.class

View File

@ -22,26 +22,33 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.dataTypes;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;
import org.hibernate.Session;
import org.hibernate.jdbc.Work;
import org.hibernate.test.annotations.TestCase;
import org.hibernate.type.descriptor.JdbcTypeNameMapper;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
* TODO : javadoc
*
* @author Steve Ebersole
*/
public class BasicOperationsTest extends TestCase {
public class BasicOperationsTest extends BaseCoreFunctionalTestCase {
@Override
protected Class<?>[] getAnnotatedClasses() {
return new Class[] { SomeEntity.class, SomeOtherEntity.class };
}
@Test
public void testCreateAndDelete() {
Date now = new Date();
@ -85,22 +92,4 @@ public class BasicOperationsTest extends TestCase {
s.getTransaction().commit();
s.close();
}
private Byte[] generateByteArray() {
final byte[] bytes = "I'll be back".getBytes();
final Byte[] wrappedBytes = new Byte[ bytes.length ];
for ( int i = 0, max = bytes.length; i < max; i++ ) {
wrappedBytes[i] = Byte.valueOf( bytes[i] );
}
return wrappedBytes;
}
private Character[] generateCharacterArray() {
final char[] chars = "I'll be back".toCharArray();
final Character[] wrappedChars = new Character[ chars.length ];
for ( int i = 0, max = chars.length; i < max; i++ ) {
wrappedChars[i] = Character.valueOf( chars[i] );
}
return wrappedChars;
}
}

View File

@ -1,69 +1,75 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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
*/
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.derivedidentities.bidirectional;
import org.hibernate.Session;
import org.hibernate.test.annotations.TestCase;
public class CompositeDerivedIdentityTest extends TestCase
{
@Override
protected Class<?>[] getAnnotatedClasses() {
return new Class<?>[] {
Product.class,
OrderLine.class,
Order.class
};
}
public void testCreateProject() {
Product product = new Product();
product.setName("Product 1");
Session session = openSession();
session.beginTransaction();
session.save(product);
session.getTransaction().commit();
session.close();
Order order = new Order();
order.setName("Order 1");
order.addLineItem(product, 2);
session = openSession();
session.beginTransaction();
session.save(order);
session.getTransaction().commit();
session.close();
Long orderId = order.getId();
session = openSession();
session.beginTransaction();
order = (Order) session.get(Order.class, orderId);
assertEquals(1, order.getLineItems().size());
session.delete( order );
session.getTransaction().commit();
session.close();
}
}
import org.hibernate.Session;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
public class CompositeDerivedIdentityTest extends BaseCoreFunctionalTestCase {
@Override
protected Class<?>[] getAnnotatedClasses() {
return new Class<?>[] {
Product.class,
OrderLine.class,
Order.class
};
}
@Test
public void testCreateProject() {
Product product = new Product();
product.setName("Product 1");
Session session = openSession();
session.beginTransaction();
session.save(product);
session.getTransaction().commit();
session.close();
Order order = new Order();
order.setName("Order 1");
order.addLineItem(product, 2);
session = openSession();
session.beginTransaction();
session.save(order);
session.getTransaction().commit();
session.close();
Long orderId = order.getId();
session = openSession();
session.beginTransaction();
order = (Order) session.get(Order.class, orderId);
assertEquals(1, order.getLineItems().size());
session.delete( order );
session.getTransaction().commit();
session.close();
}
}

View File

@ -22,18 +22,25 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.derivedidentities.bidirectional;
import org.hibernate.Session;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.test.util.SchemaUtil;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
* @author Hardy Ferentschik
*/
public class DerivedIdentityWithBidirectionalAssociationTest extends TestCase {
public class DerivedIdentityWithBidirectionalAssociationTest extends BaseCoreFunctionalTestCase {
@Test
public void testBidirectionalAssociation() throws Exception {
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "emp_empId", getCfg() ) );
assertTrue( !SchemaUtil.isColumnPresent( "Dependent", "empPK", getCfg() ) );
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "emp_empId", configuration() ) );
assertTrue( !SchemaUtil.isColumnPresent( "Dependent", "empPK", configuration() ) );
Employee e = new Employee();
e.empId = 1;
e.empName = "Emmanuel";

View File

@ -22,12 +22,19 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.derivedidentities.bidirectional;
import org.hibernate.Session;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
public class OneToOneWithDerivedIdentityTest extends TestCase {
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
public class OneToOneWithDerivedIdentityTest extends BaseCoreFunctionalTestCase {
@Test
@FailureExpected(jiraKey = "HHH-5695")
public void testInsertFooAndBarWithDerivedId() {
Session s = openSession();

View File

@ -1,18 +1,50 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.derivedidentities.e1.a;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.test.util.SchemaUtil;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* @author Emmanuel Bernard
*/
public class DerivedIdentitySimpleParentIdClassDepTest extends TestCase {
public class DerivedIdentitySimpleParentIdClassDepTest extends BaseCoreFunctionalTestCase {
@Test
public void testManyToOne() throws Exception {
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "emp_empId", getCfg() ) );
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "emp", getCfg() ) );
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "emp_empId", configuration() ) );
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "emp", configuration() ) );
Session s = openSession();
s.getTransaction().begin();
@ -36,6 +68,7 @@ public class DerivedIdentitySimpleParentIdClassDepTest extends TestCase {
s.close();
}
@Test
public void testQueryNewEntityInPC() throws Exception {
Session s = openSession();
s.getTransaction().begin();

View File

@ -1,17 +1,46 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.derivedidentities.e1.b;
import org.hibernate.Session;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.test.util.SchemaUtil;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
* @author Emmanuel Bernard
*/
public class
DerivedIdentitySimpleParentEmbeddedIdDepTest extends TestCase {
public class DerivedIdentitySimpleParentEmbeddedIdDepTest extends BaseCoreFunctionalTestCase {
@Test
public void testManyToOne() throws Exception {
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "emp_empId", getCfg() ) );
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "empPK", getCfg() ) );
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "emp_empId", configuration() ) );
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "empPK", configuration() ) );
Employee e = new Employee();
e.empId = 1;
e.empName = "Emmanuel";
@ -32,9 +61,10 @@ public class
s.close();
}
@Test
public void testOneToOne() throws Exception {
assertTrue( SchemaUtil.isColumnPresent( "ExclusiveDependent", "FK", getCfg() ) );
assertTrue( ! SchemaUtil.isColumnPresent( "ExclusiveDependent", "empPK", getCfg() ) );
assertTrue( SchemaUtil.isColumnPresent( "ExclusiveDependent", "FK", configuration() ) );
assertTrue( ! SchemaUtil.isColumnPresent( "ExclusiveDependent", "empPK", configuration() ) );
Employee e = new Employee();
e.empId = 1;
e.empName = "Emmanuel";

View File

@ -22,26 +22,31 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.derivedidentities.e1.b.specjmapid;
import java.math.BigDecimal;
import java.util.List;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
/**
* A test.
*
* @author <a href="mailto:stale.pedersen@jboss.org">Stale W. Pedersen</a>
*/
public class IdMapManyToOneSpecjTest extends TestCase {
public class IdMapManyToOneSpecjTest extends BaseCoreFunctionalTestCase {
public IdMapManyToOneSpecjTest() {
System.setProperty( "hibernate.enable_specj_proprietary_syntax", "true" );
}
@Test
public void testComplexIdClass() {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -130,6 +135,7 @@ public class IdMapManyToOneSpecjTest extends TestCase {
s.close();
}
@Override
protected Class[] getAnnotatedClasses() {
return new Class[] {
Customer.class,

View File

@ -22,19 +22,27 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.derivedidentities.e1.b2;
import java.math.BigDecimal;
import java.util.List;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
* A test.
*
* @author <a href="mailto:stale.pedersen@jboss.org">Stale W. Pedersen</a>
*/
public class IdClassGeneratedValueManyToOneTest extends TestCase {
public class IdClassGeneratedValueManyToOneTest extends BaseCoreFunctionalTestCase {
@Test
public void testComplexIdClass() {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -80,46 +88,8 @@ public class IdClassGeneratedValueManyToOneTest extends TestCase {
assertTrue( true );
}
/*
public void testCustomer()
{
Session s = openSession();
Transaction tx = s.beginTransaction();
for(int i=0; i < 2; i++)
{
Customer c1 = new Customer(
"foo"+i, "bar"+i, "contact"+i, "100", new BigDecimal( 1000+i ), new BigDecimal( 1000+i ), new BigDecimal( 1000+i )
);
s.persist( c1 );
s.flush();
s.clear();
Item boat = new Item();
boat.setId( Integer.toString(i) );
boat.setName( "cruiser" );
boat.setPrice( new BigDecimal( 500 ) );
boat.setDescription( "a boat" );
boat.setCategory( 42 );
s.persist( boat );
s.flush();
s.clear();
c1.addInventory( boat, 10, new BigDecimal( 5000 ) );
s.merge( c1 );
s.flush();
s.clear();
}
tx.rollback();
s.close();
assertTrue( true );
}*/
@Override
protected Class[] getAnnotatedClasses() {
return new Class[] {
Customer.class,

View File

@ -1,16 +1,46 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.derivedidentities.e1.c;
import org.hibernate.Session;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.test.util.SchemaUtil;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
* @author Emmanuel Bernard
*/
public class DerivedIdentitySimpleParentEmbeddedDepTest extends TestCase {
public class DerivedIdentitySimpleParentEmbeddedDepTest extends BaseCoreFunctionalTestCase {
@Test
public void testManyToOne() throws Exception {
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "emp_empId", getCfg() ) );
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "empPK", getCfg() ) );
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "emp_empId", configuration() ) );
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "empPK", configuration() ) );
Employee e = new Employee();
e.empId = 1;
e.empName = "Emmanuel";

View File

@ -1,19 +1,27 @@
package org.hibernate.test.annotations.derivedidentities.e2.a;
import org.hibernate.Session;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.test.util.SchemaUtil;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
/**
* @author Emmanuel Bernard
*/
public class DerivedIdentityIdClassParentIdClassDepTest extends TestCase {
public class DerivedIdentityIdClassParentIdClassDepTest extends BaseCoreFunctionalTestCase {
@Test
public void testManytoOne() {
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "FK1", getCfg() ) );
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "FK2", getCfg() ) );
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "name", getCfg() ) );
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "firstName", getCfg() ) );
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "lastName", getCfg() ) );
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "FK1", configuration() ) );
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "FK2", configuration() ) );
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "name", configuration() ) );
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "firstName", configuration() ) );
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "lastName", configuration() ) );
Employee e = new Employee();
e.firstName = "Emmanuel";
e.lastName = "Bernard";

View File

@ -1,19 +1,27 @@
package org.hibernate.test.annotations.derivedidentities.e2.b;
import org.hibernate.Session;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.test.util.SchemaUtil;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
/**
* @author Emmanuel Bernard
*/
public class DerivedIdentityIdClassParentEmbeddedIdDepTest extends TestCase {
public class DerivedIdentityIdClassParentEmbeddedIdDepTest extends BaseCoreFunctionalTestCase {
@Test
public void testManyToOne() throws Exception {
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "emp_firstName", getCfg() ) );
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "emp_lastName", getCfg() ) );
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "name", getCfg() ) );
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "firstName", getCfg() ) );
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "lastName", getCfg() ) );
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "emp_firstName", configuration() ) );
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "emp_lastName", configuration() ) );
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "name", configuration() ) );
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "firstName", configuration() ) );
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "lastName", configuration() ) );
Employee e = new Employee();
e.firstName = "Emmanuel";
e.lastName = "Bernard";
@ -34,7 +42,6 @@ public class DerivedIdentityIdClassParentEmbeddedIdDepTest extends TestCase {
s.close();
}
@Override
protected Class<?>[] getAnnotatedClasses() {
return new Class<?>[] {

View File

@ -1,18 +1,50 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.derivedidentities.e3.a;
import org.hibernate.Session;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.test.util.SchemaUtil;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
/**
* @author Emmanuel Bernard
*/
public class DerivedIdentityEmbeddedIdParentIdClassTest extends TestCase {
public class DerivedIdentityEmbeddedIdParentIdClassTest extends BaseCoreFunctionalTestCase {
@Test
public void testManyToOne() throws Exception {
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "FK1", getCfg() ) );
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "FK2", getCfg() ) );
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "dep_name", getCfg() ) );
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "firstName", getCfg() ) );
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "lastName", getCfg() ) );
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "FK1", configuration() ) );
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "FK2", configuration() ) );
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "dep_name", configuration() ) );
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "firstName", configuration() ) );
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "lastName", configuration() ) );
Employee e = new Employee();
e.empId = new EmployeeId();
e.empId.firstName = "Emmanuel";

View File

@ -1,18 +1,50 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.derivedidentities.e3.b;
import org.hibernate.Session;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.test.util.SchemaUtil;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
/**
* @author Emmanuel Bernard
*/
public class DerivedIdentityEmbeddedIdParentEmbeddedIdDepTest extends TestCase {
public class DerivedIdentityEmbeddedIdParentEmbeddedIdDepTest extends BaseCoreFunctionalTestCase {
@Test
public void testManyToOne() throws Exception {
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "FK1", getCfg() ) );
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "FK2", getCfg() ) );
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "dep_name", getCfg() ) );
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "firstName", getCfg() ) );
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "lastName", getCfg() ) );
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "FK1", configuration() ) );
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "FK2", configuration() ) );
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "dep_name", configuration() ) );
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "firstName", configuration() ) );
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "lastName", configuration() ) );
Employee e = new Employee();
e.empId = new EmployeeId();
e.empId.firstName = "Emmanuel";
@ -34,12 +66,8 @@ public class DerivedIdentityEmbeddedIdParentEmbeddedIdDepTest extends TestCase {
s.close();
}
@Override
protected Class<?>[] getAnnotatedClasses() {
return new Class<?>[] {
Dependent.class,
Employee.class
};
return new Class<?>[] { Dependent.class, Employee.class };
}
}

View File

@ -1,17 +1,49 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.derivedidentities.e4.a;
import java.util.Date;
import org.hibernate.Session;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.test.util.SchemaUtil;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
/**
* @author Emmanuel Bernard
*/
public class DerivedIdentitySimpleParentSimpleDepTest extends TestCase {
public class DerivedIdentitySimpleParentSimpleDepTest extends BaseCoreFunctionalTestCase {
@Test
public void testOneToOneExplicitJoinColumn() throws Exception {
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK", getCfg() ) );
assertTrue( ! SchemaUtil.isColumnPresent( "MedicalHistory", "id", getCfg() ) );
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK", configuration() ) );
assertTrue( ! SchemaUtil.isColumnPresent( "MedicalHistory", "id", configuration() ) );
Session s = openSession();
s.getTransaction().begin();
@ -35,13 +67,15 @@ public class DerivedIdentitySimpleParentSimpleDepTest extends TestCase {
medicalHistory = (MedicalHistory) s.get( MedicalHistory.class, "aaa" );
assertNotNull( medicalHistory.lastupdate );
s.delete( medicalHistory );
s.delete( medicalHistory.patient );
s.getTransaction().commit();
s.close();
}
@Test
public void testManyToOneExplicitJoinColumn() throws Exception {
assertTrue( SchemaUtil.isColumnPresent( "FinancialHistory", "patient_ssn", getCfg() ) );
assertTrue( ! SchemaUtil.isColumnPresent( "FinancialHistory", "id", getCfg() ) );
assertTrue( SchemaUtil.isColumnPresent( "FinancialHistory", "patient_ssn", configuration() ) );
assertTrue( ! SchemaUtil.isColumnPresent( "FinancialHistory", "id", configuration() ) );
Session s = openSession();
s.getTransaction().begin();
@ -65,10 +99,12 @@ public class DerivedIdentitySimpleParentSimpleDepTest extends TestCase {
financialHistory = (FinancialHistory) s.get( FinancialHistory.class, "aaa" );
assertNotNull( financialHistory.lastUpdate );
s.delete( financialHistory );
s.delete( financialHistory.patient );
s.getTransaction().commit();
s.close();
}
@Test
public void testSimplePkValueLoading() {
Session s = openSession();
s.getTransaction().begin();
@ -84,6 +120,7 @@ public class DerivedIdentitySimpleParentSimpleDepTest extends TestCase {
FinancialHistory history = (FinancialHistory) s.get( FinancialHistory.class, "aaa" );
assertNotNull( history );
s.delete( history );
s.delete( history.patient );
s.getTransaction().commit();
s.close();
}

View File

@ -1,17 +1,50 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.derivedidentities.e4.b;
import java.util.Date;
import org.hibernate.Session;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.test.util.SchemaUtil;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
/**
* @author Emmanuel Bernard
*/
public class DerivedIdentitySimpleParentSimpleDepMapsIdTest extends TestCase {
public class DerivedIdentitySimpleParentSimpleDepMapsIdTest extends BaseCoreFunctionalTestCase {
@Test
public void testOneToOneExplicitJoinColumn() throws Exception {
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK", getCfg() ) );
assertTrue( ! SchemaUtil.isColumnPresent( "MedicalHistory", "id", getCfg() ) );
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK", configuration() ) );
assertTrue( ! SchemaUtil.isColumnPresent( "MedicalHistory", "id", configuration() ) );
Person e = new Person();
e.ssn = "aaa";
Session s = openSession( );
@ -34,9 +67,10 @@ public class DerivedIdentitySimpleParentSimpleDepMapsIdTest extends TestCase {
s.close();
}
@Test
public void testManyToOneExplicitJoinColumn() throws Exception {
assertTrue( SchemaUtil.isColumnPresent( "FinancialHistory", "FK", getCfg() ) );
assertTrue( ! SchemaUtil.isColumnPresent( "FinancialHistory", "id", getCfg() ) );
assertTrue( SchemaUtil.isColumnPresent( "FinancialHistory", "FK", configuration() ) );
assertTrue( ! SchemaUtil.isColumnPresent( "FinancialHistory", "id", configuration() ) );
Person e = new Person();
e.ssn = "aaa";
Session s = openSession( );
@ -59,6 +93,7 @@ public class DerivedIdentitySimpleParentSimpleDepMapsIdTest extends TestCase {
s.close();
}
@Test
public void testExplicitlyAssignedDependentIdAttributeValue() {
// even though the id is by definition generated (using the "foreign" strategy), JPA
// still does allow manually setting the generated id attribute value which providers

View File

@ -1,19 +1,50 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.derivedidentities.e5.a;
import org.hibernate.Session;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.test.util.SchemaUtil;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
* @author Emmanuel Bernard
*/
public class DerivedIdentityIdClassParentSameIdTypeIdClassDepTest extends TestCase {
public class DerivedIdentityIdClassParentSameIdTypeIdClassDepTest extends BaseCoreFunctionalTestCase {
private static final String FIRST_NAME = "Emmanuel";
private static final String LAST_NAME = "Bernard";
@Test
public void testOneToOneExplicitJoinColumn() throws Exception {
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK1", getCfg() ) );
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK2", getCfg() ) );
assertTrue( ! SchemaUtil.isColumnPresent( "MedicalHistory", "firstname", getCfg() ) );
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK1", configuration() ) );
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK2", configuration() ) );
assertTrue( ! SchemaUtil.isColumnPresent( "MedicalHistory", "firstname", configuration() ) );
Session s = openSession();
s.getTransaction().begin();
@ -39,10 +70,11 @@ public class DerivedIdentityIdClassParentSameIdTypeIdClassDepTest extends TestCa
s.close();
}
@Test
public void testTckLikeBehavior() throws Exception {
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK1", getCfg() ) );
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK2", getCfg() ) );
assertTrue( ! SchemaUtil.isColumnPresent( "MedicalHistory", "firstname", getCfg() ) );
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK1", configuration() ) );
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK2", configuration() ) );
assertTrue( ! SchemaUtil.isColumnPresent( "MedicalHistory", "firstname", configuration() ) );
Session s = openSession();
s.getTransaction().begin();

View File

@ -1,17 +1,47 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.derivedidentities.e5.b;
import org.hibernate.Session;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.test.util.SchemaUtil;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
* @author Emmanuel Bernard
*/
public class DerivedIdentityIdClassParentSameIdTypeEmbeddedIdDepTest extends TestCase {
public class DerivedIdentityIdClassParentSameIdTypeEmbeddedIdDepTest extends BaseCoreFunctionalTestCase {
@Test
public void testOneToOneExplicitJoinColumn() throws Exception {
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK1", getCfg() ) );
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK2", getCfg() ) );
assertTrue( ! SchemaUtil.isColumnPresent( "MedicalHistory", "firstname", getCfg() ) );
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK1", configuration() ) );
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK2", configuration() ) );
assertTrue( ! SchemaUtil.isColumnPresent( "MedicalHistory", "firstname", configuration() ) );
Person e = new Person();
e.firstName = "Emmanuel";
e.lastName = "Bernard";

View File

@ -1,15 +1,45 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.derivedidentities.e5.c;
import org.hibernate.Session;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.test.util.SchemaUtil;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
* @author Emmanuel Bernard
*/
public class ForeignGeneratorViaMapsIdTest extends TestCase {
public class ForeignGeneratorViaMapsIdTest extends BaseCoreFunctionalTestCase {
@Test
public void testForeignGenerator() throws Exception {
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "patient_id", getCfg() ) );
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "patient_id", configuration() ) );
Person e = new Person();
Session s = openSession( );
s.getTransaction().begin();

View File

@ -1,17 +1,47 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.derivedidentities.e6.a;
import org.hibernate.Session;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.test.util.SchemaUtil;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
* @author Emmanuel Bernard
*/
public class DerivedIdentityEmbeddedIdParentSameIdTypeIdClassDepTest extends TestCase {
public class DerivedIdentityEmbeddedIdParentSameIdTypeIdClassDepTest extends BaseCoreFunctionalTestCase {
@Test
public void testOneToOneExplicitJoinColumn() throws Exception {
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK1", getCfg() ) );
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK2", getCfg() ) );
assertTrue( ! SchemaUtil.isColumnPresent( "MedicalHistory", "firstname", getCfg() ) );
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK1", configuration() ) );
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK2", configuration() ) );
assertTrue( ! SchemaUtil.isColumnPresent( "MedicalHistory", "firstname", configuration() ) );
Person e = new Person();
e.id = new PersonId();
e.id.firstName = "Emmanuel";

View File

@ -1,17 +1,47 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.derivedidentities.e6.b;
import org.hibernate.Session;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.test.util.SchemaUtil;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
* @author Emmanuel Bernard
*/
public class DerivedIdentityEmbeddedIdParentSameIdTypeEmbeddedIdDepTest extends TestCase {
public class DerivedIdentityEmbeddedIdParentSameIdTypeEmbeddedIdDepTest extends BaseCoreFunctionalTestCase {
@Test
public void testOneToOneExplicitJoinColumn() throws Exception {
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK1", getCfg() ) );
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK2", getCfg() ) );
assertTrue( ! SchemaUtil.isColumnPresent( "MedicalHistory", "firstname", getCfg() ) );
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK1", configuration() ) );
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK2", configuration() ) );
assertTrue( ! SchemaUtil.isColumnPresent( "MedicalHistory", "firstname", configuration() ) );
Person e = new Person();
e.id = new PersonId();
e.id.firstName = "Emmanuel";

View File

@ -1,23 +1,54 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.embedded;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.test.annotations.embedded.FloatLeg.RateIndex;
import org.hibernate.test.annotations.embedded.Leg.Frequency;
import org.hibernate.test.util.SchemaUtil;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
/**
* @author Emmanuel Bernard
*/
public class EmbeddedTest extends TestCase {
public class EmbeddedTest extends BaseCoreFunctionalTestCase {
@Test
public void testSimple() throws Exception {
Session s;
Transaction tx;
@ -56,6 +87,7 @@ public class EmbeddedTest extends TestCase {
s.close();
}
@Test
public void testCompositeId() throws Exception {
Session s;
Transaction tx;
@ -82,6 +114,7 @@ public class EmbeddedTest extends TestCase {
s.close();
}
@Test
public void testManyToOneInsideComponent() throws Exception {
Session s;
Transaction tx;
@ -120,6 +153,7 @@ public class EmbeddedTest extends TestCase {
s.close();
}
@Test
public void testEmbeddedSuperclass() {
Session s;
Transaction tx;
@ -156,6 +190,7 @@ public class EmbeddedTest extends TestCase {
s.close();
}
@Test
public void testDottedProperty() {
Session s;
Transaction tx;
@ -231,21 +266,22 @@ public class EmbeddedTest extends TestCase {
assertEquals( Frequency.MONTHLY, deal.getSwap().getFloatLeg().getPaymentFrequency() );
assertEquals( Frequency.MONTHLY, deal.getLongSwap().getFixedLeg().getPaymentFrequency() );
assertEquals( Frequency.MONTHLY, deal.getLongSwap().getFloatLeg().getPaymentFrequency() );
assertEquals( 5.6, deal.getShortSwap().getFixedLeg().getRate() );
assertEquals( 7.6, deal.getSwap().getFixedLeg().getRate() );
assertEquals( 7.6, deal.getLongSwap().getFixedLeg().getRate() );
assertEquals( 5.6, deal.getShortSwap().getFixedLeg().getRate(), 0.01 );
assertEquals( 7.6, deal.getSwap().getFixedLeg().getRate(), 0.01 );
assertEquals( 7.6, deal.getLongSwap().getFixedLeg().getRate(), 0.01 );
assertEquals( RateIndex.LIBOR, deal.getShortSwap().getFloatLeg().getRateIndex() );
assertEquals( RateIndex.TIBOR, deal.getSwap().getFloatLeg().getRateIndex() );
assertEquals( RateIndex.TIBOR, deal.getLongSwap().getFloatLeg().getRateIndex() );
assertEquals( 1.1, deal.getShortSwap().getFloatLeg().getRateSpread() );
assertEquals( 0.8, deal.getSwap().getFloatLeg().getRateSpread() );
assertEquals( 0.8, deal.getLongSwap().getFloatLeg().getRateSpread() );
assertEquals( 1.1, deal.getShortSwap().getFloatLeg().getRateSpread(), 0.01 );
assertEquals( 0.8, deal.getSwap().getFloatLeg().getRateSpread(), 0.01 );
assertEquals( 0.8, deal.getLongSwap().getFloatLeg().getRateSpread(), 0.01 );
s.delete( deal );
tx.commit();
s.close();
}
public void testEmbeddedInSecdondaryTable() throws Exception {
@Test
public void testEmbeddedInSecondaryTable() throws Exception {
Session s;
s = openSession();
s.getTransaction().begin();
@ -270,6 +306,7 @@ public class EmbeddedTest extends TestCase {
s.close();
}
@Test
public void testParent() throws Exception {
Session s;
s = openSession();
@ -295,6 +332,7 @@ public class EmbeddedTest extends TestCase {
s.close();
}
@Test
public void testEmbeddedAndMultipleManyToOne() throws Exception {
Session s;
s = openSession();
@ -332,6 +370,7 @@ public class EmbeddedTest extends TestCase {
s.close();
}
@Test
public void testEmbeddedAndOneToMany() throws Exception {
Session s;
s = openSession();
@ -366,11 +405,12 @@ public class EmbeddedTest extends TestCase {
s.close();
}
@Test
public void testDefaultCollectionTable() throws Exception {
//are the tables correct?
assertTrue( SchemaUtil.isTablePresent("WealthyPerson_vacationHomes", getCfg() ) );
assertTrue( SchemaUtil.isTablePresent("PersonEmbed_legacyVacationHomes", getCfg() ) );
assertTrue( SchemaUtil.isTablePresent("WelPers_VacHomes", getCfg() ) );
assertTrue( SchemaUtil.isTablePresent("WealthyPerson_vacationHomes", configuration() ) );
assertTrue( SchemaUtil.isTablePresent("PersonEmbed_legacyVacationHomes", configuration() ) );
assertTrue( SchemaUtil.isTablePresent("WelPers_VacHomes", configuration() ) );
//just to make sure, use the mapping
Session s;
@ -416,6 +456,7 @@ public class EmbeddedTest extends TestCase {
}
// make sure we support collection of embeddable objects inside embeddable objects
@Test
public void testEmbeddableInsideEmbeddable() throws Exception {
Session s;
Transaction tx;
@ -477,10 +518,7 @@ public class EmbeddedTest extends TestCase {
s.close();
}
public EmbeddedTest(String x) {
super( x );
}
@Override
protected Class[] getAnnotatedClasses() {
return new Class[]{
Person.class,

View File

@ -22,21 +22,27 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.embedded.many2one;
import java.util.List;
import org.hibernate.Session;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
/**
* TODO : javadoc
*
* @author Steve Ebersole
*/
public class EmbeddableWithMany2OneTest extends TestCase {
public class EmbeddableWithMany2OneTest extends BaseCoreFunctionalTestCase {
@Override
protected Class<?>[] getAnnotatedClasses() {
return new Class[] { Person.class, Country.class };
}
@Test
public void testJoinAcrossEmbedded() {
Session session = openSession();
session.beginTransaction();
@ -48,6 +54,7 @@ public class EmbeddableWithMany2OneTest extends TestCase {
session.close();
}
@Test
public void testBasicOps() {
Session session = openSession();
session.beginTransaction();

View File

@ -22,21 +22,29 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.embedded.one2many;
import java.util.List;
import org.hibernate.Session;
import org.junit.Test;
import org.hibernate.testing.FailureExpected;
import org.hibernate.test.annotations.TestCase;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
/**
* @author Steve Ebersole
*/
public class EmbeddableWithOne2ManyTest extends TestCase {
public class EmbeddableWithOne2ManyTest extends BaseCoreFunctionalTestCase {
@Override
protected Class<?>[] getAnnotatedClasses() {
// return new Class[] { Alias.class, Person.class };
return new Class[] { };
}
@Test
@FailureExpected( jiraKey = "HHH-4883")
public void testJoinAcrossEmbedded() {
// NOTE : this may or may not work now with HHH-4883 fixed,
@ -49,6 +57,7 @@ public class EmbeddableWithOne2ManyTest extends TestCase {
session.close();
}
@Test
@FailureExpected( jiraKey = "HHH-4599")
public void testBasicOps() {
Session session = openSession();

View File

@ -1,13 +1,40 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.engine.collection;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
/**
* @author Emmanuel Bernard
*/
public class UnidirCollectionWithMultipleOwnerTest extends TestCase {
public class UnidirCollectionWithMultipleOwnerTest extends BaseCoreFunctionalTestCase {
@Test
public void testUnidirCollectionWithMultipleOwner() throws Exception {
Session s = openSession();
Transaction tx;

View File

@ -1,4 +1,3 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
@ -23,30 +22,43 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.entity;
import java.math.BigDecimal;
import java.util.Currency;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import org.hibernate.AnnotationException;
import org.hibernate.Hibernate;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.test.annotations.TestCase;
import org.hibernate.cfg.Configuration;
import org.junit.Test;
import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.RequiresDialectFeature;
import org.hibernate.testing.ServiceRegistryBuilder;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
/**
* @author Emmanuel Bernard
*/
public class BasicHibernateAnnotationsTest extends TestCase {
public class BasicHibernateAnnotationsTest extends BaseCoreFunctionalTestCase {
@Test
@RequiresDialectFeature( DialectChecks.SupportsExpectedLobUsagePattern.class )
public void testEntity() throws Exception {
if( !getDialect().supportsExpectedLobUsagePattern() ){
return;
}
Forest forest = new Forest();
forest.setName( "Fontainebleau" );
Session s;
@ -82,10 +94,9 @@ public class BasicHibernateAnnotationsTest extends TestCase {
s.close();
}
@Test
@RequiresDialectFeature( DialectChecks.SupportsExpectedLobUsagePattern.class )
public void testVersioning() throws Exception {
if( !getDialect().supportsExpectedLobUsagePattern() ){
return;
}
Forest forest = new Forest();
forest.setName( "Fontainebleau" );
forest.setLength( 33 );
@ -126,13 +137,11 @@ public class BasicHibernateAnnotationsTest extends TestCase {
s.delete( s.get( Forest.class, forest.getId() ) );
tx.commit();
s.close();
}
@Test
@RequiresDialectFeature( DialectChecks.SupportsExpectedLobUsagePattern.class )
public void testPolymorphism() throws Exception {
if( !getDialect().supportsExpectedLobUsagePattern() ){
return;
}
Forest forest = new Forest();
forest.setName( "Fontainebleau" );
forest.setLength( 33 );
@ -154,10 +163,9 @@ public class BasicHibernateAnnotationsTest extends TestCase {
s.close();
}
@Test
@RequiresDialectFeature( DialectChecks.SupportsExpectedLobUsagePattern.class )
public void testType() throws Exception {
if( !getDialect().supportsExpectedLobUsagePattern() ){
return;
}
Forest f = new Forest();
f.setName( "Broceliande" );
String description = "C'est une enorme foret enchantee ou vivais Merlin et toute la clique";
@ -188,8 +196,8 @@ public class BasicHibernateAnnotationsTest extends TestCase {
* component 'LastName'. This is to verify that processing the
* typedef defined in the component TWICE does not create any
* issues.
*
*/
@Test
public void testImportTypeDefinitions() throws Exception {
LastName lastName = new LastName();
lastName.setName("reddy");
@ -227,6 +235,7 @@ public class BasicHibernateAnnotationsTest extends TestCase {
s.close();
}
@Test
public void testNonLazy() throws Exception {
Session s;
Transaction tx;
@ -250,6 +259,7 @@ public class BasicHibernateAnnotationsTest extends TestCase {
s.close();
}
@Test
public void testCache() throws Exception {
Session s;
Transaction tx;
@ -260,25 +270,25 @@ public class BasicHibernateAnnotationsTest extends TestCase {
s.persist( zc );
tx.commit();
s.close();
getSessions().getStatistics().clear();
getSessions().getStatistics().setStatisticsEnabled( true );
getSessions().evict( ZipCode.class );
sessionFactory().getStatistics().clear();
sessionFactory().getStatistics().setStatisticsEnabled( true );
sessionFactory().evict( ZipCode.class );
s = openSession();
tx = s.beginTransaction();
s.get( ZipCode.class, zc.code );
assertEquals( 1, getSessions().getStatistics().getSecondLevelCachePutCount() );
assertEquals( 1, sessionFactory().getStatistics().getSecondLevelCachePutCount() );
tx.commit();
s.close();
s = openSession();
tx = s.beginTransaction();
s.get( ZipCode.class, zc.code );
assertEquals( 1, getSessions().getStatistics().getSecondLevelCacheHitCount() );
assertEquals( 1, sessionFactory().getStatistics().getSecondLevelCacheHitCount() );
tx.commit();
s.close();
}
@Test
public void testFilterOnCollection() {
Session s = openSession();
@ -311,6 +321,7 @@ public class BasicHibernateAnnotationsTest extends TestCase {
}
@Test
public void testCascadedDeleteOfChildEntitiesBug2() {
// Relationship is one SoccerTeam to many Players.
// Create a SoccerTeam (parent) and three Players (child).
@ -360,6 +371,7 @@ public class BasicHibernateAnnotationsTest extends TestCase {
s.close();
}
@Test
public void testCascadedDeleteOfChildOneToOne() {
// create two single player teams (for one versus one match of soccer)
// and associate teams with players via the special OneVOne methods.
@ -409,6 +421,7 @@ public class BasicHibernateAnnotationsTest extends TestCase {
s.close();
}
@Test
public void testFilter() throws Exception {
Session s;
Transaction tx;
@ -444,6 +457,7 @@ public class BasicHibernateAnnotationsTest extends TestCase {
* Tests the functionality of inheriting @Filter and @FilterDef annotations
* defined on a parent MappedSuperclass(s)
*/
@Test
public void testInheritFiltersFromMappedSuperclass() throws Exception {
Session s;
Transaction tx;
@ -487,10 +501,9 @@ public class BasicHibernateAnnotationsTest extends TestCase {
s.close();
}
@Test
@RequiresDialectFeature( DialectChecks.SupportsExpectedLobUsagePattern.class )
public void testParameterizedType() throws Exception {
if( !getDialect().supportsExpectedLobUsagePattern() ){
return;
}
Session s;
Transaction tx;
s = openSession();
@ -510,10 +523,9 @@ public class BasicHibernateAnnotationsTest extends TestCase {
s.close();
}
@Test
@RequiresDialectFeature( DialectChecks.SupportsExpectedLobUsagePattern.class )
public void testSerialized() throws Exception {
if( !getDialect().supportsExpectedLobUsagePattern() ){
return;
}
Forest forest = new Forest();
forest.setName( "Shire" );
Country country = new Country();
@ -557,6 +569,7 @@ public class BasicHibernateAnnotationsTest extends TestCase {
s.close();
}
@Test
public void testCompositeType() throws Exception {
Session s;
Transaction tx;
@ -583,6 +596,7 @@ public class BasicHibernateAnnotationsTest extends TestCase {
s.close();
}
@Test
public void testFormula() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -603,9 +617,8 @@ public class BasicHibernateAnnotationsTest extends TestCase {
s.close();
}
@Test
public void testTypeDefNameAndDefaultForTypeAttributes() {
ContactDetails contactDetails = new ContactDetails();
contactDetails.setLocalPhoneNumber(new PhoneNumber("999999"));
contactDetails.setOverseasPhoneNumber(
@ -630,12 +643,12 @@ public class BasicHibernateAnnotationsTest extends TestCase {
}
@Test
public void testTypeDefWithoutNameAndDefaultForTypeAttributes() {
try {
AnnotationConfiguration config = new AnnotationConfiguration();
Configuration config = new Configuration();
config.addAnnotatedClass(LocalContactDetails.class);
config.buildSessionFactory( getServiceRegistry() );
config.buildSessionFactory( ServiceRegistryBuilder.buildServiceRegistry( config.getProperties() ) );
fail("Did not throw expected exception");
}
catch( AnnotationException ex ) {
@ -643,7 +656,6 @@ public class BasicHibernateAnnotationsTest extends TestCase {
"Either name or defaultForType (or both) attribute should be set in TypeDef having typeClass org.hibernate.test.annotations.entity.PhoneNumberType",
ex.getMessage());
}
}
@ -657,6 +669,7 @@ public class BasicHibernateAnnotationsTest extends TestCase {
*
* @throws Exception
*/
@Test
public void testSetSimpleValueTypeNameInSecondPass() throws Exception {
Peugot derived = new Peugot();
derived.setName("sharath");
@ -678,12 +691,8 @@ public class BasicHibernateAnnotationsTest extends TestCase {
tx.commit();
s.close();
}
public BasicHibernateAnnotationsTest(String x) {
super( x );
}
@Override
protected Class<?>[] getAnnotatedClasses() {
return new Class[]{
Forest.class,
@ -705,6 +714,7 @@ public class BasicHibernateAnnotationsTest extends TestCase {
};
}
@Override
protected String[] getAnnotatedPackages() {
return new String[]{
"org.hibernate.test.annotations.entity"

View File

@ -1,13 +1,43 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.entity;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
/**
* @author Emmanuel Bernard
*/
public class Java5FeaturesTest extends TestCase {
public class Java5FeaturesTest extends BaseCoreFunctionalTestCase {
@Test
public void testInterface() throws Exception {
Session s;
Transaction tx;
@ -29,6 +59,7 @@ public class Java5FeaturesTest extends TestCase {
}
@Test
public void testEnums() throws Exception {
Session s;
Transaction tx;
@ -110,10 +141,7 @@ public class Java5FeaturesTest extends TestCase {
s.close();
}
public Java5FeaturesTest(String x) {
super( x );
}
@Override
protected Class[] getAnnotatedClasses() {
return new Class[]{
Race.class,

View File

@ -23,8 +23,9 @@
*/
package org.hibernate.test.annotations.entity;
import java.io.Serializable;
public class PhoneNumber {
public class PhoneNumber implements Serializable {
private String number;

View File

@ -1,17 +1,44 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.entity;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
/**
* @author Emmanuel Bernard
*/
public class PropertyDefaultMappingsTest extends TestCase {
public PropertyDefaultMappingsTest(String x) {
super( x );
}
public class PropertyDefaultMappingsTest extends BaseCoreFunctionalTestCase {
@Test
public void testSerializableObject() throws Exception {
Session s;
Transaction tx;
@ -36,6 +63,7 @@ public class PropertyDefaultMappingsTest extends TestCase {
s.close();
}
@Test
public void testTransientField() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -52,6 +80,7 @@ public class PropertyDefaultMappingsTest extends TestCase {
s.close();
}
@Override
protected Class[] getAnnotatedClasses() {
return new Class[]{
Address.class,

View File

@ -1,13 +1,44 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.entitynonentity;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
/**
* @author Emmanuel Bernard
*/
public class EntityNonEntityTest extends TestCase {
public class EntityNonEntityTest extends BaseCoreFunctionalTestCase {
@Test
public void testMix() throws Exception {
GSM gsm = new GSM();
gsm.brand = "Sony";
@ -32,6 +63,7 @@ public class EntityNonEntityTest extends TestCase {
s.close();
}
@Override
protected Class[] getAnnotatedClasses() {
return new Class[]{
Phone.class,

View File

@ -1,15 +1,47 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.fetch;
import java.util.Date;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
/**
* @author Emmanuel Bernard
*/
public class FetchingTest extends TestCase {
public class FetchingTest extends BaseCoreFunctionalTestCase {
@Test
public void testLazy() throws Exception {
Session s;
Transaction tx;
@ -30,6 +62,7 @@ public class FetchingTest extends TestCase {
s.close();
}
@Test
public void testExtraLazy() throws Exception {
Session s;
Transaction tx;
@ -54,6 +87,7 @@ public class FetchingTest extends TestCase {
s.close();
}
@Test
public void testHibernateFetchingLazy() throws Exception {
Session s;
Transaction tx;
@ -89,6 +123,7 @@ public class FetchingTest extends TestCase {
s.close();
}
@Test
public void testOneToManyFetchEager() throws Exception {
Branch b = new Branch();
Session s = openSession( );
@ -108,10 +143,7 @@ public class FetchingTest extends TestCase {
s.close();
}
public FetchingTest(String x) {
super( x );
}
@Override
protected Class[] getAnnotatedClasses() {
return new Class[]{
Person.class,

View File

@ -1,4 +1,3 @@
// $Id: FetchProfileTest.java 19528 2010-05-17 14:28:55Z epbernard $
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
@ -24,18 +23,25 @@
*
*/
package org.hibernate.test.annotations.fetchprofile;
import java.util.Date;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertTrue;
/**
* @author Emmanuel Bernard
* @author Hardy Ferentschik
*/
public class MoreFetchProfileTest extends TestCase {
public class MoreFetchProfileTest extends BaseCoreFunctionalTestCase {
@Test
public void testFetchWithTwoOverrides() throws Exception {
Session s = openSession();
s.enableFetchProfile( "customer-with-orders-and-country" );

View File

@ -1,66 +1,83 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.generics;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.test.annotations.TestCase;
public class EmbeddedGenericsTest extends TestCase {
Session session;
Classes.Edition<String> edition;
public void setUp() throws Exception {
super.setUp();
session = openSession();
session.getTransaction().begin();
edition = new Classes.Edition<String>();
edition.name = "Second";
}
public void testWorksWithGenericEmbedded() {
Classes.Book b = new Classes.Book();
b.edition = edition;
persist( b );
Classes.Book retrieved = (Classes.Book)find( Classes.Book.class, b.id );
assertEquals( "Second", retrieved.edition.name );
clean( Classes.Book.class, b.id );
session.close();
}
public void testWorksWithGenericCollectionOfElements() {
Classes.PopularBook b = new Classes.PopularBook();
b.editions.add( edition );
persist( b );
Classes.PopularBook retrieved = (Classes.PopularBook)find( Classes.PopularBook.class, b.id );
assertEquals( "Second", retrieved.editions.iterator().next().name );
clean( Classes.PopularBook.class, b.id );
session.close();
}
protected Class[] getAnnotatedClasses() {
return new Class[]{
Classes.Book.class,
Classes.PopularBook.class
};
}
private void persist(Object data) {
session.persist( data );
session.getTransaction().commit();
session.clear();
}
private Object find(Class clazz, Long id) {
return session.get( clazz, id );
}
private void clean(Class<?> clazz, Long id) {
Transaction tx = session.beginTransaction();
session.delete( find( clazz, id ) );
tx.commit();
}
}
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
public class EmbeddedGenericsTest extends BaseCoreFunctionalTestCase {
@Test
public void testWorksWithGenericEmbedded() {
Session session = openSession();
session.beginTransaction();
Classes.Edition<String> edition = new Classes.Edition<String>();
edition.name = "Second";
Classes.Book b = new Classes.Book();
b.edition = edition;
session.persist( b );
session.getTransaction().commit();
session.close();
session = openSession();
session.beginTransaction();
Classes.Book retrieved = (Classes.Book) session.get( Classes.Book.class, b.id );
assertEquals( "Second", retrieved.edition.name );
session.delete( retrieved );
session.getTransaction().commit();
session.close();
}
public void testWorksWithGenericCollectionOfElements() {
Session session = openSession();
session.beginTransaction();
Classes.Edition<String> edition = new Classes.Edition<String>();
edition.name = "Second";
Classes.PopularBook b = new Classes.PopularBook();
b.editions.add( edition );
session.persist( b );
session.getTransaction().commit();
session.close();
session = openSession();
session.beginTransaction();
Classes.PopularBook retrieved = (Classes.PopularBook) session.get( Classes.PopularBook.class, b.id );
assertEquals( "Second", retrieved.editions.iterator().next().name );
session.delete( retrieved );
session.getTransaction().commit();
session.close();
}
@Override
protected Class[] getAnnotatedClasses() {
return new Class[]{
Classes.Book.class,
Classes.PopularBook.class
};
}
}

View File

@ -1,15 +1,42 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.generics;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
/**
* @author Emmanuel Bernard
*/
public class GenericsTest extends TestCase {
public class GenericsTest extends BaseCoreFunctionalTestCase {
@Test
public void testManyToOneGenerics() throws Exception {
Paper white = new Paper();
white.setName( "WhiteA4" );
@ -47,6 +74,7 @@ public class GenericsTest extends TestCase {
super.configure( cfg );
}
@Override
protected Class[] getAnnotatedClasses() {
return new Class[]{
Paper.class,

View File

@ -1,42 +1,72 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.generics;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.test.annotations.TestCase;
/**
* @author Paolo Perrotta
*/
public class UnresolvedTypeTest extends TestCase {
public void testAcceptsUnresolvedPropertyTypesIfATargetEntityIsExplicitlySet() {
Session s = openSession();
Transaction tx = s.beginTransaction();
Gene item = new Gene();
s.persist( item );
s.flush();
tx.rollback();
s.close();
}
public void testAcceptsUnresolvedPropertyTypesIfATypeExplicitlySet() {
Session s = openSession();
Transaction tx = s.beginTransaction();
Gene item = new Gene();
item.setState( State.DORMANT );
s.persist( item );
s.flush();
s.clear();
item = (Gene) s.get( Gene.class, item.getId() );
assertEquals( State.DORMANT, item.getState() );
tx.rollback();
s.close();
}
@Override
protected Class[] getAnnotatedClasses() {
return new Class[]{
Gene.class,
DNA.class
};
}
}
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
/**
* @author Paolo Perrotta
*/
public class UnresolvedTypeTest extends BaseCoreFunctionalTestCase {
@Test
public void testAcceptsUnresolvedPropertyTypesIfATargetEntityIsExplicitlySet() {
Session s = openSession();
Transaction tx = s.beginTransaction();
Gene item = new Gene();
s.persist( item );
s.flush();
tx.rollback();
s.close();
}
@Test
public void testAcceptsUnresolvedPropertyTypesIfATypeExplicitlySet() {
Session s = openSession();
Transaction tx = s.beginTransaction();
Gene item = new Gene();
item.setState( State.DORMANT );
s.persist( item );
s.flush();
s.clear();
item = (Gene) s.get( Gene.class, item.getId() );
assertEquals( State.DORMANT, item.getState() );
tx.rollback();
s.close();
}
@Override
protected Class[] getAnnotatedClasses() {
return new Class[]{
Gene.class,
DNA.class
};
}
}

View File

@ -1,23 +1,52 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.genericsinheritance;
import org.hibernate.Session;
import org.hibernate.test.annotations.TestCase;
/**
* @author Emmanuel Bernard
*/
public class GenericsInheritanceTest extends TestCase {
public void testMapping() throws Exception {
Session s = openSession();
s.close();
//mapping is tested
}
protected Class[] getAnnotatedClasses() {
return new Class[] {
ChildHierarchy1.class,
ParentHierarchy1.class,
ChildHierarchy22.class,
ParentHierarchy22.class
};
}
}
import org.hibernate.Session;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
/**
* @author Emmanuel Bernard
*/
public class GenericsInheritanceTest extends BaseCoreFunctionalTestCase {
@Test
public void testMapping() throws Exception {
Session s = openSession();
s.close();
//mapping is tested
}
@Override
protected Class[] getAnnotatedClasses() {
return new Class[] {
ChildHierarchy1.class,
ParentHierarchy1.class,
ChildHierarchy22.class,
ParentHierarchy22.class
};
}
}

View File

@ -1,25 +1,51 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.id;
import static org.hibernate.testing.TestLogger.LOG;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.test.annotations.id.entities.Planet;
import org.hibernate.test.annotations.id.entities.PlanetCheatSheet;
import static org.hibernate.testing.TestLogger.LOG;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
/**
* Tests for enum type as id.
*
* @author Hardy Ferentschik
* @see ANN-744
*/
@SuppressWarnings("unchecked")
public class EnumIdTest extends TestCase {
public EnumIdTest(String x) {
super(x);
}
@TestForIssue( jiraKey = "ANN-744" )
public class EnumIdTest extends BaseCoreFunctionalTestCase {
@Test
public void testEnumAsId() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -49,9 +75,6 @@ public class EnumIdTest extends TestCase {
s.close();
}
/**
* @see org.hibernate.test.annotations.TestCase#getAnnotatedClasses()
*/
@Override
protected Class[] getAnnotatedClasses() {
return new Class[] { PlanetCheatSheet.class };

View File

@ -1,17 +1,45 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.id;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.test.annotations.id.entities.Location;
import org.hibernate.test.annotations.id.entities.Tower;
import static org.junit.Assert.assertNotNull;
/**
* @author Emmanuel Bernard
*/
@SuppressWarnings("unchecked")
public class IdClassTest extends TestCase {
public class IdClassTest extends BaseCoreFunctionalTestCase {
@Test
public void testIdClassInSuperclass() throws Exception {
Tower tower = new Tower();
tower.latitude = 10.3;
@ -29,6 +57,7 @@ public class IdClassTest extends TestCase {
s.close();
}
@Override
protected Class[] getAnnotatedClasses() {
return new Class[]{
Tower.class

View File

@ -1,11 +1,35 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.id;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.cfg.Configuration;
import org.hibernate.mapping.Column;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.test.annotations.id.entities.Ball;
import org.hibernate.test.annotations.id.entities.BreakDance;
import org.hibernate.test.annotations.id.entities.Computer;
@ -24,11 +48,15 @@ import org.hibernate.test.annotations.id.entities.SoundSystem;
import org.hibernate.test.annotations.id.entities.Store;
import org.hibernate.test.annotations.id.entities.Tree;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
/**
* @author Emmanuel Bernard
*/
@SuppressWarnings("unchecked")
public class IdTest extends TestCase {
public class IdTest extends BaseCoreFunctionalTestCase {
@Test
public void testGenericGenerator() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -51,13 +79,13 @@ public class IdTest extends TestCase {
s.delete(fur);
tx.commit();
s.close();
}
/*
* Ensures that GenericGenerator annotations wrapped inside a
* GenericGenerators holder are bound correctly
*/
@Test
public void testGenericGenerators() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -69,6 +97,7 @@ public class IdTest extends TestCase {
s.close();
}
@Test
public void testTableGenerator() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -76,8 +105,8 @@ public class IdTest extends TestCase {
Ball b = new Ball();
Dog d = new Dog();
Computer c = new Computer();
s.persist(b);
s.persist(d);
s.persist( b );
s.persist( d );
s.persist(c);
tx.commit();
s.close();
@ -95,6 +124,7 @@ public class IdTest extends TestCase {
s.close();
}
@Test
public void testSequenceGenerator() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -111,6 +141,7 @@ public class IdTest extends TestCase {
s.close();
}
@Test
public void testClassLevelGenerator() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -127,6 +158,7 @@ public class IdTest extends TestCase {
s.close();
}
@Test
public void testMethodLevelGenerator() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -134,7 +166,7 @@ public class IdTest extends TestCase {
s.persist(b);
tx.commit();
s.close();
assertNotNull(b.getId());
assertNotNull( b.getId() );
s = openSession();
tx = s.beginTransaction();
@ -143,6 +175,7 @@ public class IdTest extends TestCase {
s.close();
}
@Test
public void testDefaultSequence() throws Exception {
Session s;
Transaction tx;
@ -163,6 +196,7 @@ public class IdTest extends TestCase {
s.close();
}
@Test
public void testParameterizedAuto() throws Exception {
Session s;
Transaction tx;
@ -177,12 +211,13 @@ public class IdTest extends TestCase {
s = openSession();
tx = s.beginTransaction();
Home reloadedHome = (Home) s.get(Home.class, h.getId());
assertEquals(h.getId(), reloadedHome.getId());
assertEquals( h.getId(), reloadedHome.getId() );
s.delete(reloadedHome);
tx.commit();
s.close();
}
@Test
public void testIdInEmbeddableSuperclass() throws Exception {
Session s;
Transaction tx;
@ -200,6 +235,7 @@ public class IdTest extends TestCase {
s.close();
}
@Test
public void testIdClass() throws Exception {
Session s;
Transaction tx;
@ -250,12 +286,14 @@ public class IdTest extends TestCase {
s.close();
}
@Test
public void testColumnDefinition() {
Column idCol = (Column) getCfg().getClassMapping(Ball.class.getName())
Column idCol = (Column) configuration().getClassMapping(Ball.class.getName())
.getIdentifierProperty().getValue().getColumnIterator().next();
assertEquals("ball_id", idCol.getName());
assertEquals( "ball_id", idCol.getName() );
}
@Test
public void testLowAllocationSize() throws Exception {
Session s;
Transaction tx;
@ -275,9 +313,7 @@ public class IdTest extends TestCase {
s.close();
}
/**
* @see org.hibernate.test.annotations.TestCase#getAnnotatedClasses()
*/
@Override
protected Class[] getAnnotatedClasses() {
return new Class[] { Ball.class, Shoe.class, Store.class,
Department.class, Dog.class, Computer.class, Home.class,
@ -286,9 +322,7 @@ public class IdTest extends TestCase {
BreakDance.class, Monkey.class};
}
/**
* @see org.hibernate.test.annotations.TestCase#getAnnotatedPackages()
*/
@Override
protected String[] getAnnotatedPackages() {
return new String[] { "org.hibernate.test.annotations",
"org.hibernate.test.annotations.id" };
@ -298,9 +332,4 @@ public class IdTest extends TestCase {
protected String[] getXmlFiles() {
return new String[] { "org/hibernate/test/annotations/orm.xml" };
}
@Override
protected void configure(Configuration cfg) {
cfg.setProperty( AnnotationConfiguration.USE_NEW_ID_GENERATOR_MAPPINGS, "true" );
}
}

View File

@ -1,35 +1,63 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.id;
import static org.hibernate.testing.TestLogger.LOG;
import java.io.PrintWriter;
import java.io.StringWriter;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.cfg.Configuration;
import org.hibernate.dialect.SQLServerDialect;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.ServiceRegistryBuilder;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseUnitTestCase;
import org.hibernate.test.annotations.id.entities.Bunny;
import org.hibernate.test.annotations.id.entities.PointyTooth;
import org.hibernate.test.annotations.id.entities.TwinkleToes;
import static org.hibernate.testing.TestLogger.LOG;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
/**
* Tests for JIRA issue ANN-748.
*
* @author Hardy Ferentschik
*/
@SuppressWarnings("unchecked")
public class JoinColumnOverrideTest extends TestCase {
public JoinColumnOverrideTest(String x) {
super(x);
}
public class JoinColumnOverrideTest extends BaseUnitTestCase {
@Test
@TestForIssue( jiraKey = "ANN-748" )
public void testBlownPrecision() throws Exception {
try {
AnnotationConfiguration config = new AnnotationConfiguration();
Configuration config = new Configuration();
config.addAnnotatedClass(Bunny.class);
config.addAnnotatedClass(PointyTooth.class);
config.addAnnotatedClass(TwinkleToes.class);
config.buildSessionFactory( getServiceRegistry() );
config.buildSessionFactory( ServiceRegistryBuilder.buildServiceRegistry( config.getProperties() ) );
String[] schema = config
.generateSchemaCreationScript(new SQLServerDialect());
for (String s : schema) {
@ -42,19 +70,12 @@ public class JoinColumnOverrideTest extends TestCase {
String expectedSqlTwinkleToes = "create table TwinkleToes (id numeric(128,0) not null, " +
"bunny_id numeric(128,0) null, primary key (id))";
assertEquals("Wrong SQL", expectedSqlTwinkleToes, schema[2]);
} catch (Exception e) {
}
catch (Exception e) {
StringWriter writer = new StringWriter();
e.printStackTrace(new PrintWriter(writer));
LOG.debug(writer.toString());
fail(e.getMessage());
}
}
/**
* @see org.hibernate.test.annotations.TestCase#getAnnotatedClasses()
*/
@Override
protected Class[] getAnnotatedClasses() {
return new Class[] {};
}
}

View File

@ -1,38 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010, 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.test.annotations.id;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.cfg.Configuration;
/**
* TODO : javadoc
*
* @author Steve Ebersole
*/
public class NewSchemeIdTest extends IdTest {
@Override
protected void configure(Configuration cfg) {
cfg.setProperty( AnnotationConfiguration.USE_NEW_ID_GENERATOR_MAPPINGS, "true" );
}
}

View File

@ -22,7 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.id.generationmappings;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.id.IdentifierGenerator;
@ -30,7 +30,14 @@ import org.hibernate.id.enhanced.OptimizerFactory;
import org.hibernate.id.enhanced.SequenceStyleGenerator;
import org.hibernate.id.enhanced.TableGenerator;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
/**
* Test mapping the {@link javax.persistence.GenerationType GenerationTypes} to the corresponding
@ -38,7 +45,7 @@ import org.hibernate.test.annotations.TestCase;
*
* @author Steve Ebersole
*/
public class NewGeneratorMappingsTest extends TestCase {
public class NewGeneratorMappingsTest extends BaseCoreFunctionalTestCase {
@Override
protected Class<?>[] getAnnotatedClasses() {
return new Class[] {
@ -52,25 +59,17 @@ public class NewGeneratorMappingsTest extends TestCase {
@Override
protected void configure(Configuration cfg) {
super.configure( cfg );
cfg.setProperty( AnnotationConfiguration.USE_NEW_ID_GENERATOR_MAPPINGS, "true" );
cfg.setProperty( Environment.HBM2DDL_AUTO, "" );
}
@Override
protected boolean recreateSchema() {
protected boolean createSchema() {
return false;
}
@Override
protected void runSchemaGeneration() {
}
@Override
protected void runSchemaDrop() {
}
@Test
public void testMinimalSequenceEntity() {
final EntityPersister persister = sfi().getEntityPersister( MinimalSequenceEntity.class.getName() );
final EntityPersister persister = sessionFactory().getEntityPersister( MinimalSequenceEntity.class.getName() );
IdentifierGenerator generator = persister.getIdentifierGenerator();
assertTrue( SequenceStyleGenerator.class.isInstance( generator ) );
SequenceStyleGenerator seqGenerator = (SequenceStyleGenerator) generator;
@ -82,8 +81,9 @@ public class NewGeneratorMappingsTest extends TestCase {
assertFalse( OptimizerFactory.NoopOptimizer.class.isInstance( seqGenerator.getOptimizer() ) );
}
@Test
public void testCompleteSequenceEntity() {
final EntityPersister persister = sfi().getEntityPersister( CompleteSequenceEntity.class.getName() );
final EntityPersister persister = sessionFactory().getEntityPersister( CompleteSequenceEntity.class.getName() );
IdentifierGenerator generator = persister.getIdentifierGenerator();
assertTrue( SequenceStyleGenerator.class.isInstance( generator ) );
SequenceStyleGenerator seqGenerator = (SequenceStyleGenerator) generator;
@ -93,8 +93,9 @@ public class NewGeneratorMappingsTest extends TestCase {
assertFalse( OptimizerFactory.NoopOptimizer.class.isInstance( seqGenerator.getOptimizer() ) );
}
@Test
public void testAutoEntity() {
final EntityPersister persister = sfi().getEntityPersister( AutoEntity.class.getName() );
final EntityPersister persister = sessionFactory().getEntityPersister( AutoEntity.class.getName() );
IdentifierGenerator generator = persister.getIdentifierGenerator();
assertTrue( SequenceStyleGenerator.class.isInstance( generator ) );
SequenceStyleGenerator seqGenerator = (SequenceStyleGenerator) generator;
@ -103,8 +104,9 @@ public class NewGeneratorMappingsTest extends TestCase {
assertEquals( SequenceStyleGenerator.DEFAULT_INCREMENT_SIZE, seqGenerator.getDatabaseStructure().getIncrementSize() );
}
@Test
public void testMinimalTableEntity() {
final EntityPersister persister = sfi().getEntityPersister( MinimalTableEntity.class.getName() );
final EntityPersister persister = sessionFactory().getEntityPersister( MinimalTableEntity.class.getName() );
IdentifierGenerator generator = persister.getIdentifierGenerator();
assertTrue( TableGenerator.class.isInstance( generator ) );
TableGenerator tabGenerator = (TableGenerator) generator;

View File

@ -1,25 +1,51 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.id.sequences;
import static org.hibernate.testing.TestLogger.LOG;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.test.annotations.id.sequences.entities.Planet;
import org.hibernate.test.annotations.id.sequences.entities.PlanetCheatSheet;
import static org.hibernate.testing.TestLogger.LOG;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
/**
* Tests for enum type as id.
*
* @author Hardy Ferentschik
* @see ANN-744
*/
@SuppressWarnings("unchecked")
public class EnumIdTest extends TestCase {
public EnumIdTest(String x) {
super(x);
}
@TestForIssue( jiraKey = "ANN-744" )
public class EnumIdTest extends BaseCoreFunctionalTestCase {
@Test
public void testEnumAsId() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -49,9 +75,6 @@ public class EnumIdTest extends TestCase {
s.close();
}
/**
* @see org.hibernate.test.annotations.TestCase#getAnnotatedClasses()
*/
@Override
protected Class[] getAnnotatedClasses() {
return new Class[] { PlanetCheatSheet.class };

View File

@ -1,18 +1,45 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.id.sequences;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.test.annotations.id.sequences.entities.Location;
import org.hibernate.test.annotations.id.sequences.entities.Tower;
import static org.junit.Assert.assertNotNull;
/**
* @author Emmanuel Bernard
*/
@SuppressWarnings("unchecked")
public class IdClassTest extends TestCase {
public class IdClassTest extends BaseCoreFunctionalTestCase {
@Test
public void testIdClassInSuperclass() throws Exception {
Tower tower = new Tower();
tower.latitude = 10.3;
@ -30,9 +57,8 @@ public class IdClassTest extends TestCase {
s.close();
}
@Override
protected Class[] getAnnotatedClasses() {
return new Class[]{
Tower.class
};
return new Class[] { Tower.class };
}
}

View File

@ -1,4 +1,3 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
@ -26,13 +25,14 @@ package org.hibernate.test.annotations.id.sequences;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.cfg.Configuration;
import org.hibernate.mapping.Column;
import org.junit.Test;
import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.RequiresDialectFeature;
import org.hibernate.test.annotations.TestCase;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.test.annotations.id.sequences.entities.Ball;
import org.hibernate.test.annotations.id.sequences.entities.BreakDance;
import org.hibernate.test.annotations.id.sequences.entities.Computer;
@ -51,12 +51,16 @@ import org.hibernate.test.annotations.id.sequences.entities.SoundSystem;
import org.hibernate.test.annotations.id.sequences.entities.Store;
import org.hibernate.test.annotations.id.sequences.entities.Tree;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
/**
* @author Emmanuel Bernard
*/
@SuppressWarnings("unchecked")
@RequiresDialectFeature(DialectChecks.SupportsSequences.class)
public class IdTest extends TestCase {
public class IdTest extends BaseCoreFunctionalTestCase {
@Test
public void testGenericGenerator() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -82,12 +86,9 @@ public class IdTest extends TestCase {
}
/*
* Ensures that GenericGenerator annotations wrapped inside a
* GenericGenerators holder are bound correctly
*/
@Test
public void testGenericGenerators() throws Exception {
// Ensures that GenericGenerator annotations wrapped inside a GenericGenerators holder are bound correctly
Session s = openSession();
Transaction tx = s.beginTransaction();
Monkey monkey = new Monkey();
@ -98,6 +99,7 @@ public class IdTest extends TestCase {
s.close();
}
@Test
public void testTableGenerator() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -126,6 +128,7 @@ public class IdTest extends TestCase {
s.close();
}
@Test
public void testSequenceGenerator() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -142,6 +145,7 @@ public class IdTest extends TestCase {
s.close();
}
@Test
public void testClassLevelGenerator() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -158,6 +162,7 @@ public class IdTest extends TestCase {
s.close();
}
@Test
public void testMethodLevelGenerator() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -174,6 +179,7 @@ public class IdTest extends TestCase {
s.close();
}
@Test
public void testDefaultSequence() throws Exception {
Session s;
Transaction tx;
@ -194,6 +200,7 @@ public class IdTest extends TestCase {
s.close();
}
@Test
public void testParameterizedAuto() throws Exception {
Session s;
Transaction tx;
@ -214,6 +221,7 @@ public class IdTest extends TestCase {
s.close();
}
@Test
public void testIdInEmbeddableSuperclass() throws Exception {
Session s;
Transaction tx;
@ -231,6 +239,7 @@ public class IdTest extends TestCase {
s.close();
}
@Test
public void testIdClass() throws Exception {
Session s;
Transaction tx;
@ -284,12 +293,14 @@ public class IdTest extends TestCase {
s.close();
}
@Test
public void testColumnDefinition() {
Column idCol = ( Column ) getCfg().getClassMapping( Ball.class.getName() )
Column idCol = ( Column ) configuration().getClassMapping( Ball.class.getName() )
.getIdentifierProperty().getValue().getColumnIterator().next();
assertEquals( "ball_id", idCol.getName() );
}
@Test
public void testLowAllocationSize() throws Exception {
Session s;
Transaction tx;
@ -309,9 +320,7 @@ public class IdTest extends TestCase {
s.close();
}
/**
* @see org.hibernate.test.annotations.TestCase#getAnnotatedClasses()
*/
@Override
protected Class[] getAnnotatedClasses() {
return new Class[] {
Ball.class, Shoe.class, Store.class,
@ -322,9 +331,7 @@ public class IdTest extends TestCase {
};
}
/**
* @see org.hibernate.test.annotations.TestCase#getAnnotatedPackages()
*/
@Override
protected String[] getAnnotatedPackages() {
return new String[] {
"org.hibernate.test.annotations",
@ -336,10 +343,4 @@ public class IdTest extends TestCase {
protected String[] getXmlFiles() {
return new String[] { "org/hibernate/test/annotations/orm.xml" };
}
@Override
protected void configure(Configuration cfg) {
cfg.setProperty( AnnotationConfiguration.USE_NEW_ID_GENERATOR_MAPPINGS, "true" );
}
}

View File

@ -1,37 +1,42 @@
//$Id$
package org.hibernate.test.annotations.id.sequences;
import static org.hibernate.testing.TestLogger.LOG;
import java.io.PrintWriter;
import java.io.StringWriter;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.cfg.Configuration;
import org.hibernate.dialect.SQLServerDialect;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.ServiceRegistryBuilder;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseUnitTestCase;
import org.hibernate.test.annotations.id.sequences.entities.Bunny;
import org.hibernate.test.annotations.id.sequences.entities.PointyTooth;
import org.hibernate.test.annotations.id.sequences.entities.TwinkleToes;
import static org.hibernate.testing.TestLogger.LOG;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
/**
* Tests for JIRA issue ANN-748.
*
* @author Hardy Ferentschik
*/
@SuppressWarnings("unchecked")
public class JoinColumnOverrideTest extends TestCase {
public JoinColumnOverrideTest(String x) {
super(x);
}
public class JoinColumnOverrideTest extends BaseUnitTestCase {
@Test
@TestForIssue( jiraKey = "ANN-748" )
public void testBlownPrecision() throws Exception {
try {
AnnotationConfiguration config = new AnnotationConfiguration();
Configuration config = new Configuration();
config.addAnnotatedClass(Bunny.class);
config.addAnnotatedClass(PointyTooth.class);
config.addAnnotatedClass(TwinkleToes.class);
config.buildSessionFactory( getServiceRegistry() );
String[] schema = config
.generateSchemaCreationScript(new SQLServerDialect());
config.buildSessionFactory( ServiceRegistryBuilder.buildServiceRegistry( config.getProperties() ) );
String[] schema = config.generateSchemaCreationScript( new SQLServerDialect() );
for (String s : schema) {
LOG.debug(s);
}
@ -42,19 +47,12 @@ public class JoinColumnOverrideTest extends TestCase {
String expectedSqlTwinkleToes = "create table TwinkleToes (id numeric(128,0) not null, " +
"bunny_id numeric(128,0) null, primary key (id))";
assertEquals("Wrong SQL", expectedSqlTwinkleToes, schema[2]);
} catch (Exception e) {
}
catch (Exception e) {
StringWriter writer = new StringWriter();
e.printStackTrace(new PrintWriter(writer));
LOG.debug(writer.toString());
fail(e.getMessage());
}
}
/**
* @see org.hibernate.test.annotations.TestCase#getAnnotatedClasses()
*/
@Override
protected Class[] getAnnotatedClasses() {
return new Class[] {};
}
}

View File

@ -1,38 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010, 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.test.annotations.id.sequences;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.cfg.Configuration;
/**
* TODO : javadoc
*
* @author Steve Ebersole
*/
public class NewSchemeIdTest extends IdTest {
@Override
protected void configure(Configuration cfg) {
cfg.setProperty( AnnotationConfiguration.USE_NEW_ID_GENERATOR_MAPPINGS, "true" );
}
}

View File

@ -21,19 +21,22 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.hibernate.test.annotations.idclass;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
/**
* A IdClassTestCase.
*
* @author <a href="mailto:stale.pedersen@jboss.org">Stale W. Pedersen</a>
* @version $Revision: 1.1 $
*/
public class IdClassCompositePKTest extends TestCase {
public class IdClassCompositePKTest extends BaseCoreFunctionalTestCase {
@Test
public void testEntityMappningPropertiesAreNotIgnored() {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -49,9 +52,8 @@ public class IdClassCompositePKTest extends TestCase {
s.close();
}
@Override
protected Class[] getAnnotatedClasses() {
return new Class[] {
DomainAdmin.class
};
return new Class[] { DomainAdmin.class };
}
}

View File

@ -1,4 +1,3 @@
// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2005, JBoss Inc., and individual contributors as indicated
@ -22,8 +21,10 @@
*/
package org.hibernate.test.annotations.idclass.xml;
import org.junit.Test;
import org.hibernate.testing.FailureExpected;
import org.hibernate.test.annotations.TestCase;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
/**
* A test for HHH-4282
@ -31,9 +32,9 @@ import org.hibernate.test.annotations.TestCase;
* @author Hardy Ferentschik
*/
@FailureExpected( jiraKey = "HHH-4282" )
public class IdClassXmlTest extends TestCase {
public void testEntityMappningPropertiesAreNotIgnored() {
public class IdClassXmlTest extends BaseCoreFunctionalTestCase {
@Test
public void testEntityMappingPropertiesAreNotIgnored() {
throw new RuntimeException();
// Session s = openSession();
// Transaction tx = s.beginTransaction();
@ -50,12 +51,14 @@ public class IdClassXmlTest extends TestCase {
// s.close();
}
@Override
protected Class[] getAnnotatedClasses() {
return new Class[] {
HabitatSpeciesLink.class
};
}
@Override
protected String[] getXmlFiles() {
return new String[] {
"org/hibernate/test/annotations/idclass/xml/HabitatSpeciesLink.xml"

View File

@ -23,17 +23,24 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.idclassgeneratedvalue;
import java.util.List;
import org.hibernate.Session;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
/**
* A test.
*
* @author <a href="mailto:stale.pedersen@jboss.org">Stale W. Pedersen</a>
*/
public class IdClassGeneratedValueTest extends TestCase {
public class IdClassGeneratedValueTest extends BaseCoreFunctionalTestCase {
@Test
@SuppressWarnings({ "unchecked" })
public void testBaseLine() {
Session s = openSession();
@ -57,6 +64,7 @@ public class IdClassGeneratedValueTest extends TestCase {
s.close();
}
@Test
@SuppressWarnings({ "unchecked" })
public void testSingleGeneratedValue() {
Session s = openSession();
@ -81,6 +89,7 @@ public class IdClassGeneratedValueTest extends TestCase {
s.close();
}
@Test
@SuppressWarnings({ "unchecked" })
public void testMultipleGeneratedValue() {
Session s = openSession();
@ -106,6 +115,7 @@ public class IdClassGeneratedValueTest extends TestCase {
s.close();
}
@Override
protected Class[] getAnnotatedClasses() {
return new Class[] {
Simple.class,

View File

@ -1,44 +1,74 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.identifiercollection;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.test.annotations.TestCase;
/**
* @author Emmanuel Bernard
*/
public class IdentifierCollectionTest extends TestCase {
public void testIdBag() throws Exception {
Passport passport = new Passport();
passport.setName( "Emmanuel Bernard" );
Stamp canada = new Stamp();
canada.setCountry( "Canada" );
passport.getStamps().add( canada );
passport.getVisaStamp().add( canada );
Stamp norway = new Stamp();
norway.setCountry( "Norway" );
passport.getStamps().add( norway );
passport.getStamps().add(canada);
Session s = openSession();
Transaction tx = s.beginTransaction();
s.persist( passport );
s.flush();
//s.clear();
passport = (Passport) s.get( Passport.class, passport.getId() );
int canadaCount = 0;
for ( Stamp stamp : passport.getStamps() ) {
if ( "Canada".equals( stamp.getCountry() ) ) canadaCount++;
}
assertEquals( 2, canadaCount );
assertEquals( 1, passport.getVisaStamp().size() );
tx.rollback();
s.close();
}
protected Class[] getAnnotatedClasses() {
return new Class[] {
Passport.class,
Stamp.class
};
}
}
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
/**
* @author Emmanuel Bernard
*/
public class IdentifierCollectionTest extends BaseCoreFunctionalTestCase {
@Test
public void testIdBag() throws Exception {
Passport passport = new Passport();
passport.setName( "Emmanuel Bernard" );
Stamp canada = new Stamp();
canada.setCountry( "Canada" );
passport.getStamps().add( canada );
passport.getVisaStamp().add( canada );
Stamp norway = new Stamp();
norway.setCountry( "Norway" );
passport.getStamps().add( norway );
passport.getStamps().add(canada);
Session s = openSession();
Transaction tx = s.beginTransaction();
s.persist( passport );
s.flush();
//s.clear();
passport = (Passport) s.get( Passport.class, passport.getId() );
int canadaCount = 0;
for ( Stamp stamp : passport.getStamps() ) {
if ( "Canada".equals( stamp.getCountry() ) ) canadaCount++;
}
assertEquals( 2, canadaCount );
assertEquals( 1, passport.getVisaStamp().size() );
tx.rollback();
s.close();
}
@Override
protected Class[] getAnnotatedClasses() {
return new Class[] {
Passport.class,
Stamp.class
};
}
}

View File

@ -1,81 +1,88 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.idmanytoone;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.test.annotations.TestCase;
/**
* @author Emmanuel Bernard
*/
public class IdManyToOneTest extends TestCase {
public void testFkCreationOrdering() throws Exception {
//no real test case, the sessionFactory building is tested
Session s = openSession();
s.close();
}
public void getBiDirOneToManyInId() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
CardKey key = new CardKey();
s.persist( key );
Project project = new Project();
s.persist( project );
Card card = new Card();
card.getPrimaryKey().setProject( project );
s.persist( card );
CardField field = new CardField();
field.getPrimaryKey().setKey( key );
field.getPrimaryKey().setCard( card );
s.persist( field );
card.setMainCardField( field );
s.flush();
s.clear();
card = (Card) s.createQuery( "from Card c").list().get(0);
assertEquals( 1, card.getFields().size() );
assertEquals( card.getMainCardField(), card.getFields().iterator().next() );
tx.rollback();
s.close();
}
public void testIdClassManyToOne() {
Session s = openSession();
Transaction tx = s.beginTransaction();
Store store = new Store();
Customer customer = new Customer();
s.persist( store );
s.persist( customer );
StoreCustomer sc = new StoreCustomer( store, customer );
s.persist( sc );
s.flush();
s.clear();
store = (Store) s.get(Store.class, store.id );
assertEquals( 1, store.customers.size() );
assertEquals( customer.id, store.customers.iterator().next().customer.id );
tx.rollback();
//TODO test Customers / ShoppingBaskets / BasketItems testIdClassManyToOneWithReferenceColumn
s.close();
}
protected Class[] getAnnotatedClasses() {
return new Class[] {
Store.class,
Customer.class,
StoreCustomer.class,
CardKey.class,
CardField.class,
Card.class,
Project.class,
//tested only through deployment
//ANN-590 testIdClassManyToOneWithReferenceColumn
Customers.class,
ShoppingBaskets.class,
ShoppingBasketsPK.class,
BasketItems.class,
BasketItemsPK.class
};
}
}
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
/**
* @author Emmanuel Bernard
*/
public class IdManyToOneTest extends BaseCoreFunctionalTestCase {
@Test
public void testFkCreationOrdering() throws Exception {
//no real test case, the sessionFactory building is tested
Session s = openSession();
s.close();
}
@Test
public void testIdClassManyToOne() {
Session s = openSession();
Transaction tx = s.beginTransaction();
Store store = new Store();
Customer customer = new Customer();
s.persist( store );
s.persist( customer );
StoreCustomer sc = new StoreCustomer( store, customer );
s.persist( sc );
s.flush();
s.clear();
store = (Store) s.get(Store.class, store.id );
assertEquals( 1, store.customers.size() );
assertEquals( customer.id, store.customers.iterator().next().customer.id );
tx.rollback();
//TODO test Customers / ShoppingBaskets / BasketItems testIdClassManyToOneWithReferenceColumn
s.close();
}
@Override
protected Class[] getAnnotatedClasses() {
return new Class[] {
Store.class,
Customer.class,
StoreCustomer.class,
CardKey.class,
CardField.class,
Card.class,
Project.class,
//tested only through deployment
//ANN-590 testIdClassManyToOneWithReferenceColumn
Customers.class,
ShoppingBaskets.class,
ShoppingBasketsPK.class,
BasketItems.class,
BasketItemsPK.class
};
}
}

View File

@ -1,23 +1,43 @@
//$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.idmanytoone.alphabetical;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
/**
* @author Emmanuel Bernard
*/
public class AlphabeticalIdManyToOneTest extends TestCase {
public class AlphabeticalIdManyToOneTest extends BaseCoreFunctionalTestCase {
@Test
public void testAlphabeticalTest() throws Exception {
//test through deployment
}
@Override
protected Class[] getAnnotatedClasses() {
return new Class[] {
B.class,
C.class,
A.class
};
return new Class[] { B.class, C.class, A.class };
}
}

View File

@ -1,15 +1,42 @@
//$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.idmanytoone.alphabetical;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
/**
* @author Emmanuel Bernard
*/
public class AlphabeticalManyToOneTest extends TestCase {
public class AlphabeticalManyToOneTest extends BaseCoreFunctionalTestCase {
@Test
public void testAlphabeticalTest() throws Exception {
//test through deployment
}
@Override
protected Class[] getAnnotatedClasses() {
return new Class[] {
Acces.class,

View File

@ -1,14 +1,47 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.immutable;
import static org.hibernate.testing.TestLogger.LOG;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.AnnotationException;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.test.annotations.TestCase;
import org.hibernate.cfg.Configuration;
import org.junit.Test;
import org.hibernate.testing.ServiceRegistryBuilder;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.hibernate.testing.TestLogger.LOG;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
/**
* Tests for <code>Immutable</code> annotation.
@ -16,12 +49,8 @@ import org.hibernate.test.annotations.TestCase;
* @author Hardy Ferentschik
*/
@SuppressWarnings("unchecked")
public class ImmutableTest extends TestCase {
public ImmutableTest(String x) {
super(x);
}
public class ImmutableTest extends BaseCoreFunctionalTestCase {
@Test
public void testImmutableEntity() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -50,22 +79,9 @@ public class ImmutableTest extends TestCase {
assertEquals("Name should not have changed", "Germany", germany.getName());
tx.commit();
s.close();
// // try deletion
// s = openSession();
// tx = s.beginTransaction();
// s.delete(germany);
// tx.commit();
// s.close();
//
// s = openSession();
// tx = s.beginTransaction();
// germany = (Country) s.get(Country.class, country.getId());
// assertNotNull(germany);
// assertEquals("Name should not have changed", "Germany", germany.getName());
// s.close();
}
@Test
public void testImmutableCollection() {
Country country = new Country();
country.setName("Germany");
@ -101,7 +117,8 @@ public class ImmutableTest extends TestCase {
try {
tx.commit();
fail();
} catch (HibernateException e) {
}
catch (HibernateException e) {
assertTrue(e.getMessage().contains("changed an immutable collection instance"));
LOG.debug("success");
}
@ -133,20 +150,19 @@ public class ImmutableTest extends TestCase {
s.close();
}
@Test
public void testMiscplacedImmutableAnnotation() {
try {
AnnotationConfiguration config = new AnnotationConfiguration();
Configuration config = new Configuration();
config.addAnnotatedClass(Foobar.class);
config.buildSessionFactory( getServiceRegistry() );
config.buildSessionFactory( ServiceRegistryBuilder.buildServiceRegistry( config.getProperties() ) );
fail();
} catch (AnnotationException ae) {
}
catch (AnnotationException ae) {
LOG.debug("succes");
}
}
/**
* @see org.hibernate.test.annotations.TestCase#getAnnotatedClasses()
*/
@Override
protected Class[] getAnnotatedClasses() {
return new Class[] { Country.class, State.class};

View File

@ -37,22 +37,31 @@ import org.hibernate.dialect.HSQLDialect;
import org.hibernate.mapping.Collection;
import org.hibernate.mapping.Column;
import org.junit.Test;
import org.hibernate.testing.RequiresDialect;
import org.hibernate.test.annotations.TestCase;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
/**
* Test index collections
*
* @author Emmanuel Bernard
*/
public class IndexedCollectionTest extends TestCase {
public class IndexedCollectionTest extends BaseCoreFunctionalTestCase {
@Test
public void testJPA2DefaultMapColumns() throws Exception {
isDefaultKeyColumnPresent( Atmosphere.class.getName(), "gasesDef", "_KEY" );
isDefaultKeyColumnPresent( Atmosphere.class.getName(), "gasesPerKeyDef", "_KEY" );
isNotDefaultKeyColumnPresent( Atmosphere.class.getName(), "gasesDefLeg", "_KEY" );
}
@Test
public void testJPA2DefaultIndexColumns() throws Exception {
isDefaultKeyColumnPresent( Drawer.class.getName(), "dresses", "_ORDER" );
}
@ -63,7 +72,7 @@ public class IndexedCollectionTest extends TestCase {
}
private boolean isDefaultColumnPresent(String collectionOwner, String propertyName, String suffix) {
final Collection collection = getCfg().getCollectionMapping( collectionOwner + "." + propertyName );
final Collection collection = configuration().getCollectionMapping( collectionOwner + "." + propertyName );
final Iterator columnIterator = collection.getCollectionTable().getColumnIterator();
boolean hasDefault = false;
while ( columnIterator.hasNext() ) {
@ -78,6 +87,7 @@ public class IndexedCollectionTest extends TestCase {
isDefaultColumnPresent(collectionOwner, propertyName, suffix) );
}
@Test
public void testFkList() throws Exception {
Wardrobe w = new Wardrobe();
Drawer d1 = new Drawer();
@ -122,6 +132,7 @@ public class IndexedCollectionTest extends TestCase {
s.close();
}
@Test
public void testJoinedTableList() throws Exception {
Wardrobe w = new Wardrobe();
w.setDrawers( new ArrayList<Drawer>() );
@ -171,6 +182,7 @@ public class IndexedCollectionTest extends TestCase {
s.close();
}
@Test
public void testMapKey() throws Exception {
Session s;
Transaction tx;
@ -225,6 +237,7 @@ public class IndexedCollectionTest extends TestCase {
s.close();
}
@Test
public void testDefaultMapKey() throws Exception {
Session s;
Transaction tx;
@ -270,6 +283,7 @@ public class IndexedCollectionTest extends TestCase {
s.close();
}
@Test
public void testMapKeyToEntity() throws Exception {
Session s;
Transaction tx;
@ -315,6 +329,7 @@ public class IndexedCollectionTest extends TestCase {
s.close();
}
@Test
@RequiresDialect(HSQLDialect.class)
public void testComponentSubPropertyMapKey() throws Exception {
Session s;
@ -359,6 +374,7 @@ public class IndexedCollectionTest extends TestCase {
s.close();
}
@Test
public void testMapKeyOnManyToMany() throws Exception {
Session s;
s = openSession();
@ -387,6 +403,7 @@ public class IndexedCollectionTest extends TestCase {
s.close();
}
@Test
public void testMapKeyOnManyToManyOnId() throws Exception {
Session s;
s = openSession();
@ -415,6 +432,7 @@ public class IndexedCollectionTest extends TestCase {
s.close();
}
@Test
public void testMapKeyAndIdClass() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -437,6 +455,7 @@ public class IndexedCollectionTest extends TestCase {
s.close();
}
@Test
public void testRealMap() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -466,6 +485,7 @@ public class IndexedCollectionTest extends TestCase {
s.close();
}
@Test
public void testTemporalKeyMap() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -485,6 +505,7 @@ public class IndexedCollectionTest extends TestCase {
s.close();
}
@Test
public void testEnumKeyType() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -502,6 +523,7 @@ public class IndexedCollectionTest extends TestCase {
s.close();
}
@Test
public void testMapKeyEntityEntity() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -529,6 +551,7 @@ public class IndexedCollectionTest extends TestCase {
s.close();
}
@Test
public void testEntityKeyElementTarget() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -550,6 +573,7 @@ public class IndexedCollectionTest extends TestCase {
s.close();
}
@Test
public void testSortedMap() {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -574,6 +598,7 @@ public class IndexedCollectionTest extends TestCase {
s.close();
}
@Test
public void testMapKeyLoad() throws Exception {
Session s;
Transaction tx;
@ -613,11 +638,7 @@ public class IndexedCollectionTest extends TestCase {
s.close();
}
public IndexedCollectionTest(String x) {
super( x );
}
@Override
protected Class[] getAnnotatedClasses() {
return new Class[]{
Wardrobe.class,

View File

@ -1,39 +1,68 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.indexcoll;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.test.annotations.TestCase;
/**
* @author Emmanuel Bernard
*/
public class MapKeyTest extends TestCase {
public void testMapKeyOnEmbeddedId() {
Session s = openSession();
Transaction tx = s.beginTransaction();
Generation c = new Generation();
c.setAge( "a" );
c.setCulture( "b" );
GenerationGroup r = new GenerationGroup();
r.setGeneration( c );
s.persist( r );
GenerationUser m = new GenerationUser();
s.persist( m );
m.getRef().put( c, r );
s.flush();
s.clear();
m = (GenerationUser) s.get( GenerationUser.class, m.getId() );
assertEquals( "a", m.getRef().keySet().iterator().next().getAge() );
tx.rollback();
s.close();
}
protected Class[] getAnnotatedClasses() {
return new Class[] {
GenerationUser.class,
GenerationGroup.class
};
}
}
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
/**
* @author Emmanuel Bernard
*/
public class MapKeyTest extends BaseCoreFunctionalTestCase {
@Test
public void testMapKeyOnEmbeddedId() {
Session s = openSession();
Transaction tx = s.beginTransaction();
Generation c = new Generation();
c.setAge( "a" );
c.setCulture( "b" );
GenerationGroup r = new GenerationGroup();
r.setGeneration( c );
s.persist( r );
GenerationUser m = new GenerationUser();
s.persist( m );
m.getRef().put( c, r );
s.flush();
s.clear();
m = (GenerationUser) s.get( GenerationUser.class, m.getId() );
assertEquals( "a", m.getRef().keySet().iterator().next().getAge() );
tx.rollback();
s.close();
}
@Override
protected Class[] getAnnotatedClasses() {
return new Class[] {
GenerationUser.class,
GenerationGroup.class
};
}
}

View File

@ -1,27 +1,56 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.inheritance;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.test.annotations.A320;
import org.hibernate.test.annotations.A320b;
import org.hibernate.test.annotations.Plane;
import org.hibernate.test.annotations.TestCase;
import org.hibernate.test.annotations.inheritance.singletable.Funk;
import org.hibernate.test.annotations.inheritance.singletable.Music;
import org.hibernate.test.annotations.inheritance.singletable.Noise;
import org.hibernate.test.annotations.inheritance.singletable.Rock;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
/**
* @author Emmanuel Bernard
*/
public class SubclassTest extends TestCase {
public SubclassTest(String x) {
super( x );
}
public class SubclassTest extends BaseCoreFunctionalTestCase {
@Test
public void testPolymorphism() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -51,6 +80,7 @@ public class SubclassTest extends TestCase {
s.close();
}
@Test
public void test2ndLevelSubClass() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -72,6 +102,7 @@ public class SubclassTest extends TestCase {
s.close();
}
@Test
public void testEmbeddedSuperclass() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -99,6 +130,7 @@ public class SubclassTest extends TestCase {
s.close();
}
@Test
public void testFormula() throws Exception {
Session s;
Transaction tx;
@ -134,21 +166,7 @@ public class SubclassTest extends TestCase {
s.close();
}
private void checkClassType(Fruit fruitToTest, Fruit f, Apple a) {
if ( fruitToTest.getId().equals( f.getId() ) ) {
assertFalse( fruitToTest instanceof Apple );
}
else if ( fruitToTest.getId().equals( a.getId() ) ) {
assertTrue( fruitToTest instanceof Apple );
}
else {
fail( "Result does not contains the previously inserted elements" );
}
}
/**
* @see org.hibernate.test.annotations.TestCase#getAnnotatedClasses()
*/
@Override
protected Class[] getAnnotatedClasses() {
return new Class[]{
A320b.class, //subclasses should be properly reordered

View File

@ -21,24 +21,34 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
//$Id$
package org.hibernate.test.annotations.inheritance.discriminatoroptions;
import org.hibernate.cfg.Configuration;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.RootClass;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.testing.junit4.BaseUnitTestCase;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
/**
* Test for the @DiscriminatorOptions annotations.
*
* @author Hardy Ferentschik
*/
public class DiscriminatorOptionsTest extends TestCase {
public class DiscriminatorOptionsTest extends BaseUnitTestCase {
@Test
public void testNonDefaultOptions() throws Exception {
buildConfiguration();
PersistentClass persistentClass = cfg.getClassMapping( BaseClass.class.getName() );
Configuration configuration = new Configuration();
configuration.addAnnotatedClass( BaseClass.class );
configuration.addAnnotatedClass( SubClass.class );
configuration.buildMappings();
PersistentClass persistentClass = configuration.getClassMapping( BaseClass.class.getName() );
assertNotNull( persistentClass );
assertTrue( persistentClass instanceof RootClass );
@ -46,10 +56,4 @@ public class DiscriminatorOptionsTest extends TestCase {
assertTrue( "Discriminator should be forced", root.isForceDiscriminator() );
assertFalse( "Discriminator should not be insertable", root.isDiscriminatorInsertable() );
}
protected Class[] getAnnotatedClasses() {
return new Class[] {
BaseClass.class, SubClass.class
};
}
}

View File

@ -1,32 +1,53 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.inheritance.joined;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.test.annotations.TestCase;
/**
* @author Emmanuel Bernard
*/
public class JoinedSubclassAndSecondaryTable extends TestCase {
public void testSecondaryTableAndJoined() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
SwimmingPool sp = new SwimmingPool();
sp.setAddress( "Park Avenue" );
s.persist( sp );
tx.rollback();
s.close();
}
/**
* @see org.hibernate.test.annotations.TestCase#getAnnotatedClasses()
*/
protected Class[] getAnnotatedClasses() {
return new Class[]{
Pool.class,
SwimmingPool.class
};
}
}
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
/**
* @author Emmanuel Bernard
*/
public class JoinedSubclassAndSecondaryTable extends BaseCoreFunctionalTestCase {
@Test
public void testSecondaryTableAndJoined() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
SwimmingPool sp = new SwimmingPool();
sp.setAddress( "Park Avenue" );
s.persist( sp );
tx.rollback();
s.close();
}
@Override
protected Class[] getAnnotatedClasses() {
return new Class[] { Pool.class, SwimmingPool.class };
}
}

View File

@ -1,4 +1,3 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
@ -23,22 +22,30 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.inheritance.joined;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
/**
* @author Emmanuel Bernard
*/
public class JoinedSubclassTest extends TestCase {
public JoinedSubclassTest(String x) {
super( x );
}
public class JoinedSubclassTest extends BaseCoreFunctionalTestCase {
@Test
public void testDefault() throws Exception {
Session s;
Transaction tx;
@ -66,6 +73,7 @@ public class JoinedSubclassTest extends TestCase {
s.close();
}
@Test
public void testManyToOneOnAbstract() throws Exception {
Folder f = new Folder();
f.setName( "data" );
@ -88,7 +96,6 @@ public class JoinedSubclassTest extends TestCase {
s.delete( remove.getAppliesOn() );
tx.commit();
s.close();
}
private void checkClassType(File fruitToTest, File f, Folder a) {
@ -103,9 +110,9 @@ public class JoinedSubclassTest extends TestCase {
}
}
@Test
public void testJoinedAbstractClass() throws Exception {
Session s;
Transaction tx;
s = openSession();
s.getTransaction().begin();
Sweater sw = new Sweater();
@ -124,6 +131,7 @@ public class JoinedSubclassTest extends TestCase {
s.close();
}
@Test
public void testInheritance() throws Exception {
Session session = openSession();
Transaction transaction = session.beginTransaction();
@ -146,9 +154,10 @@ public class JoinedSubclassTest extends TestCase {
session.close();
}
//HHH-4250 : @ManyToOne - @OneToMany doesn't work with @Inheritance(strategy= InheritanceType.JOINED)
@Test
@TestForIssue( jiraKey = "HHH-4250" )
public void testManyToOneWithJoinTable() {
//HHH-4250 : @ManyToOne - @OneToMany doesn't work with @Inheritance(strategy= InheritanceType.JOINED)
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -172,7 +181,7 @@ public class JoinedSubclassTest extends TestCase {
s.clear();
c1 = (Client) s.load(Client.class, c1.getId());
assertEquals(5000.0, c1.getAccount().getBalance());
assertEquals( 5000.0, c1.getAccount().getBalance(), 0.01 );
s.flush();
s.clear();
@ -188,11 +197,10 @@ public class JoinedSubclassTest extends TestCase {
s.close();
}
/**
* HHH-4240 - SecondaryTables not recognized when using JOINED inheritance
*/
@Test
@TestForIssue( jiraKey = "HHH-4240" )
public void testSecondaryTables() {
// HHH-4240 - SecondaryTables not recognized when using JOINED inheritance
Session s = openSession();
s.getTransaction().begin();
@ -219,41 +227,7 @@ public class JoinedSubclassTest extends TestCase {
s.close();
}
// public void testManyToOneAndJoin() throws Exception {
// Session session = openSession();
// Transaction transaction = session.beginTransaction();
// Parent parent = new Parent();
// session.persist( parent );
// PropertyAsset property = new PropertyAsset();
// property.setParent( parent );
// property.setPrice( 230000d );
// FinancialAsset financial = new FinancialAsset();
// financial.setParent( parent );
// financial.setPrice( 230000d );
// session.persist( financial );
// session.persist( property );
// session.flush();
// session.clear();
// parent = (Parent) session.get( Parent.class, parent.getId() );
// assertNotNull( parent );
// assertEquals( 1, parent.getFinancialAssets().size() );
// assertEquals( 1, parent.getPropertyAssets().size() );
// assertEquals( property.getId(), parent.getPropertyAssets().iterator().next() );
// transaction.rollback();
// session.close();
// }
@Override
protected String[] getXmlFiles() {
return new String[] {
//"org/hibernate/test/annotations/inheritance/joined/Asset.hbm.xml"
};
}
/**
* @see org.hibernate.test.annotations.TestCase#getAnnotatedClasses()
*/
protected Class[] getAnnotatedClasses() {
return new Class[]{
File.class,

View File

@ -1,20 +1,49 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.inheritance.mixed;
import java.util.List;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.exception.SQLGrammarException;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
/**
* @author Emmanuel Bernard
*/
public class SubclassTest extends TestCase {
public SubclassTest(String x) {
super( x );
}
public class SubclassTest extends BaseCoreFunctionalTestCase {
@Test
public void testDefault() throws Exception {
Session s;
Transaction tx;
@ -59,9 +88,7 @@ public class SubclassTest extends TestCase {
}
}
/**
* @see org.hibernate.test.annotations.TestCase#getAnnotatedClasses()
*/
@Override
protected Class[] getAnnotatedClasses() {
return new Class[]{
File.class,

View File

@ -1,19 +1,49 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.inheritance.union;
import java.util.List;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
/**
* @author Emmanuel Bernard
*/
public class SubclassTest extends TestCase {
public SubclassTest(String x) {
super( x );
}
public class SubclassTest extends BaseCoreFunctionalTestCase {
@Test
public void testDefault() throws Exception {
Session s;
Transaction tx;
@ -51,9 +81,7 @@ public class SubclassTest extends TestCase {
}
}
/**
* @see org.hibernate.test.annotations.TestCase#getAnnotatedClasses()
*/
@Override
protected Class[] getAnnotatedClasses() {
return new Class[]{
File.class,

View File

@ -1,19 +1,43 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.interfaces;
import org.hibernate.test.annotations.TestCase;
/**
* @author Emmanuel Bernard
*/
public class InterfacesTest extends TestCase {
public void testInterface() {
}
protected Class[] getAnnotatedClasses() {
return new Class[]{
ContactImpl.class,
UserImpl.class
};
}
}
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
/**
* @author Emmanuel Bernard
*/
public class InterfacesTest extends BaseCoreFunctionalTestCase {
@Test
public void testInterface() {
// test via SessionFactory building
}
@Override
protected Class[] getAnnotatedClasses() {
return new Class[] { ContactImpl.class, UserImpl.class };
}
}

View File

@ -1,23 +1,55 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.join;
import java.util.ArrayList;
import java.util.Date;
import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.criterion.Expression;
import org.hibernate.criterion.Restrictions;
import org.hibernate.mapping.Join;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
/**
* @author Emmanuel Bernard
*/
public class JoinTest extends TestCase {
public class JoinTest extends BaseCoreFunctionalTestCase {
@Test
public void testDefaultValue() throws Exception {
Join join = (Join) getCfg().getClassMapping( Life.class.getName() ).getJoinClosureIterator().next();
Join join = (Join) configuration().getClassMapping( Life.class.getName() ).getJoinClosureIterator().next();
assertEquals( "ExtendedLife", join.getTable().getName() );
org.hibernate.mapping.Column owner = new org.hibernate.mapping.Column();
owner.setName( "LIFE_ID" );
@ -40,8 +72,9 @@ public class JoinTest extends TestCase {
s.close();
}
@Test
public void testCompositePK() throws Exception {
Join join = (Join) getCfg().getClassMapping( Dog.class.getName() ).getJoinClosureIterator().next();
Join join = (Join) configuration().getClassMapping( Dog.class.getName() ).getJoinClosureIterator().next();
assertEquals( "DogThoroughbred", join.getTable().getName() );
org.hibernate.mapping.Column owner = new org.hibernate.mapping.Column();
owner.setName( "OWNER_NAME" );
@ -68,6 +101,7 @@ public class JoinTest extends TestCase {
s.close();
}
@Test
public void testExplicitValue() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -88,6 +122,7 @@ public class JoinTest extends TestCase {
s.close();
}
@Test
public void testManyToOne() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -105,7 +140,7 @@ public class JoinTest extends TestCase {
s = openSession();
tx = s.beginTransaction();
Criteria crit = s.createCriteria( Life.class );
crit.createCriteria( "owner" ).add( Expression.eq( "name", "kitty" ) );
crit.createCriteria( "owner" ).add( Restrictions.eq( "name", "kitty" ) );
life = (Life) crit.uniqueResult();
assertEquals( "Long long description", life.fullDescription );
s.delete( life.owner );
@ -114,6 +149,7 @@ public class JoinTest extends TestCase {
s.close();
}
@Test
public void testReferenceColumnWithBacktics() throws Exception {
Session s=openSession();
s.beginTransaction();
@ -127,6 +163,7 @@ public class JoinTest extends TestCase {
s.close();
}
@Test
public void testUniqueConstaintOnSecondaryTable() throws Exception {
Cat cat = new Cat();
cat.setStoryPart2( "My long story" );
@ -149,6 +186,7 @@ public class JoinTest extends TestCase {
}
}
@Test
public void testFetchModeOnSecondaryTable() throws Exception {
Cat cat = new Cat();
cat.setStoryPart2( "My long story" );
@ -166,6 +204,7 @@ public class JoinTest extends TestCase {
s.close();
}
@Test
public void testCustomSQL() throws Exception {
Cat cat = new Cat();
String storyPart2 = "My long story";
@ -184,6 +223,7 @@ public class JoinTest extends TestCase {
s.close();
}
@Test
public void testMappedSuperclassAndSecondaryTable() throws Exception {
Session s = openSession( );
s.getTransaction().begin();
@ -201,9 +241,7 @@ public class JoinTest extends TestCase {
s.close();
}
/**
* @see org.hibernate.test.annotations.TestCase#getAnnotatedClasses()
*/
@Override
protected Class[] getAnnotatedClasses() {
return new Class[]{
Life.class,

View File

@ -1,67 +1,92 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.loader;
import java.util.Iterator;
import java.util.Set;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.test.annotations.TestCase;
/**
* @author Emmanuel Bernard
*/
public class LoaderTest extends TestCase {
protected String[] getXmlFiles() {
return new String[] {
"org/hibernate/test/annotations/loader/Loader.hbm.xml"
};
}
public void testBasic() throws Exception {
Session s = openSession( );
Transaction tx = s.beginTransaction();
Team t = new Team();
Player p = new Player();
p.setName("me");
t.getPlayers().add(p);
p.setTeam(t);
try {
s.persist(p);
s.persist(t);
tx.commit();
s.close();
s= openSession( );
tx = s.beginTransaction();
Team t2 = (Team)s.load(Team.class,new Long(1));
Set<Player> players = t2.getPlayers();
Iterator<Player> iterator = players.iterator();
assertEquals("me", iterator.next().getName());
tx.commit();
}
catch (Exception e) {
e.printStackTrace();
if ( tx != null ) tx.rollback();
}
finally {
s.close();
}
}
/**
* @see org.hibernate.test.annotations.TestCase#getAnnotatedClasses()
*/
protected Class[] getAnnotatedClasses() {
return new Class[]{
Player.class,
Team.class
};
}
}
import java.util.Iterator;
import java.util.Set;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
/**
* @author Emmanuel Bernard
*/
public class LoaderTest extends BaseCoreFunctionalTestCase {
@Override
protected String[] getXmlFiles() {
return new String[] {
"org/hibernate/test/annotations/loader/Loader.hbm.xml"
};
}
@Override
protected Class[] getAnnotatedClasses() {
return new Class[]{
Player.class,
Team.class
};
}
@Test
public void testBasic() throws Exception {
Session s = openSession( );
Transaction tx = s.beginTransaction();
Team t = new Team();
Player p = new Player();
p.setName("me");
t.getPlayers().add(p);
p.setTeam(t);
try {
s.persist(p);
s.persist(t);
tx.commit();
s.close();
s= openSession( );
tx = s.beginTransaction();
Team t2 = (Team)s.load(Team.class,new Long(1));
Set<Player> players = t2.getPlayers();
Iterator<Player> iterator = players.iterator();
assertEquals("me", iterator.next().getName());
tx.commit();
}
catch (Exception e) {
e.printStackTrace();
if ( tx != null ) tx.rollback();
}
finally {
s.close();
}
}
}

View File

@ -22,18 +22,23 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.lob;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
/**
* @author Gail Badner
*/
public abstract class AbstractLobTest<B extends AbstractBook, C extends AbstractCompiledCode> extends TestCase {
public AbstractLobTest(String name) {
super( name );
}
public abstract class AbstractLobTest<B extends AbstractBook, C extends AbstractCompiledCode>
extends BaseCoreFunctionalTestCase {
protected abstract Class<B> getBookClass();
@ -61,6 +66,7 @@ public abstract class AbstractLobTest<B extends AbstractBook, C extends Abstract
protected abstract Integer getId(C compiledCode);
@Test
public void testSerializableToBlob() throws Exception {
B book = createBook();
Editor editor = new Editor();
@ -91,6 +97,7 @@ public abstract class AbstractLobTest<B extends AbstractBook, C extends Abstract
}
@Test
public void testClob() throws Exception {
Session s;
Transaction tx;
@ -116,6 +123,7 @@ public abstract class AbstractLobTest<B extends AbstractBook, C extends Abstract
s.close();
}
@Test
public void testBlob() throws Exception {
Session s;
Transaction tx;
@ -144,6 +152,7 @@ public abstract class AbstractLobTest<B extends AbstractBook, C extends Abstract
s.close();
}
@Test
public void testBinary() throws Exception {
Session s;
Transaction tx;

View File

@ -23,7 +23,6 @@
*/
package org.hibernate.test.annotations.lob;
import junit.framework.AssertionFailedError;
import org.hibernate.Session;
import org.hibernate.dialect.SQLServerDialect;
import org.hibernate.dialect.Sybase11Dialect;
@ -31,8 +30,12 @@ import org.hibernate.dialect.SybaseASE15Dialect;
import org.hibernate.dialect.SybaseDialect;
import org.hibernate.internal.util.collections.ArrayHelper;
import org.junit.Assert;
import org.junit.Test;
import junit.framework.AssertionFailedError;
import org.hibernate.testing.RequiresDialect;
import org.hibernate.test.annotations.TestCase;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
/**
* Tests eager materialization and mutation of data mapped by
@ -40,11 +43,11 @@ import org.hibernate.test.annotations.TestCase;
*
* @author Gail Badner
*/
@RequiresDialect( { SybaseASE15Dialect.class, SQLServerDialect.class,
SybaseDialect.class, Sybase11Dialect.class })
public class ImageTest extends TestCase {
@RequiresDialect( { SybaseASE15Dialect.class, SQLServerDialect.class, SybaseDialect.class, Sybase11Dialect.class })
public class ImageTest extends BaseCoreFunctionalTestCase {
private static final int ARRAY_SIZE = 10000;
@Test
public void testBoundedLongByteArrayAccess() {
byte[] original = buildRecursively(ARRAY_SIZE, true);
byte[] changed = buildRecursively(ARRAY_SIZE, false);
@ -59,9 +62,9 @@ public class ImageTest extends TestCase {
s = openSession();
s.beginTransaction();
entity = (ImageHolder) s.get(ImageHolder.class, entity.getId());
assertNull(entity.getLongByteArray());
assertNull(entity.getDog());
assertNull(entity.getPicByteArray());
Assert.assertNull( entity.getLongByteArray() );
Assert.assertNull( entity.getDog() );
Assert.assertNull( entity.getPicByteArray() );
entity.setLongByteArray(original);
Dog dog = new Dog();
dog.setName("rabbit");
@ -73,12 +76,12 @@ public class ImageTest extends TestCase {
s = openSession();
s.beginTransaction();
entity = (ImageHolder) s.get(ImageHolder.class, entity.getId());
assertEquals(ARRAY_SIZE, entity.getLongByteArray().length);
Assert.assertEquals( ARRAY_SIZE, entity.getLongByteArray().length );
assertEquals(original, entity.getLongByteArray());
assertEquals(ARRAY_SIZE, entity.getPicByteArray().length);
Assert.assertEquals( ARRAY_SIZE, entity.getPicByteArray().length );
assertEquals(original, unwrapNonPrimitive(entity.getPicByteArray()));
assertNotNull(entity.getDog());
assertEquals(dog.getName(), entity.getDog().getName());
Assert.assertNotNull( entity.getDog() );
Assert.assertEquals( dog.getName(), entity.getDog().getName() );
entity.setLongByteArray(changed);
entity.setPicByteArray(wrapPrimitive(changed));
dog.setName("papa");
@ -89,12 +92,12 @@ public class ImageTest extends TestCase {
s = openSession();
s.beginTransaction();
entity = (ImageHolder) s.get(ImageHolder.class, entity.getId());
assertEquals(ARRAY_SIZE, entity.getLongByteArray().length);
Assert.assertEquals( ARRAY_SIZE, entity.getLongByteArray().length );
assertEquals(changed, entity.getLongByteArray());
assertEquals(ARRAY_SIZE, entity.getPicByteArray().length);
Assert.assertEquals( ARRAY_SIZE, entity.getPicByteArray().length );
assertEquals(changed, unwrapNonPrimitive(entity.getPicByteArray()));
assertNotNull(entity.getDog());
assertEquals(dog.getName(), entity.getDog().getName());
Assert.assertNotNull( entity.getDog() );
Assert.assertEquals( dog.getName(), entity.getDog().getName() );
entity.setLongByteArray(null);
entity.setPicByteArray(null);
entity.setDog(null);
@ -104,9 +107,9 @@ public class ImageTest extends TestCase {
s = openSession();
s.beginTransaction();
entity = (ImageHolder) s.get(ImageHolder.class, entity.getId());
assertNull(entity.getLongByteArray());
assertNull(entity.getDog());
assertNull(entity.getPicByteArray());
Assert.assertNull( entity.getLongByteArray() );
Assert.assertNull( entity.getDog() );
Assert.assertNull( entity.getPicByteArray() );
s.delete(entity);
s.getTransaction().commit();
s.close();
@ -116,7 +119,7 @@ public class ImageTest extends TestCase {
int length = bytes.length;
Byte[] result = new Byte[length];
for (int index = 0; index < length; index++) {
result[index] = Byte.valueOf(bytes[index]);
result[index] = Byte.valueOf( bytes[index] );
}
return result;
}
@ -150,10 +153,6 @@ public class ImageTest extends TestCase {
}
}
public ImageTest(String name) {
super(name);
}
@Override
protected String[] getAnnotatedPackages() {
return new String[] { "org.hibernate.test.annotations.lob" };

View File

@ -32,27 +32,27 @@ import org.hibernate.testing.DialectChecks;
*/
@RequiresDialectFeature(DialectChecks.SupportsExpectedLobUsagePattern.class)
public class LobTest extends AbstractLobTest<Book, CompiledCode> {
public LobTest(String x) {
super( x );
}
@Override
protected Class<Book> getBookClass() {
return Book.class;
}
@Override
protected Integer getId(Book book) {
return book.getId();
}
@Override
protected Class<CompiledCode> getCompiledCodeClass() {
return CompiledCode.class;
}
@Override
protected Integer getId(CompiledCode compiledCode) {
return compiledCode.getId();
}
@Override
protected Class[] getAnnotatedClasses() {
return new Class[] {
Book.class,

View File

@ -24,37 +24,38 @@
package org.hibernate.test.annotations.lob;
import java.util.Arrays;
import org.hibernate.Session;
import org.hibernate.cfg.Configuration;
import org.hibernate.test.annotations.TestCase;
import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.RequiresDialectFeature;
import org.hibernate.Session;
import org.hibernate.type.MaterializedBlobType;
import org.hibernate.type.Type;
import org.junit.Test;
import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.RequiresDialectFeature;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
* @author Steve Ebersole
*/
@RequiresDialectFeature(DialectChecks.SupportsExpectedLobUsagePattern.class)
public class MaterializedBlobTest extends TestCase {
@Override
protected void configure(Configuration cfg) {
super.configure( cfg );
cfg.setProperty( Configuration.USE_NEW_ID_GENERATOR_MAPPINGS, "true" );
}
public class MaterializedBlobTest extends BaseCoreFunctionalTestCase {
@Override
protected Class<?>[] getAnnotatedClasses() {
return new Class<?>[] { MaterializedBlobEntity.class };
}
@Test
public void testTypeSelection() {
int index = sfi().getEntityPersister( MaterializedBlobEntity.class.getName() ).getEntityMetamodel().getPropertyIndex( "theBytes" );
Type type = sfi().getEntityPersister( MaterializedBlobEntity.class.getName() ).getEntityMetamodel().getProperties()[index].getType();
int index = sessionFactory().getEntityPersister( MaterializedBlobEntity.class.getName() ).getEntityMetamodel().getPropertyIndex( "theBytes" );
Type type = sessionFactory().getEntityPersister( MaterializedBlobEntity.class.getName() ).getEntityMetamodel().getProperties()[index].getType();
assertEquals( MaterializedBlobType.INSTANCE, type );
}
@Test
public void testSaving() {
byte[] testData = "test data".getBytes();

View File

@ -23,15 +23,21 @@
*/
package org.hibernate.test.annotations.lob;
import junit.framework.AssertionFailedError;
import org.hibernate.Session;
import org.hibernate.dialect.SQLServerDialect;
import org.hibernate.dialect.Sybase11Dialect;
import org.hibernate.dialect.SybaseASE15Dialect;
import org.hibernate.dialect.SybaseDialect;
import org.hibernate.internal.util.collections.ArrayHelper;
import org.junit.Assert;
import org.junit.Test;
import junit.framework.AssertionFailedError;
import org.hibernate.testing.RequiresDialect;
import org.hibernate.test.annotations.TestCase;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertNull;
/**
* Tests eager materialization and mutation of long strings.
@ -39,7 +45,7 @@ import org.hibernate.test.annotations.TestCase;
* @author Steve Ebersole
*/
@RequiresDialect({SybaseASE15Dialect.class,SQLServerDialect.class,SybaseDialect.class,Sybase11Dialect.class})
public class TextTest extends TestCase {
public class TextTest extends BaseCoreFunctionalTestCase {
@Override
protected Class<?>[] getAnnotatedClasses() {
@ -48,6 +54,7 @@ public class TextTest extends TestCase {
private static final int LONG_STRING_SIZE = 10000;
@Test
public void testBoundedLongStringAccess() {
String original = buildRecursively(LONG_STRING_SIZE, 'x');
String changed = buildRecursively(LONG_STRING_SIZE, 'y');
@ -76,14 +83,14 @@ public class TextTest extends TestCase {
s.beginTransaction();
entity = (LongStringHolder) s.get(LongStringHolder.class, entity
.getId());
assertEquals(LONG_STRING_SIZE, entity.getLongString().length());
assertEquals(original, entity.getLongString());
assertNotNull(entity.getName());
assertEquals(LONG_STRING_SIZE, entity.getName().length);
assertEquals(original.toCharArray(), entity.getName());
assertNotNull(entity.getWhatEver());
assertEquals(LONG_STRING_SIZE, entity.getWhatEver().length);
assertEquals(original.toCharArray(), unwrapNonPrimitive(entity.getWhatEver()));
Assert.assertEquals( LONG_STRING_SIZE, entity.getLongString().length() );
Assert.assertEquals( original, entity.getLongString() );
Assert.assertNotNull( entity.getName() );
Assert.assertEquals( LONG_STRING_SIZE, entity.getName().length );
assertEquals( original.toCharArray(), entity.getName() );
Assert.assertNotNull( entity.getWhatEver() );
Assert.assertEquals( LONG_STRING_SIZE, entity.getWhatEver().length );
assertEquals( original.toCharArray(), unwrapNonPrimitive( entity.getWhatEver() ) );
entity.setLongString(changed);
entity.setName(changed.toCharArray());
entity.setWhatEver(wrapPrimitive(changed.toCharArray()));
@ -94,14 +101,14 @@ public class TextTest extends TestCase {
s.beginTransaction();
entity = (LongStringHolder) s.get(LongStringHolder.class, entity
.getId());
assertEquals(LONG_STRING_SIZE, entity.getLongString().length());
assertEquals(changed, entity.getLongString());
assertNotNull(entity.getName());
assertEquals(LONG_STRING_SIZE, entity.getName().length);
assertEquals(changed.toCharArray(), entity.getName());
assertNotNull(entity.getWhatEver());
assertEquals(LONG_STRING_SIZE, entity.getWhatEver().length);
assertEquals(changed.toCharArray(), unwrapNonPrimitive(entity.getWhatEver()));
Assert.assertEquals( LONG_STRING_SIZE, entity.getLongString().length() );
Assert.assertEquals( changed, entity.getLongString() );
Assert.assertNotNull( entity.getName() );
Assert.assertEquals( LONG_STRING_SIZE, entity.getName().length );
assertEquals( changed.toCharArray(), entity.getName() );
Assert.assertNotNull( entity.getWhatEver() );
Assert.assertEquals( LONG_STRING_SIZE, entity.getWhatEver().length );
assertEquals( changed.toCharArray(), unwrapNonPrimitive( entity.getWhatEver() ) );
entity.setLongString(null);
entity.setName(null);
entity.setWhatEver(null);

View File

@ -26,35 +26,41 @@ package org.hibernate.test.annotations.lob;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.junit.Test;
import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.RequiresDialectFeature;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
/**
* @author Gail Badner
*/
@RequiresDialectFeature(DialectChecks.SupportsExpectedLobUsagePattern.class)
public class VersionedLobTest extends AbstractLobTest<VersionedBook, VersionedCompiledCode> {
public VersionedLobTest(String x) {
super( x );
}
@Override
protected Class<VersionedBook> getBookClass() {
return VersionedBook.class;
}
@Override
protected Integer getId(VersionedBook book) {
return book.getId();
}
@Override
protected Class<VersionedCompiledCode> getCompiledCodeClass() {
return VersionedCompiledCode.class;
}
@Override
protected Integer getId(VersionedCompiledCode compiledCode) {
return compiledCode.getId();
}
@Override
protected Class[] getAnnotatedClasses() {
return new Class[] {
VersionedBook.class,
@ -62,6 +68,7 @@ public class VersionedLobTest extends AbstractLobTest<VersionedBook, VersionedCo
};
}
@Test
public void testVersionUnchangedPrimitiveCharArray() throws Exception {
VersionedBook book = createBook();
Editor editor = new Editor();
@ -87,6 +94,7 @@ public class VersionedLobTest extends AbstractLobTest<VersionedBook, VersionedCo
}
@Test
public void testVersionUnchangedCharArray() throws Exception {
Session s;
Transaction tx;
@ -112,6 +120,7 @@ public class VersionedLobTest extends AbstractLobTest<VersionedBook, VersionedCo
s.close();
}
@Test
public void testVersionUnchangedString() throws Exception {
Session s;
Transaction tx;
@ -137,6 +146,7 @@ public class VersionedLobTest extends AbstractLobTest<VersionedBook, VersionedCo
s.close();
}
@Test
@FailureExpected( jiraKey = "HHH-5811")
public void testVersionUnchangedByteArray() throws Exception {
Session s;
@ -163,6 +173,7 @@ public class VersionedLobTest extends AbstractLobTest<VersionedBook, VersionedCo
s.close();
}
@Test
public void testVersionUnchangedPrimitiveByteArray() throws Exception {
Session s;
Transaction tx;

View File

@ -23,6 +23,7 @@
*
*/
package org.hibernate.test.annotations.manytomany;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
@ -33,11 +34,6 @@ import org.hibernate.cfg.Environment;
*/
@SuppressWarnings("unchecked")
public class ManyToManyMaxFetchDepth0Test extends ManyToManyTest {
public ManyToManyMaxFetchDepth0Test(String x) {
super( x );
}
@Override
protected void configure(Configuration cfg) {
cfg.setProperty( Environment.MAX_FETCH_DEPTH, "0" );

View File

@ -1,5 +1,26 @@
//$Id$
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.manytomany;
import java.util.ArrayList;
@ -9,12 +30,23 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.hibernate.Hibernate;
import org.hibernate.JDBCException;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.criterion.Restrictions;
import org.hibernate.test.annotations.TestCase;
import org.junit.Test;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
/**
* Many to many tests
@ -22,12 +54,8 @@ import org.hibernate.test.annotations.TestCase;
* @author Emmanuel Bernard
*/
@SuppressWarnings("unchecked")
public class ManyToManyTest extends TestCase {
public ManyToManyTest(String x) {
super( x );
}
public class ManyToManyTest extends BaseCoreFunctionalTestCase {
@Test
public void testDefault() throws Exception {
Session s;
Transaction tx;
@ -79,6 +107,7 @@ public class ManyToManyTest extends TestCase {
s.close();
}
@Test
public void testCanUseCriteriaQuery() throws Exception {
Session s;
Transaction tx;
@ -104,6 +133,8 @@ public class ManyToManyTest extends TestCase {
tx.commit();
s.close();
}
@Test
public void testDefaultCompositePk() throws Exception {
Session s;
Transaction tx;
@ -153,6 +184,7 @@ public class ManyToManyTest extends TestCase {
s.close();
}
@Test
public void testMappedBy() throws Exception {
Session s;
Transaction tx;
@ -195,6 +227,7 @@ public class ManyToManyTest extends TestCase {
s.close();
}
@Test
public void testBasic() throws Exception {
Session s;
Transaction tx;
@ -245,6 +278,7 @@ public class ManyToManyTest extends TestCase {
s.close();
}
@Test
public void testOrderByEmployee() throws Exception {
Session s;
Transaction tx;
@ -279,83 +313,9 @@ public class ManyToManyTest extends TestCase {
assertEquals( employee2.getName(), eeFromDb.getName() );
tx.rollback();
s.close();
}
/**
* ANN-625
*
* @throws Exception in case the test fails.
*
* This test only works against databases which allow a mixed usage of
* table names and table aliases. The generated SQL for this test is:
*
* select
* contractor0_.EMPLOYER_ID as EMPLOYER1_1_,
* contractor0_.CONTRACTOR_ID as CONTRACTOR2_1_,
* contractor1_.id as id2_0_,
* contractor1_.fld_name as fld3_2_0_,
* contractor1_.hourlyRate as hourlyRate2_0_
* from
* EMPLOYER_CONTRACTOR contractor0_
* left outer join
* Employee contractor1_
* on contractor0_.CONTRACTOR_ID=contractor1_.id
* where
* contractor0_.EMPLOYER_ID=?
* order by
* Employee.fld_name desc
*
*
*/
// HHH-3577
// public void testOrderByContractor() throws Exception {
//
// Session s;
// Transaction tx;
// s = openSession();
// tx = s.beginTransaction();
//
// // create some test entities
// Employer employer = new Employer();
// Contractor contractor1 = new Contractor();
// contractor1.setName( "Emmanuel" );
// contractor1.setHourlyRate(100.0f);
// Contractor contractor2 = new Contractor();
// contractor2.setName( "Hardy" );
// contractor2.setHourlyRate(99.99f);
// s.persist( contractor1 );
// s.persist( contractor2 );
//
// // add contractors to employer
// List setOfContractors = new ArrayList();
// setOfContractors.add( contractor1 );
// setOfContractors.add( contractor2 );
// employer.setContractors( setOfContractors );
//
// // add employer to contractors
// Collection employerListContractor1 = new ArrayList();
// employerListContractor1.add( employer );
// contractor1.setEmployers( employerListContractor1 );
//
// Collection employerListContractor2 = new ArrayList();
// employerListContractor2.add( employer );
// contractor2.setEmployers( employerListContractor2 );
//
// s.flush();
// s.clear();
//
// // assertions
// employer = (Employer) s.get( Employer.class, employer.getId() );
// assertNotNull( employer );
// assertNotNull( employer.getContractors() );
// assertEquals( 2, employer.getContractors().size() );
// Contractor firstContractorFromDb = (Contractor) employer.getContractors().iterator().next();
// assertEquals( contractor2.getName(), firstContractorFromDb.getName() );
// tx.rollback();
// s.close();
// }
@Test
public void testRemoveInBetween() throws Exception {
Session s;
Transaction tx;
@ -416,6 +376,7 @@ public class ManyToManyTest extends TestCase {
s.close();
}
@Test
public void testSelf() throws Exception {
Session s;
Transaction tx;
@ -446,6 +407,7 @@ public class ManyToManyTest extends TestCase {
s.close();
}
@Test
public void testCompositePk() throws Exception {
Session s;
Transaction tx;
@ -513,6 +475,7 @@ public class ManyToManyTest extends TestCase {
s.close();
}
@Test
public void testAssociationTableUniqueConstraints() throws Exception {
Session s = openSession();
Permission readAccess = new Permission();
@ -539,6 +502,7 @@ public class ManyToManyTest extends TestCase {
}
}
@Test
public void testAssociationTableAndOrderBy() throws Exception {
Session s = openSession();
s.enableFilter( "Groupfilter" );
@ -565,6 +529,7 @@ public class ManyToManyTest extends TestCase {
s.close();
}
@Test
public void testAssociationTableAndOrderByWithSet() throws Exception {
Session s = openSession();
s.enableFilter( "Groupfilter" );
@ -604,6 +569,7 @@ public class ManyToManyTest extends TestCase {
s.close();
}
@Test
public void testJoinedSubclassManyToMany() throws Exception {
Session s = openSession();
Zone a = new Zone();
@ -626,6 +592,7 @@ public class ManyToManyTest extends TestCase {
s.close();
}
@Test
public void testJoinedSubclassManyToManyWithNonPkReference() throws Exception {
Session s = openSession();
Zone a = new Zone();
@ -649,6 +616,7 @@ public class ManyToManyTest extends TestCase {
s.close();
}
@Test
public void testReferencedColumnNameToSuperclass() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -667,16 +635,17 @@ public class ManyToManyTest extends TestCase {
s.close();
}
// Test for HHH-4685
// Section 11.1.25
// The ManyToMany annotation may be used within an embeddable class contained within an entity class to specify a
// relationship to a collection of entities[101]. If the relationship is bidirectional and the entity containing
// the embeddable class is the owner of the relationship, the non-owning side must use the mappedBy element of the
// ManyToMany annotation to specify the relationship field or property of the embeddable class. The dot (".")
// notation syntax must be used in the mappedBy element to indicate the relationship attribute within the embedded
// attribute. The value of each identifier used with the dot notation is the name of the respective embedded field
// or property.
@Test
@TestForIssue( jiraKey = "HHH-4685" )
public void testManyToManyEmbeddableBiDirectionalDotNotationInMappedBy() throws Exception {
// Section 11.1.25
// The ManyToMany annotation may be used within an embeddable class contained within an entity class to specify a
// relationship to a collection of entities[101]. If the relationship is bidirectional and the entity containing
// the embeddable class is the owner of the relationship, the non-owning side must use the mappedBy element of the
// ManyToMany annotation to specify the relationship field or property of the embeddable class. The dot (".")
// notation syntax must be used in the mappedBy element to indicate the relationship attribute within the embedded
// attribute. The value of each identifier used with the dot notation is the name of the respective embedded field
// or property.
Session s;
s = openSession();
s.getTransaction().begin();
@ -705,15 +674,16 @@ public class ManyToManyTest extends TestCase {
s.close();
}
// Test for HHH-4685
// Section 11.1.26
// The ManyToOne annotation may be used within an embeddable class to specify a relationship from the embeddable
// class to an entity class. If the relationship is bidirectional, the non-owning OneToMany entity side must use the
// mappedBy element of the OneToMany annotation to specify the relationship field or property of the embeddable field
// or property on the owning side of the relationship. The dot (".") notation syntax must be used in the mappedBy
// element to indicate the relationship attribute within the embedded attribute. The value of each identifier used
// with the dot notation is the name of the respective embedded field or property.
@Test
@TestForIssue( jiraKey = "HHH-4685" )
public void testOneToManyEmbeddableBiDirectionalDotNotationInMappedBy() throws Exception {
// Section 11.1.26
// The ManyToOne annotation may be used within an embeddable class to specify a relationship from the embeddable
// class to an entity class. If the relationship is bidirectional, the non-owning OneToMany entity side must use the
// mappedBy element of the OneToMany annotation to specify the relationship field or property of the embeddable field
// or property on the owning side of the relationship. The dot (".") notation syntax must be used in the mappedBy
// element to indicate the relationship attribute within the embedded attribute. The value of each identifier used
// with the dot notation is the name of the respective embedded field or property.
Session s;
s = openSession();
s.getTransaction().begin();
@ -740,9 +710,6 @@ public class ManyToManyTest extends TestCase {
s.close();
}
/**
* @see org.hibernate.test.annotations.TestCase#getAnnotatedClasses()
*/
@Override
protected Class[] getAnnotatedClasses() {
return new Class[]{

View File

@ -1,61 +1,93 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.manytoone;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.test.annotations.TestCase;
/**
* @author Emmanuel Bernard
*/
public class ManyToOneJoinTest extends TestCase {
public void testManyToOneJoinTable() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
ForestType forest = new ForestType();
forest.setName( "Original forest" );
s.persist( forest );
TreeType tree = new TreeType();
tree.setForestType( forest );
tree.setAlternativeForestType( forest );
tree.setName( "just a tree");
s.persist( tree );
s.flush();
s.clear();
tree = (TreeType) s.get(TreeType.class, tree.getId() );
assertNotNull( tree.getForestType() );
assertNotNull( tree.getAlternativeForestType() );
s.clear();
forest = (ForestType) s.get( ForestType.class, forest.getId() );
assertEquals( 1, forest.getTrees().size() );
assertEquals( tree.getId(), forest.getTrees().iterator().next().getId() );
tx.rollback();
s.close();
}
public void testOneToOneJoinTable() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
ForestType forest = new ForestType();
forest.setName( "Original forest" );
s.persist( forest );
BiggestForest forestRepr = new BiggestForest();
forestRepr.setType( forest );
forest.setBiggestRepresentative( forestRepr );
s.persist( forestRepr );
s.flush();
s.clear();
forest = (ForestType) s.get( ForestType.class, forest.getId() );
assertNotNull( forest.getBiggestRepresentative() );
assertEquals( forest, forest.getBiggestRepresentative().getType() );
tx.rollback();
s.close();
}
protected Class[] getAnnotatedClasses() {
return new Class[] {
BiggestForest.class,
ForestType.class,
TreeType.class
};
}
}
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
/**
* @author Emmanuel Bernard
*/
public class ManyToOneJoinTest extends BaseCoreFunctionalTestCase {
@Test
public void testManyToOneJoinTable() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
ForestType forest = new ForestType();
forest.setName( "Original forest" );
s.persist( forest );
TreeType tree = new TreeType();
tree.setForestType( forest );
tree.setAlternativeForestType( forest );
tree.setName( "just a tree");
s.persist( tree );
s.flush();
s.clear();
tree = (TreeType) s.get(TreeType.class, tree.getId() );
assertNotNull( tree.getForestType() );
assertNotNull( tree.getAlternativeForestType() );
s.clear();
forest = (ForestType) s.get( ForestType.class, forest.getId() );
assertEquals( 1, forest.getTrees().size() );
assertEquals( tree.getId(), forest.getTrees().iterator().next().getId() );
tx.rollback();
s.close();
}
@Test
public void testOneToOneJoinTable() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
ForestType forest = new ForestType();
forest.setName( "Original forest" );
s.persist( forest );
BiggestForest forestRepr = new BiggestForest();
forestRepr.setType( forest );
forest.setBiggestRepresentative( forestRepr );
s.persist( forestRepr );
s.flush();
s.clear();
forest = (ForestType) s.get( ForestType.class, forest.getId() );
assertNotNull( forest.getBiggestRepresentative() );
assertEquals( forest, forest.getBiggestRepresentative().getType() );
tx.rollback();
s.close();
}
@Override
protected Class[] getAnnotatedClasses() {
return new Class[] {
BiggestForest.class,
ForestType.class,
TreeType.class
};
}
}

View File

@ -1,50 +0,0 @@
//$Id$
package org.hibernate.test.annotations.manytoone;
import org.hibernate.test.annotations.TestCase;
/**
* FIXME test for ANN-548
* @author Emmanuel Bernard
*/
public class ManyToOneOnNonPkTest extends TestCase {
public void testNonPkPartOfPk() throws Exception {
// Session s = openSession( );
// s.getTransaction().begin();
//
// LotzPK pk = new LotzPK();
// pk.setId( 1 );
// pk.setLocCode( "fr" );
// Lotz lot = new Lotz();
// lot.setLocation( "France" );
// lot.setName( "Chez Dede" );
// lot.setLotPK( pk );
// Carz car = new Carz();
// car.setId( 1 );
// car.setLot( lot );
// car.setMake( "Citroen" );
// car.setManufactured( new Date() );
// car.setModel( "C5" );
// s.persist( lot );
// s.persist( car );
//
// s.flush();
// s.clear();
// s.clear();
//
// car = (Carz) s.createQuery( "from Carz car left join fetch car.lot").uniqueResult();
// assertNotNull( car.getLot() );
//
// s.getTransaction().commit();
// s.close();
//
}
protected Class[] getAnnotatedClasses() {
return new Class[] {
//Carz.class,
//Lotz.class
};
}
}

View File

@ -1,29 +1,57 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.test.annotations.manytoone;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.hibernate.Hibernate;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.test.annotations.Company;
import org.hibernate.test.annotations.Customer;
import org.hibernate.test.annotations.Discount;
import org.hibernate.test.annotations.Flight;
import org.hibernate.test.annotations.Passport;
import org.hibernate.test.annotations.TestCase;
import org.hibernate.test.annotations.Ticket;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
/**
* @author Emmanuel Bernard
*/
public class ManyToOneTest extends TestCase {
public ManyToOneTest(String x) {
super( x );
}
public class ManyToOneTest extends BaseCoreFunctionalTestCase {
@Test
public void testEager() throws Exception {
Session s;
Transaction tx;
@ -46,9 +74,9 @@ public class ManyToOneTest extends TestCase {
assertNotNull( car );
assertNotNull( car.getBodyColor() );
assertEquals( "Yellow", car.getBodyColor().getName() );
}
@Test
public void testDefaultMetadata() throws Exception {
Session s;
Transaction tx;
@ -73,6 +101,7 @@ public class ManyToOneTest extends TestCase {
s.close();
}
@Test
public void testCreate() throws Exception {
Session s;
Transaction tx;
@ -99,6 +128,7 @@ public class ManyToOneTest extends TestCase {
s.close();
}
@Test
public void testCascade() throws Exception {
Session s;
Transaction tx;
@ -120,7 +150,7 @@ public class ManyToOneTest extends TestCase {
tx = s.beginTransaction();
discount = (Discount) s.get( Discount.class, discount.getId() );
assertNotNull( discount );
assertEquals( 20.12, discount.getDiscount() );
assertEquals( 20.12, discount.getDiscount(), 0.01 );
assertNotNull( discount.getOwner() );
customer = new Customer();
customer.setName( "Clooney" );
@ -148,6 +178,7 @@ public class ManyToOneTest extends TestCase {
s.close();
}
@Test
public void testFetch() throws Exception {
Session s;
Transaction tx;
@ -186,6 +217,7 @@ public class ManyToOneTest extends TestCase {
s.close();
}
@Test
public void testCompositeFK() throws Exception {
Session s;
Transaction tx;
@ -217,6 +249,7 @@ public class ManyToOneTest extends TestCase {
s.close();
}
@Test
public void testImplicitCompositeFk() throws Exception {
Session s;
Transaction tx;
@ -247,6 +280,7 @@ public class ManyToOneTest extends TestCase {
s.close();
}
@Test
public void testManyToOneNonPk() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -267,6 +301,7 @@ public class ManyToOneTest extends TestCase {
s.close();
}
@Test
public void testManyToOneNonPkSecondaryTable() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -287,6 +322,7 @@ public class ManyToOneTest extends TestCase {
s.close();
}
@Test
public void testTwoManyToOneNonPk() throws Exception {
//2 many to one non pk pointing to the same referencedColumnName should not fail
Session s = openSession();
@ -310,6 +346,7 @@ public class ManyToOneTest extends TestCase {
s.close();
}
@Test
public void testFormulaOnOtherSide() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -334,11 +371,10 @@ public class ManyToOneTest extends TestCase {
s.close();
}
/**
* @see org.hibernate.test.annotations.TestCase#getAnnotatedClasses()
*/
protected java.lang.Class[] getAnnotatedClasses() {
return new java.lang.Class[]{
@Override
protected Class[] getAnnotatedClasses() {
return new Class[]{
Deal.class,
org.hibernate.test.annotations.manytoone.Customer.class,
Car.class,

View File

@ -22,17 +22,22 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.manytoone.referencedcolumnname;
import java.math.BigDecimal;
import org.hibernate.Session;
import org.junit.Test;
import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.RequiresDialectFeature;
import org.hibernate.test.annotations.TestCase;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
/**
* @author Emmanuel Bernard
*/
public class ManyToOneReferencedColumnNameTest extends TestCase {
public class ManyToOneReferencedColumnNameTest extends BaseCoreFunctionalTestCase {
@Test
@RequiresDialectFeature(DialectChecks.SupportsIdentityColumns.class)
public void testReoverableExceptionInFkOrdering() throws Exception {
//SF should not blow up
@ -58,6 +63,7 @@ public class ManyToOneReferencedColumnNameTest extends TestCase {
s.close();
}
@Override
protected Class[] getAnnotatedClasses() {
return new Class[] {
Item.class,

Some files were not shown because too many files have changed in this diff Show More