From 1b9ca7df6ce444266716756ce377a5ab7f9186a8 Mon Sep 17 00:00:00 2001 From: Strong Liu Date: Sun, 9 Jun 2013 05:17:49 +0800 Subject: [PATCH] HHH-7919 : Miscellaneous bugfixes --- ...atedFormWithBeanValidationNotNullTest.java | 17 ++++++++------- .../instrument/cases/AbstractExecutable.java | 21 ++++++++++++++----- .../testing/junit4/BaseUnitTestCase.java | 2 +- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/hibernate-core/src/test/java/org/hibernate/test/formulajoin/AnnotatedFormWithBeanValidationNotNullTest.java b/hibernate-core/src/test/java/org/hibernate/test/formulajoin/AnnotatedFormWithBeanValidationNotNullTest.java index 2bb218be18..a22345083b 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/formulajoin/AnnotatedFormWithBeanValidationNotNullTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/formulajoin/AnnotatedFormWithBeanValidationNotNullTest.java @@ -23,22 +23,25 @@ */ package org.hibernate.test.formulajoin; -import org.hibernate.cfg.Configuration; import org.junit.Test; import org.hibernate.testing.TestForIssue; -import org.hibernate.testing.junit4.BaseUnitTestCase; +import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; /** * @author Steve Ebersole */ -public class AnnotatedFormWithBeanValidationNotNullTest extends BaseUnitTestCase { +public class AnnotatedFormWithBeanValidationNotNullTest extends BaseCoreFunctionalTestCase { + + @Override + protected Class[] getAnnotatedClasses() { + return new Class[] { AnnotatedMaster.class, AnnotatedDetail.class }; + } + @Test - @TestForIssue( jiraKey = "HHH-8167" ) + @TestForIssue(jiraKey = "HHH-8167") public void testAnnotatedFormWithBeanValidationNotNull() { - Configuration cfg = new Configuration(); - cfg.addAnnotatedClass( AnnotatedMaster.class ).addAnnotatedClass( AnnotatedDetail.class ); - cfg.buildSessionFactory(); + //doing noting, we here only testing the mapping binding } } diff --git a/hibernate-core/src/test/java/org/hibernate/test/instrument/cases/AbstractExecutable.java b/hibernate-core/src/test/java/org/hibernate/test/instrument/cases/AbstractExecutable.java index 4bb9df9a91..6d228212d2 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/instrument/cases/AbstractExecutable.java +++ b/hibernate-core/src/test/java/org/hibernate/test/instrument/cases/AbstractExecutable.java @@ -3,8 +3,10 @@ package org.hibernate.test.instrument.cases; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; +import org.hibernate.metamodel.MetadataSources; import org.hibernate.service.ServiceRegistry; import org.hibernate.testing.ServiceRegistryBuilder; +import org.hibernate.testing.junit4.BaseUnitTestCase; /** * @author Steve Ebersole @@ -16,12 +18,21 @@ public abstract class AbstractExecutable implements Executable { @Override public final void prepare() { Configuration cfg = new Configuration().setProperty( Environment.HBM2DDL_AUTO, "create-drop" ); - String[] resources = getResources(); - for ( String resource : resources ) { - cfg.addResource( resource ); - } serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( cfg.getProperties() ); - factory = cfg.buildSessionFactory( serviceRegistry ); + String[] resources = getResources(); + if( BaseUnitTestCase.isMetadataUsed()){ + MetadataSources metadataSources = new MetadataSources( serviceRegistry ); + for(String resource : resources){ + metadataSources.addResource( resource ); + } + factory = metadataSources.buildMetadata().buildSessionFactory(); + }else{ + for ( String resource : resources ) { + cfg.addResource( resource ); + } + factory = cfg.buildSessionFactory( serviceRegistry ); + } + } @Override public final void complete() { diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseUnitTestCase.java b/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseUnitTestCase.java index 7b348e8f52..799a7b79a7 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseUnitTestCase.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseUnitTestCase.java @@ -52,7 +52,7 @@ public abstract class BaseUnitTestCase { */ protected static final String OUTPUT_PREFIX = SqlStatementLogger.OUTPUT_PREFIX; protected static boolean isMetadataUsed = Boolean.valueOf( System.getProperty( USE_NEW_METADATA_MAPPINGS, "true" ) ); - protected static boolean isMetadataUsed() { + public static boolean isMetadataUsed() { return isMetadataUsed; } @Rule