BAEL-2709: Implementing example for Spring Boot Hibernate. (#6478)

This commit is contained in:
dionisPrifti
2019-03-11 13:43:15 +01:00
committed by Eugen
parent 3c6e9001c6
commit 6cd8c51b4d
9 changed files with 140 additions and 1 deletions
@@ -0,0 +1,27 @@
package com.baeldung.springboothibernate.application.tests;
import com.baeldung.springboothibernate.application.models.Book;
import com.baeldung.springboothibernate.application.services.BookService;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.List;
@RunWith(SpringRunner.class)
@SpringBootTest
public class BookServiceUnitTest {
@Autowired
private BookService bookService;
@Test
public void test() {
List<Book> books = bookService.list();
Assert.assertEquals(books.size(), 3);
}
}
@@ -12,5 +12,5 @@ hibernate.cache.use_second_level_cache=true
hibernate.cache.use_query_cache=true
hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.EhCacheRegionFactory
spring.jpa.properties.hibernate.hbm2ddl.import_files=migrated_users.sql
spring.jpa.properties.hibernate.hbm2ddl.import_files=migrated_users.sql, import_books.sql
spring.datasource.data=import_*_users.sql
@@ -0,0 +1,3 @@
insert into book values(1, 'The Tartar Steppe');
insert into book values(2, 'Poem Strip');
insert into book values(3, 'Restless Nights: Selected Stories of Dino Buzzati');