spring-test-dbunit

Spring Test DBUnit and table schema name

痞子三分冷 提交于 2020-01-02 05:30:28
问题 Is it possible to set the table schema name when using @DatabaseSetup annotation from Spring Test DBUnit? Currently I'm using it like this: @DatabaseSetup("user-data.xml") public class UserMapperTest { } user-data.xml: (I also tried to set the element name to user.system_user without any luck) <dataset> <system_user ... /> </dataset> And here I'm creating my table with schema called user: create table "user".system_user (...); And this is the exception that I get when running test: org.h2

Configure specific in memory database for testing purpose in Spring

旧巷老猫 提交于 2019-12-17 22:30:10
问题 How do I configure my Spring Boot application so that when I run unit tests it will use in-memory database such as H2/HSQL but when I run Spring Boot application it will use production database [Postgre/MySQL] ? 回答1: Spring profiles can be used for this. This would be a specific way: Have environment specific properties files: application.properties : spring.profiles.active: dev application-dev.properties spring.jpa.database: MYSQL spring.jpa.hibernate.ddl-auto: update spring.datasource.url:

Spring Test DBunit Warning

元气小坏坏 提交于 2019-12-12 08:22:59
问题 I am using spring-test-dbunit and I get a warning in my Unit tests with this message: Code: @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "/context.xml"}) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, DirtiesContextTestExecutionListener.class, TransactionalTestExecutionListener.class, DbUnitTestExecutionListener.class }) public class TestDB { @Autowired private ICourseService courseService; @Test @DatabaseSetup("sampleData.xml") public

What are TestExecutionListeners, and what do they do?

青春壹個敷衍的年華 提交于 2019-12-04 10:00:48
问题 As far as I understand, TestExecutionListeners act like @BeforeClass methods in JUnit. What I don't understand is why I need to use DependencyInjectionTestExecutionListener , TransactionalTestExecutionListener and DirtiesContextTestExecutionListener to use DbUnitTestExecutionListener . Normally without DbUnit, I can create and populate the database. Why suddenly do I need to use these listeners to do some CRUD for my database? 回答1: TestExecutionListeners provide various types of functionality

Spring Test DBunit Warning

前提是你 提交于 2019-12-04 00:30:32
I am using spring-test-dbunit and I get a warning in my Unit tests with this message: Code: @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "/context.xml"}) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, DirtiesContextTestExecutionListener.class, TransactionalTestExecutionListener.class, DbUnitTestExecutionListener.class }) public class TestDB { @Autowired private ICourseService courseService; @Test @DatabaseSetup("sampleData.xml") public void testFind() throws Exception { List<Course> courseList = this.courseService.getAllCourses();

What are TestExecutionListeners, and what do they do?

不打扰是莪最后的温柔 提交于 2019-12-03 04:45:34
As far as I understand, TestExecutionListeners act like @BeforeClass methods in JUnit. What I don't understand is why I need to use DependencyInjectionTestExecutionListener , TransactionalTestExecutionListener and DirtiesContextTestExecutionListener to use DbUnitTestExecutionListener . Normally without DbUnit, I can create and populate the database. Why suddenly do I need to use these listeners to do some CRUD for my database? TestExecutionListeners provide various types of functionality to tests running in the Spring TestContext Framework. If you are interested in what a particular listener

Configure specific in memory database for testing purpose in Spring

感情迁移 提交于 2019-11-28 16:21:30
How do I configure my Spring Boot application so that when I run unit tests it will use in-memory database such as H2/HSQL but when I run Spring Boot application it will use production database [Postgre/MySQL] ? Spring profiles can be used for this. This would be a specific way: Have environment specific properties files: application.properties : spring.profiles.active: dev application-dev.properties spring.jpa.database: MYSQL spring.jpa.hibernate.ddl-auto: update spring.datasource.url: jdbc:mysql://localhost:3306/dbname spring.datasource.username: username spring.datasource.password: password