Another mem-leak fix
This commit is contained in:
parent
9a4a760280
commit
56a907385e
|
@ -23,6 +23,8 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.cfg.beanvalidation;
|
package org.hibernate.cfg.beanvalidation;
|
||||||
|
|
||||||
|
import static junit.framework.Assert.assertEquals;
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
|
@ -33,11 +35,6 @@ import javax.validation.constraints.Max;
|
||||||
import javax.validation.constraints.Min;
|
import javax.validation.constraints.Min;
|
||||||
import javax.validation.constraints.NotNull;
|
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.SessionFactory;
|
||||||
import org.hibernate.boot.registry.BootstrapServiceRegistry;
|
import org.hibernate.boot.registry.BootstrapServiceRegistry;
|
||||||
import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
|
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.metamodel.spi.relational.Value;
|
||||||
import org.hibernate.service.ServiceRegistry;
|
import org.hibernate.service.ServiceRegistry;
|
||||||
import org.hibernate.validator.constraints.Length;
|
import org.hibernate.validator.constraints.Length;
|
||||||
|
import org.junit.AfterClass;
|
||||||
import static junit.framework.Assert.assertEquals;
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Hardy Ferentschik
|
* @author Hardy Ferentschik
|
||||||
*/
|
*/
|
||||||
public class ApplySchemaConstraintTest {
|
public class ApplySchemaConstraintTest {
|
||||||
private StandardServiceRegistryImpl serviceRegistry;
|
private static StandardServiceRegistryImpl serviceRegistry;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public void setUp() {
|
public static void setUp() {
|
||||||
serviceRegistry = createServiceRegistry();
|
serviceRegistry = createServiceRegistry();
|
||||||
}
|
}
|
||||||
@AfterClass
|
@AfterClass
|
||||||
public void tearDown(){
|
public static void tearDown(){
|
||||||
serviceRegistry.destroy();
|
serviceRegistry.destroy();
|
||||||
serviceRegistry = null;
|
serviceRegistry = null;
|
||||||
}
|
}
|
||||||
|
@ -172,7 +170,7 @@ public class ApplySchemaConstraintTest {
|
||||||
return ( org.hibernate.metamodel.spi.relational.Column ) value;
|
return ( org.hibernate.metamodel.spi.relational.Column ) value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private StandardServiceRegistryImpl createServiceRegistry() {
|
private static StandardServiceRegistryImpl createServiceRegistry() {
|
||||||
final BootstrapServiceRegistryBuilder builder = new BootstrapServiceRegistryBuilder();
|
final BootstrapServiceRegistryBuilder builder = new BootstrapServiceRegistryBuilder();
|
||||||
final BootstrapServiceRegistry bootstrapServiceRegistry = builder.build();
|
final BootstrapServiceRegistry bootstrapServiceRegistry = builder.build();
|
||||||
StandardServiceRegistryBuilder registryBuilder = new StandardServiceRegistryBuilder( bootstrapServiceRegistry );
|
StandardServiceRegistryBuilder registryBuilder = new StandardServiceRegistryBuilder( bootstrapServiceRegistry );
|
||||||
|
|
|
@ -334,6 +334,7 @@ public abstract class BaseCoreFunctionalTestCase extends BaseFunctionalTestCase
|
||||||
sessionFactory.close();
|
sessionFactory.close();
|
||||||
sessionFactory = null;
|
sessionFactory = null;
|
||||||
configuration = null;
|
configuration = null;
|
||||||
|
metadata = null;
|
||||||
if(serviceRegistry == null){
|
if(serviceRegistry == null){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue