rename test class.
This commit is contained in:
parent
6f8d130786
commit
5996de6af1
|
@ -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<Movie> movies = session.createQuery("FROM Movie").list();
|
||||
assertNotNull(movies);
|
||||
assertEquals(movies.size(), 1L);
|
||||
sessionFactory.close();
|
||||
}
|
||||
|
||||
@After
|
||||
public void clean() throws IOException {
|
||||
session.close();
|
||||
sessionFactory.close();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue