I am trying to update my project from Spring-Boot 1.3.8 to 1.4.2. Currently I am facing a test case issue and I don't know how to solve to get it work under Spring-Boot 1.4.2. In 1.3.8 everything works fine. I have a multimodule project, my domain classes (Entity classes) are in a different module.
I have a BatchJobTest as follows:
@ContextConfiguration(classes = { ApplicationImportBackend.class, PersistenceJPAConfig.class })
@RunWith(SpringJUnit4ClassRunner.class)
@ActiveProfiles({ "test" })
public class BatchJobTest {
@Autowired private JobLauncher jobLauncher;
@Autowired private Job importDataJob;
@Autowired private Job deleteAllDataJob;
@Test
public void testLaunchJob() throws Exception {
JobExecution run;
final JobParameters jobParameters = new JobParametersBuilder().addString("run-id", "single").toJobParameters();
run = jobLauncher.run(importDataJob, jobParameters);
assertTrue("Job not completed: " + run.getExitStatus(), run.getExitStatus().equals(ExitStatus.COMPLETED));
assertThat(apprenticeRepository.count(), is(5));
// MORE ASSERTS ...
run = jobLauncher.run(deleteAllDataJob, jobParameters);
assertTrue("Job not completed: " + run.getExitStatus(), run.getExitStatus().equals(ExitStatus.COMPLETED));
assertThat(apprenticeRepository.count(), is(0));
// MORE ASSERTS ...
}
}
When I run the test, it adds my BATCH Tables into the HSQSLDB database:
Executing SQL script from class path resource [org/springframework/batch/core/schema-hsqldb.sql]
Executed SQL script from class path resource [org/springframework/batch/core/schema-hsqldb.sql] in 4 ms.
But it can`t find my entities tables more, because they are not generated.
I found something like @DataJpaTest
but then it wont call the BATCH-SQL files more.
What I want is, that this test run the Batch-SQLs for generating the batch tables and create the tables for my domain where the domain classes are in another module. I would like to avoid to have somehow a package string to my domain classes, because I have a String already when configuring the LocalContainerEntityManagerFactoryBean#packageToScan.
Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire