Skip to content

Commit b8af6be

Browse files
committed
fix multiple sql files test
1 parent fd47fa8 commit b8af6be

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/boot/test/UserRepositoryIntegrationTest.java renamed to persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/boot/test/UserRepositoryMultipleSqlFilesIntTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import org.junit.runner.RunWith;
55
import org.springframework.beans.factory.annotation.Autowired;
66
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
7+
import org.springframework.test.context.ActiveProfiles;
78
import org.springframework.test.context.junit4.SpringRunner;
89

910
import com.baeldung.boot.domain.User;
@@ -18,15 +19,16 @@
1819
*/
1920
@RunWith(SpringRunner.class)
2021
@DataJpaTest
21-
public class UserRepositoryIntegrationTest {
22+
@ActiveProfiles("multiplesqlfiles")
23+
public class UserRepositoryMultipleSqlFilesIntTest {
2224

2325
@Autowired private UserRepository userRepository;
2426

2527
@Test
2628
public void givenTwoImportFilesWhenFindAllShouldReturnSixUsers() {
2729
Collection<User> users = userRepository.findAll();
2830

29-
assertThat(users.size()).isEqualTo(3);
31+
assertThat(users.size()).isEqualTo(6);
3032
}
3133

3234
}

persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/springbootdatasourceconfig/application/tests/UserRepositoryIntegrationTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public void whenCalledSave_thenCorrectNumberOfUsers() {
2525
userRepository.save(new User("Bob", "bob@domain.com"));
2626
List<User> users = (List<User>) userRepository.findAll();
2727

28+
// 2 additional users are saved in the CommandLineRunner bean
2829
assertThat(users.size()).isEqualTo(3);
2930
}
3031
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
spring.jpa.properties.hibernate.hbm2ddl.import_files=import_active_users.sql,import_inactive_users.sql

0 commit comments

Comments
 (0)