@@ -16,6 +16,10 @@
|
||||
|
||||
package org.springframework.batch.sample;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.core.Job;
|
||||
@@ -25,8 +29,6 @@ import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import static org.springframework.batch.test.AssertFile.assertFileEquals;
|
||||
|
||||
@SpringJUnitConfig(
|
||||
locations = { "/simple-job-launcher-context.xml", "/jobs/multilineOrderJob.xml", "/job-runner-context.xml" })
|
||||
class MultilineOrderJobFunctionalTests {
|
||||
@@ -42,7 +44,9 @@ class MultilineOrderJobFunctionalTests {
|
||||
void testJobLaunch(@Autowired Job job) throws Exception {
|
||||
this.jobLauncherTestUtils.setJob(job);
|
||||
this.jobLauncherTestUtils.launchJob();
|
||||
assertFileEquals(new ClassPathResource(EXPECTED), new FileSystemResource(ACTUAL));
|
||||
Path expectedFile = new ClassPathResource(EXPECTED).getFile().toPath();
|
||||
Path actualFile = new FileSystemResource(ACTUAL).getFile().toPath();
|
||||
Assertions.assertLinesMatch(Files.lines(expectedFile), Files.lines(actualFile));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,11 @@
|
||||
|
||||
package org.springframework.batch.sample;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
@@ -25,7 +30,6 @@ import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.item.Chunk;
|
||||
import org.springframework.batch.item.file.FlatFileItemWriter;
|
||||
import org.springframework.batch.sample.domain.trade.CustomerCredit;
|
||||
import org.springframework.batch.test.AssertFile;
|
||||
import org.springframework.batch.test.JobLauncherTestUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.io.Resource;
|
||||
@@ -56,11 +60,13 @@ class RestartFileSampleFunctionalTests {
|
||||
|
||||
JobExecution je1 = jobLauncherTestUtils.launchJob(jobParameters);
|
||||
assertEquals(BatchStatus.FAILED, je1.getStatus());
|
||||
AssertFile.assertLineCount(10, outputResource);
|
||||
Path outputResourceFile = outputResource.getFile().toPath();
|
||||
Assertions.assertEquals(10, Files.lines(outputResourceFile).count());
|
||||
|
||||
JobExecution je2 = jobLauncherTestUtils.launchJob(jobParameters);
|
||||
assertEquals(BatchStatus.COMPLETED, je2.getStatus());
|
||||
AssertFile.assertLineCount(20, outputResource);
|
||||
outputResourceFile = outputResource.getFile().toPath();
|
||||
Assertions.assertEquals(20, Files.lines(outputResourceFile).count());
|
||||
}
|
||||
|
||||
static class CustomerCreditFlatFileItemWriter extends FlatFileItemWriter<CustomerCredit> {
|
||||
|
||||
@@ -16,10 +16,13 @@
|
||||
|
||||
package org.springframework.batch.sample.iosample;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.core.Job;
|
||||
import org.springframework.batch.test.AssertFile;
|
||||
import org.springframework.batch.test.JobLauncherTestUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
@@ -54,7 +57,9 @@ class MultiLineFunctionalTests {
|
||||
this.jobLauncherTestUtils.launchJob();
|
||||
|
||||
// then
|
||||
AssertFile.assertFileEquals(new FileSystemResource(INPUT_FILE), new FileSystemResource(OUTPUT_FILE));
|
||||
Path inputFile = new FileSystemResource(INPUT_FILE).getFile().toPath();
|
||||
Path outputFile = new FileSystemResource(OUTPUT_FILE).getFile().toPath();
|
||||
Assertions.assertLinesMatch(Files.lines(inputFile), Files.lines(outputFile));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,10 +16,13 @@
|
||||
|
||||
package org.springframework.batch.sample.iosample;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.core.Job;
|
||||
import org.springframework.batch.test.AssertFile;
|
||||
import org.springframework.batch.test.JobLauncherTestUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
@@ -54,7 +57,9 @@ class MultiRecordTypeFunctionalTests {
|
||||
jobLauncherTestUtils.launchJob();
|
||||
|
||||
// then
|
||||
AssertFile.assertFileEquals(new FileSystemResource(INPUT_FILE), new FileSystemResource(OUTPUT_FILE));
|
||||
Path inputFile = new FileSystemResource(INPUT_FILE).getFile().toPath();
|
||||
Path outputFile = new FileSystemResource(OUTPUT_FILE).getFile().toPath();
|
||||
Assertions.assertLinesMatch(Files.lines(inputFile), Files.lines(outputFile));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user