diff --git a/hibernate-core/src/test/java/org/hibernate/cfg/beanvalidation/ApplySchemaConstraintTest.java b/hibernate-core/src/test/java/org/hibernate/cfg/beanvalidation/ApplySchemaConstraintTest.java index 1b0418762f..4580a04fd6 100644 --- a/hibernate-core/src/test/java/org/hibernate/cfg/beanvalidation/ApplySchemaConstraintTest.java +++ b/hibernate-core/src/test/java/org/hibernate/cfg/beanvalidation/ApplySchemaConstraintTest.java @@ -23,6 +23,8 @@ */ package org.hibernate.cfg.beanvalidation; +import static junit.framework.Assert.assertEquals; + import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; @@ -33,11 +35,6 @@ import javax.validation.constraints.Max; import javax.validation.constraints.Min; import javax.validation.constraints.NotNull; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - import org.hibernate.SessionFactory; import org.hibernate.boot.registry.BootstrapServiceRegistry; import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder; @@ -54,21 +51,22 @@ import org.hibernate.metamodel.spi.relational.Size; import org.hibernate.metamodel.spi.relational.Value; import org.hibernate.service.ServiceRegistry; import org.hibernate.validator.constraints.Length; - -import static junit.framework.Assert.assertEquals; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; /** * @author Hardy Ferentschik */ public class ApplySchemaConstraintTest { - private StandardServiceRegistryImpl serviceRegistry; + private static StandardServiceRegistryImpl serviceRegistry; @BeforeClass - public void setUp() { + public static void setUp() { serviceRegistry = createServiceRegistry(); } @AfterClass - public void tearDown(){ + public static void tearDown(){ serviceRegistry.destroy(); serviceRegistry = null; } @@ -172,7 +170,7 @@ public class ApplySchemaConstraintTest { return ( org.hibernate.metamodel.spi.relational.Column ) value; } - private StandardServiceRegistryImpl createServiceRegistry() { + private static StandardServiceRegistryImpl createServiceRegistry() { final BootstrapServiceRegistryBuilder builder = new BootstrapServiceRegistryBuilder(); final BootstrapServiceRegistry bootstrapServiceRegistry = builder.build(); StandardServiceRegistryBuilder registryBuilder = new StandardServiceRegistryBuilder( bootstrapServiceRegistry ); diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseCoreFunctionalTestCase.java b/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseCoreFunctionalTestCase.java index bd27297288..f329c172e4 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseCoreFunctionalTestCase.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseCoreFunctionalTestCase.java @@ -334,6 +334,7 @@ public abstract class BaseCoreFunctionalTestCase extends BaseFunctionalTestCase sessionFactory.close(); sessionFactory = null; configuration = null; + metadata = null; if(serviceRegistry == null){ return; }