HHH-7919 : Miscellaneous bugfixes

This commit is contained in:
Strong Liu 2013-06-09 05:17:49 +08:00
parent 9bb0b2a7f3
commit 1b9ca7df6c
3 changed files with 27 additions and 13 deletions

View File

@ -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
}
}

View File

@ -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() {

View File

@ -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