From 5996de6af1a681d8c9a6c9c930a57b498daab92b Mon Sep 17 00:00:00 2001 From: "EZZEDDINE.ELHAZATI" Date: Wed, 19 Dec 2018 16:04:46 +0100 Subject: [PATCH] rename test class. --- ....java => BootstrapAPIIntegrationTest.java} | 30 +++---------------- 1 file changed, 4 insertions(+), 26 deletions(-) rename persistence-modules/hibernate5/src/test/java/com/baeldung/hibernate/bootstrap/{Hibernate5BootstrapAPITest.java => BootstrapAPIIntegrationTest.java} (62%) diff --git a/persistence-modules/hibernate5/src/test/java/com/baeldung/hibernate/bootstrap/Hibernate5BootstrapAPITest.java b/persistence-modules/hibernate5/src/test/java/com/baeldung/hibernate/bootstrap/BootstrapAPIIntegrationTest.java similarity index 62% rename from persistence-modules/hibernate5/src/test/java/com/baeldung/hibernate/bootstrap/Hibernate5BootstrapAPITest.java rename to persistence-modules/hibernate5/src/test/java/com/baeldung/hibernate/bootstrap/BootstrapAPIIntegrationTest.java index 39111f6256..19988b45be 100644 --- a/persistence-modules/hibernate5/src/test/java/com/baeldung/hibernate/bootstrap/Hibernate5BootstrapAPITest.java +++ b/persistence-modules/hibernate5/src/test/java/com/baeldung/hibernate/bootstrap/BootstrapAPIIntegrationTest.java @@ -1,7 +1,6 @@ package com.baeldung.hibernate.bootstrap; import com.baeldung.hibernate.pojo.Movie; -import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.boot.Metadata; import org.hibernate.boot.MetadataSources; @@ -10,22 +9,18 @@ import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.service.ServiceRegistry; import org.junit.After; -import org.junit.Before; import org.junit.Test; import java.io.IOException; -import java.util.List; -import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -public class Hibernate5BootstrapAPITest { +public class BootstrapAPIIntegrationTest { SessionFactory sessionFactory = null; - Session session = null; - @Before - public void setUp() throws IOException { + @Test + public void whenServiceRegistryAndMetadata_thenSessionFactory() throws IOException { BootstrapServiceRegistry bootstrapRegistry = new BootstrapServiceRegistryBuilder() .build(); @@ -41,29 +36,12 @@ public class Hibernate5BootstrapAPITest { Metadata metadata = metadataSources.getMetadataBuilder().build(); sessionFactory = metadata.buildSessionFactory(); - } - - @Test - public void testBuildSessionFactory() { assertNotNull(sessionFactory); - session = sessionFactory.openSession(); - assertNotNull(session); - - //Persist Movie - session.getTransaction().begin(); - Movie movie = new Movie(); - movie.setId(100L); - session.persist(movie); - session.getTransaction().commit(); - - List movies = session.createQuery("FROM Movie").list(); - assertNotNull(movies); - assertEquals(movies.size(), 1L); + sessionFactory.close(); } @After public void clean() throws IOException { - session.close(); sessionFactory.close(); } }