Remove the JUnit dependency in AssertFile

The side effect is a breaking change in that it will now
throw IllegalStateException instead of the Compare and
AssertExceptions provided by JUnit.

Resolves #4111
This commit is contained in:
Glenn Renfro
2022-05-10 13:36:45 -04:00
committed by Mahmoud Ben Hassine
parent c425137eec
commit 8ca9802da4
82 changed files with 690 additions and 533 deletions

View File

@@ -158,22 +158,11 @@
<artifactId>spring-batch-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>

View File

@@ -19,11 +19,13 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.explore.JobExplorer;
import org.springframework.batch.test.JobLauncherTestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
/**
* <p>
@@ -39,7 +41,8 @@ import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
* </p>
*/
@SpringJUnitConfig(
@ExtendWith(SpringExtension.class)
@ContextConfiguration(
locations = { "/simple-job-launcher-context.xml", "/jobs/amqp-example-job.xml", "/job-runner-context.xml" })
class AMQPJobFunctionalTests {

View File

@@ -17,13 +17,15 @@
package org.springframework.batch.sample;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.core.Job;
import org.springframework.batch.test.JobLauncherTestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
@SpringJUnitConfig(locations = { "/simple-job-launcher-context.xml", "/jobs/beanWrapperMapperSampleJob.xml",
@ExtendWith(SpringExtension.class)
@ContextConfiguration(locations = { "/simple-job-launcher-context.xml", "/jobs/beanWrapperMapperSampleJob.xml",
"/job-runner-context.xml" })
class BeanWrapperMapperSampleJobFunctionalTests {

View File

@@ -15,6 +15,20 @@
*/
package org.springframework.batch.sample;
import org.apache.commons.io.IOUtils;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.core.Job;
import org.springframework.batch.sample.domain.trade.Trade;
import org.springframework.batch.test.JobLauncherTestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowCallbackHandler;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.jdbc.JdbcTestUtils;
import javax.sql.DataSource;
import java.io.FileInputStream;
import java.io.IOException;
import java.math.BigDecimal;
@@ -22,23 +36,11 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import javax.sql.DataSource;
import org.apache.commons.io.IOUtils;
import org.junit.jupiter.api.Test;
import org.springframework.batch.core.Job;
import org.springframework.batch.sample.domain.trade.Trade;
import org.springframework.batch.test.JobLauncherTestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowCallbackHandler;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.jdbc.JdbcTestUtils;
import static org.junit.jupiter.api.Assertions.assertEquals;
@SpringJUnitConfig(locations = { "/simple-job-launcher-context.xml", "/jobs/compositeItemWriterSampleJob.xml",
@ExtendWith(SpringExtension.class)
@ContextConfiguration(locations = { "/simple-job-launcher-context.xml", "/jobs/compositeItemWriterSampleJob.xml",
"/job-runner-context.xml" })
class CompositeItemWriterSampleFunctionalTests {

View File

@@ -16,8 +16,21 @@
package org.springframework.batch.sample;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.test.JobLauncherTestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowCallbackHandler;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.jdbc.JdbcTestUtils;
import javax.sql.DataSource;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Arrays;
@@ -25,22 +38,10 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.sql.DataSource;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.test.JobLauncherTestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowCallbackHandler;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.jdbc.JdbcTestUtils;
@SpringJUnitConfig(
@ExtendWith(SpringExtension.class)
@ContextConfiguration(
locations = { "/simple-job-launcher-context.xml", "/jobs/customerFilterJob.xml", "/job-runner-context.xml" })
class CustomerFilterJobFunctionalTests {
@@ -95,7 +96,7 @@ class CustomerFilterJobFunctionalTests {
jdbcTemplate.query(GET_CUSTOMERS, new RowCallbackHandler() {
@Override
public void processRow(ResultSet rs) throws SQLException {
Customer customer = customers.get(activeRow++);
CustomerFilterJobFunctionalTests.Customer customer = customers.get(activeRow++);
assertEquals(customer.getName(), rs.getString(1));
assertEquals(customer.getCredit(), rs.getDouble(2), .01);
}

View File

@@ -16,21 +16,20 @@
package org.springframework.batch.sample;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.launch.JobOperator;
import org.springframework.batch.test.JobLauncherTestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.junit.jupiter.api.Assertions.*;
/**
* Functional test for graceful shutdown. A batch container is started in a new thread,
@@ -38,9 +37,12 @@ import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
*
* @author Lucas Ward
* @author Mahmoud Ben Hassine
* @author Glenn Renfro
*
*/
@SpringJUnitConfig(
@ExtendWith(SpringExtension.class)
@ContextConfiguration(
locations = { "/simple-job-launcher-context.xml", "/jobs/infiniteLoopJob.xml", "/job-runner-context.xml" })
class DatabaseShutdownFunctionalTests {

View File

@@ -15,18 +15,21 @@
*/
package org.springframework.batch.sample;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.core.Job;
import org.springframework.batch.sample.domain.person.PersonService;
import org.springframework.batch.test.JobLauncherTestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
@SpringJUnitConfig(
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
@ExtendWith(SpringExtension.class)
@ContextConfiguration(
locations = { "/simple-job-launcher-context.xml", "/jobs/delegatingJob.xml", "/job-runner-context.xml" })
class DelegatingJobFunctionalTests {

View File

@@ -15,20 +15,22 @@
*/
package org.springframework.batch.sample;
import static org.junit.jupiter.api.Assertions.assertTrue;
import javax.sql.DataSource;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.core.Job;
import org.springframework.batch.test.JobLauncherTestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.jdbc.JdbcTestUtils;
@SpringJUnitConfig(
import javax.sql.DataSource;
import static org.junit.jupiter.api.Assertions.assertTrue;
@ExtendWith(SpringExtension.class)
@ContextConfiguration(
locations = { "/simple-job-launcher-context.xml", "/jobs/footballJob.xml", "/job-runner-context.xml" })
class FootballJobFunctionalTests {

View File

@@ -16,22 +16,18 @@
package org.springframework.batch.sample;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.jupiter.api.Test;
import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.JobParametersBuilder;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.core.*;
import org.springframework.batch.core.launch.JobOperator;
import org.springframework.batch.test.JobLauncherTestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.junit.jupiter.api.Assertions.*;
/**
* Functional test for graceful shutdown. A batch container is started in a new thread,
@@ -39,9 +35,11 @@ import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
*
* @author Lucas Ward
* @author Parikshit Dutta
* @author Glenn Renfro
*
*/
@SpringJUnitConfig(
@ExtendWith(SpringExtension.class)
@ContextConfiguration(
locations = { "/simple-job-launcher-context.xml", "/jobs/infiniteLoopJob.xml", "/job-runner-context.xml" })
class GracefulShutdownFunctionalTests {

View File

@@ -16,23 +16,26 @@
package org.springframework.batch.sample;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.commons.io.FileUtils;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.core.Job;
import org.springframework.batch.test.JobLauncherTestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.springframework.batch.core.Job;
import org.springframework.batch.test.JobLauncherTestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
@SpringJUnitConfig(locations = { "/simple-job-launcher-context.xml", "/jobs/groovyJob.xml", "/job-runner-context.xml" })
class GroovyJobFunctionalTests {
@ExtendWith(SpringExtension.class)
@ContextConfiguration(
locations = { "/simple-job-launcher-context.xml", "/jobs/groovyJob.xml", "/job-runner-context.xml" })
public class GroovyJobFunctionalTests {
@Autowired
private JobLauncherTestUtils jobLauncherTestUtils;

View File

@@ -15,21 +15,24 @@
*/
package org.springframework.batch.sample;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.BufferedReader;
import java.io.FileReader;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.core.Job;
import org.springframework.batch.test.JobLauncherTestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.core.io.Resource;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
@SpringJUnitConfig(
import static org.springframework.test.util.AssertionErrors.assertTrue;
@ExtendWith(SpringExtension.class)
@ContextConfiguration(
locations = { "/simple-job-launcher-context.xml", "/jobs/headerFooterSample.xml", "/job-runner-context.xml" })
class HeaderFooterSampleFunctionalTests {
@@ -60,12 +63,13 @@ class HeaderFooterSampleFunctionalTests {
int lineCount = 0;
while ((line = inputReader.readLine()) != null) {
lineCount++;
assertTrue(outputReader.readLine().contains(line), "input line should correspond to output line");
assertTrue("input line should correspond to output line", outputReader.readLine().contains(line));
}
// footer contains the item count
int itemCount = lineCount - 1; // minus 1 due to header line
assertTrue(outputReader.readLine().contains(String.valueOf(itemCount)));
assertTrue("OutputReader did not contain the values specified",
outputReader.readLine().contains(String.valueOf(itemCount)));
inputReader.close();
outputReader.close();

View File

@@ -15,19 +15,8 @@
*/
package org.springframework.batch.sample;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import java.math.BigDecimal;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import javax.sql.DataSource;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.JobParametersBuilder;
@@ -40,21 +29,35 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowCallbackHandler;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.orm.hibernate5.HibernateJdbcException;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.jdbc.JdbcTestUtils;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.TransactionCallback;
import org.springframework.transaction.support.TransactionTemplate;
import javax.sql.DataSource;
import java.math.BigDecimal;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
/**
* Test for HibernateJob - checks that customer credit has been updated to expected value.
*
* @author Dave Syer
* @author Mahmoud Ben Hassine
* @author Glenn Renfro
*/
@SpringJUnitConfig(locations = { "/simple-job-launcher-context.xml", "/hibernate-context.xml", "/jobs/hibernateJob.xml",
"/job-runner-context.xml" })
@ExtendWith(SpringExtension.class)
@ContextConfiguration(locations = { "/simple-job-launcher-context.xml", "/hibernate-context.xml",
"/jobs/hibernateJob.xml", "/job-runner-context.xml" })
class HibernateFailureJobFunctionalTests {
private static final BigDecimal CREDIT_INCREASE = CustomerCreditIncreaseProcessor.FIXED_AMOUNT;

View File

@@ -15,19 +15,12 @@
*/
package org.springframework.batch.sample;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobParametersBuilder;
@@ -35,9 +28,17 @@ import org.springframework.batch.core.configuration.JobRegistry;
import org.springframework.batch.core.configuration.support.ReferenceJobFactory;
import org.springframework.batch.core.launch.JobOperator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
@SpringJUnitConfig(locations = { "/simple-job-launcher-context.xml", "/jobs/infiniteLoopJob.xml" })
import java.util.List;
import java.util.Map;
import java.util.Set;
import static org.junit.jupiter.api.Assertions.*;
@ExtendWith(SpringExtension.class)
@ContextConfiguration(locations = { "/simple-job-launcher-context.xml", "/jobs/infiniteLoopJob.xml" })
class JobOperatorFunctionalTests {
private static final Log LOG = LogFactory.getLog(JobOperatorFunctionalTests.class);

View File

@@ -16,26 +16,31 @@
package org.springframework.batch.sample;
import static org.junit.jupiter.api.Assertions.assertEquals;
import javax.sql.DataSource;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.core.converter.DefaultJobParametersConverter;
import org.springframework.batch.support.PropertiesConverter;
import org.springframework.batch.test.JobLauncherTestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.jdbc.JdbcTestUtils;
import javax.sql.DataSource;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Sample using a step to launch a job.
*
* @author Dave Syer
* @author Mahmoud Ben Hassine
* @author Glenn Renfro
*/
@SpringJUnitConfig
@ExtendWith(SpringExtension.class)
@ContextConfiguration
class JobStepFunctionalTests {
@Autowired

View File

@@ -55,6 +55,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author Mahmoud Ben Hassine
* @author Glenn Renfro
*/
class JsonSupportIntegrationTests {

View File

@@ -15,23 +15,27 @@
*/
package org.springframework.batch.sample;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.core.Job;
import org.springframework.batch.sample.domain.trade.internal.ItemTrackingTradeItemWriter;
import org.springframework.batch.test.JobLauncherTestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Checks that expected number of items have been processed.
*
* @author Dan Garrette
* @author Glenn Renfro
* @since 2.0
*/
@SpringJUnitConfig(
@ExtendWith(SpringExtension.class)
@ContextConfiguration(
locations = { "/simple-job-launcher-context.xml", "/jobs/loopFlowSample.xml", "/job-runner-context.xml" })
class LoopFlowSampleFunctionalTests {

View File

@@ -15,16 +15,10 @@
*/
package org.springframework.batch.sample;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Iterator;
import java.util.List;
import javax.sql.DataSource;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.core.ExitStatus;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecution;
@@ -35,16 +29,26 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.mail.MailMessage;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.jdbc.JdbcTestUtils;
import javax.sql.DataSource;
import java.util.Iterator;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author Dan Garrette
* @author Dave Syer
* @author Mahmoud Ben Hassine
* @author Glenn Renfro
* @since 2.1
*/
@SpringJUnitConfig(locations = { "/simple-job-launcher-context.xml", "/jobs/mailJob.xml", "/job-runner-context.xml" })
@ExtendWith(SpringExtension.class)
@ContextConfiguration(
locations = { "/simple-job-launcher-context.xml", "/jobs/mailJob.xml", "/job-runner-context.xml" })
class MailJobFunctionalTests {
private static final String email = "to@company.com";

View File

@@ -18,18 +18,20 @@ package org.springframework.batch.sample;
import org.apache.commons.io.IOUtils;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.core.Job;
import org.springframework.batch.test.JobLauncherTestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.util.StringUtils;
import static org.junit.jupiter.api.Assertions.assertEquals;
@SpringJUnitConfig(
@ExtendWith(SpringExtension.class)
@ContextConfiguration(
locations = { "/simple-job-launcher-context.xml", "/jobs/multilineJob.xml", "/job-runner-context.xml" })
class MultilineJobFunctionalTests {

View File

@@ -16,18 +16,20 @@
package org.springframework.batch.sample;
import static org.springframework.batch.test.AssertFile.assertFileEquals;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.core.Job;
import org.springframework.batch.test.JobLauncherTestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.FileSystemResource;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
@SpringJUnitConfig(
import static org.springframework.batch.test.AssertFile.assertFileEquals;
@ExtendWith(SpringExtension.class)
@ContextConfiguration(
locations = { "/simple-job-launcher-context.xml", "/jobs/multilineOrderJob.xml", "/job-runner-context.xml" })
class MultilineOrderJobFunctionalTests {

View File

@@ -16,21 +16,24 @@
package org.springframework.batch.sample;
import static org.junit.jupiter.api.Assertions.assertEquals;
import javax.sql.DataSource;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecution;
import org.springframework.test.jdbc.JdbcTestUtils;
import org.springframework.batch.test.JobLauncherTestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.jdbc.JdbcTestUtils;
@SpringJUnitConfig(
import javax.sql.DataSource;
import static org.junit.jupiter.api.Assertions.assertEquals;
@ExtendWith(SpringExtension.class)
@ContextConfiguration(
locations = { "/simple-job-launcher-context.xml", "/jobs/parallelJob.xml", "/job-runner-context.xml" })
class ParallelJobFunctionalTests {

View File

@@ -16,15 +16,8 @@
package org.springframework.batch.sample;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecution;
@@ -39,9 +32,19 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
@SpringJUnitConfig(
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
@ExtendWith(SpringExtension.class)
@ContextConfiguration(
locations = { "/simple-job-launcher-context.xml", "/jobs/partitionFileJob.xml", "/job-runner-context.xml" })
class PartitionFileJobFunctionalTests implements ApplicationContextAware {
@@ -84,7 +87,7 @@ class PartitionFileJobFunctionalTests implements ApplicationContextAware {
assertEquals(inputs.size(), outputs.size());
int itemCount = inputs.size();
assertTrue(itemCount > 0);
assertTrue(itemCount > 0, "No entries were available in the input");
inputs.iterator();
for (int i = 0; i < itemCount; i++) {

View File

@@ -16,15 +16,8 @@
package org.springframework.batch.sample;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecution;
@@ -39,9 +32,19 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
@SpringJUnitConfig(
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
@ExtendWith(SpringExtension.class)
@ContextConfiguration(
locations = { "/simple-job-launcher-context.xml", "/jobs/partitionJdbcJob.xml", "/job-runner-context.xml" })
class PartitionJdbcJobFunctionalTests implements ApplicationContextAware {
@@ -84,7 +87,7 @@ class PartitionJdbcJobFunctionalTests implements ApplicationContextAware {
assertEquals(inputs.size(), outputs.size());
int itemCount = inputs.size();
assertTrue(itemCount > 0);
assertTrue(itemCount > 0, "Input from reader has no entries.");
inputs.iterator();
for (int i = 0; i < itemCount; i++) {

View File

@@ -21,7 +21,7 @@ import org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.core.ExitStatus;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecution;
@@ -32,7 +32,8 @@ import org.springframework.batch.test.JobLauncherTestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.PropertySource;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -42,8 +43,11 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
* writing.
*
* @author Mahmoud Ben Hassine
* @author Glenn Renfro
*/
@SpringJUnitConfig(classes = { JobRunnerConfiguration.class, ManagerConfiguration.class })
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = { JobRunnerConfiguration.class, ManagerConfiguration.class })
@PropertySource("classpath:remote-chunking.properties")
class RemoteChunkingJobFunctionalTests {

View File

@@ -15,15 +15,13 @@
*/
package org.springframework.batch.sample;
import javax.sql.DataSource;
import org.apache.activemq.artemis.core.config.Configuration;
import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl;
import org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.core.ExitStatus;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecution;
@@ -34,6 +32,9 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.io.ClassPathResource;
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import javax.sql.DataSource;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -41,7 +42,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
* Base class for remote partitioning tests.
*
* @author Mahmoud Ben Hassine
* @author Glenn Renfro
*/
@ExtendWith(SpringExtension.class)
@PropertySource("classpath:remote-partitioning.properties")
public abstract class RemotePartitioningJobFunctionalTests {

View File

@@ -16,11 +16,8 @@
package org.springframework.batch.sample;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.List;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecution;
@@ -32,14 +29,19 @@ 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;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author Dan Garrette
* @author Mahmoud Ben Hassine
* @author Glenn Renfro
* @since 2.0
*/
@SpringJUnitConfig(
@ExtendWith(SpringExtension.class)
@ContextConfiguration(
locations = { "/simple-job-launcher-context.xml", "/jobs/restartFileSampleJob.xml", "/job-runner-context.xml" })
class RestartFileSampleFunctionalTests {

View File

@@ -16,12 +16,8 @@
package org.springframework.batch.sample;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import javax.sql.DataSource;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecution;
@@ -30,18 +26,26 @@ import org.springframework.batch.support.PropertiesConverter;
import org.springframework.batch.test.JobLauncherTestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.transaction.BeforeTransaction;
import org.springframework.test.jdbc.JdbcTestUtils;
import javax.sql.DataSource;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Simple restart scenario.
*
* @author Robert Kasanicky
* @author Dave Syer
* @author Mahmoud Ben Hassine
* @author Glenn Renfro
*/
@SpringJUnitConfig(
@ExtendWith(SpringExtension.class)
@ContextConfiguration(
locations = { "/simple-job-launcher-context.xml", "/jobs/restartSample.xml", "/job-runner-context.xml" })
class RestartFunctionalTests {

View File

@@ -15,10 +15,8 @@
*/
package org.springframework.batch.sample;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.core.Job;
import org.springframework.batch.sample.config.DataSourceConfiguration;
import org.springframework.batch.sample.config.JobRunnerConfiguration;
@@ -27,7 +25,10 @@ import org.springframework.batch.sample.domain.trade.internal.GeneratingTradeIte
import org.springframework.batch.sample.support.RetrySampleItemWriter;
import org.springframework.batch.test.JobLauncherTestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Checks that expected number of items have been processed.
@@ -35,8 +36,10 @@ import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
* @author Robert Kasanicky
* @author Dave Syer
* @author Mahmoud Ben Hassine
* @author Glenn Renfro
*/
@SpringJUnitConfig(
@ExtendWith(SpringExtension.class)
@ContextConfiguration(
classes = { DataSourceConfiguration.class, RetrySampleConfiguration.class, JobRunnerConfiguration.class })
class RetrySampleConfigurationTests {

View File

@@ -15,24 +15,28 @@
*/
package org.springframework.batch.sample;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.core.Job;
import org.springframework.batch.sample.domain.trade.internal.GeneratingTradeItemReader;
import org.springframework.batch.sample.support.RetrySampleItemWriter;
import org.springframework.batch.test.JobLauncherTestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Checks that expected number of items have been processed.
*
* @author Robert Kasanicky
* @author Mahmoud Ben Hassine
* @author Glenn Renfro
*/
@SpringJUnitConfig(
@ExtendWith(SpringExtension.class)
@ContextConfiguration(
locations = { "/simple-job-launcher-context.xml", "/jobs/retrySample.xml", "/job-runner-context.xml" })
class RetrySampleFunctionalTests {

View File

@@ -15,26 +15,10 @@
*/
package org.springframework.batch.sample;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.math.BigDecimal;
import java.util.Map;
import javax.sql.DataSource;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.ExitStatus;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.JobParametersInvalidException;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.UnexpectedJobExecutionException;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.core.*;
import org.springframework.batch.core.explore.JobExplorer;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.batch.core.launch.JobOperator;
@@ -48,14 +32,21 @@ import org.springframework.batch.sample.domain.trade.internal.TradeWriter;
import org.springframework.batch.sample.skip.SkippableExceptionDuringProcessSample;
import org.springframework.batch.sample.skip.SkippableExceptionDuringReadSample;
import org.springframework.batch.sample.skip.SkippableExceptionDuringWriteSample;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.test.jdbc.JdbcTestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.jdbc.JdbcTestUtils;
import javax.sql.DataSource;
import java.math.BigDecimal;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.*;
/**
* Error is encountered during writing - transaction is rolled back and the error item is
@@ -65,7 +56,8 @@ import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
* @author Dan Garrette
* @author Mahmoud Ben Hassine
*/
@SpringJUnitConfig(locations = { "/skipSample-job-launcher-context.xml" })
@ExtendWith(SpringExtension.class)
@ContextConfiguration(locations = { "/skipSample-job-launcher-context.xml" })
class SkipSampleFunctionalTests {
private JdbcTemplate jdbcTemplate;

View File

@@ -16,9 +16,8 @@
package org.springframework.batch.sample;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecution;
@@ -26,9 +25,13 @@ import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.batch.core.scope.context.ChunkContext;
import org.springframework.batch.test.JobLauncherTestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
@SpringJUnitConfig(
import static org.junit.jupiter.api.Assertions.assertEquals;
@ExtendWith(SpringExtension.class)
@ContextConfiguration(
locations = { "/simple-job-launcher-context.xml", "/jobs/taskletJob.xml", "/job-runner-context.xml" })
class TaskletJobFunctionalTests {

View File

@@ -16,9 +16,21 @@
package org.springframework.batch.sample;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.core.Job;
import org.springframework.batch.sample.domain.trade.Trade;
import org.springframework.batch.test.JobLauncherTestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowCallbackHandler;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.jdbc.JdbcTestUtils;
import javax.sql.DataSource;
import java.math.BigDecimal;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -27,22 +39,11 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.sql.DataSource;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.batch.core.Job;
import org.springframework.batch.sample.domain.trade.Trade;
import org.springframework.batch.test.JobLauncherTestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowCallbackHandler;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.jdbc.JdbcTestUtils;
@SpringJUnitConfig(locations = { "/simple-job-launcher-context.xml", "/jobs/tradeJob.xml", "/job-runner-context.xml" })
@ExtendWith(SpringExtension.class)
@ContextConfiguration(
locations = { "/simple-job-launcher-context.xml", "/jobs/tradeJob.xml", "/job-runner-context.xml" })
class TradeJobFunctionalTests {
private static final String GET_TRADES = "select ISIN, QUANTITY, PRICE, CUSTOMER, ID, VERSION from TRADE order by ISIN";

View File

@@ -15,24 +15,31 @@
*/
package org.springframework.batch.sample.common;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Map;
import javax.sql.DataSource;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
@SpringJUnitConfig
import static org.junit.jupiter.api.Assertions.assertEquals;
@ExtendWith(SpringExtension.class)
@ContextConfiguration
class ColumnRangePartitionerTests {
@Autowired
private DataSource dataSource;
private final ColumnRangePartitioner partitioner = new ColumnRangePartitioner();
@Autowired
public void setDataSource(DataSource dataSource) {
this.dataSource = dataSource;
}
private ColumnRangePartitioner partitioner = new ColumnRangePartitioner();
@Test
void testPartition() {

View File

@@ -15,12 +15,6 @@
*/
package org.springframework.batch.sample.common;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import java.util.ArrayList;
import java.util.List;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.batch.item.ExecutionContext;
@@ -29,12 +23,19 @@ import org.springframework.batch.item.ItemStream;
import org.springframework.batch.item.ItemStreamException;
import org.springframework.lang.Nullable;
import java.util.ArrayList;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
/**
* Unit test class that was used as part of the Reference Documentation. I'm only
* including it in the code to help keep the reference documentation up to date as the
* code base shifts.
*
* @author Lucas Ward
* @author Glenn Renfro
*
*/
class CustomItemReaderTests {

View File

@@ -15,18 +15,15 @@
*/
package org.springframework.batch.sample.common;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.junit.jupiter.api.Test;
import org.springframework.batch.item.Chunk;
import org.springframework.batch.item.ItemWriter;
import org.springframework.batch.support.transaction.TransactionAwareProxyFactory;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Unit test class that was used as part of the Reference Documentation. I'm only
* including it in the code to help keep the reference documentation up to date as the
@@ -34,7 +31,8 @@ import org.springframework.batch.support.transaction.TransactionAwareProxyFactor
*
* @author Lucas Ward
* @author Mahmoud Ben Hassine
*
* @author Glenn Renfro
*
*/
class CustomItemWriterTests {

View File

@@ -15,11 +15,6 @@
*/
package org.springframework.batch.sample.common;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.List;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.springframework.batch.core.UnexpectedJobExecutionException;
@@ -28,6 +23,11 @@ import org.springframework.batch.repeat.context.RepeatContextSupport;
import org.springframework.batch.repeat.support.RepeatSynchronizationManager;
import org.springframework.batch.sample.support.ExceptionThrowingItemReaderProxy;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
class ExceptionThrowingItemReaderProxyTests {
// expected call count before exception is thrown (exception should be thrown in next

View File

@@ -16,6 +16,7 @@
package org.springframework.batch.sample.common;
import org.junit.jupiter.api.Test;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.StepExecution;

View File

@@ -15,14 +15,8 @@
*/
package org.springframework.batch.sample.common;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
import java.util.Arrays;
import javax.sql.DataSource;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobInstance;
import org.springframework.batch.core.JobParameters;
@@ -30,7 +24,8 @@ import org.springframework.batch.core.StepExecution;
import org.springframework.batch.item.Chunk;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.transaction.AfterTransaction;
import org.springframework.test.context.transaction.BeforeTransaction;
import org.springframework.test.jdbc.JdbcTestUtils;
@@ -41,7 +36,13 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionCallback;
import org.springframework.transaction.support.TransactionTemplate;
@SpringJUnitConfig
import javax.sql.DataSource;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
@ExtendWith(SpringExtension.class)
@ContextConfiguration()
class StagingItemReaderTests {
private JdbcTemplate jdbcTemplate;

View File

@@ -15,14 +15,9 @@
*/
package org.springframework.batch.sample.common;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Collections;
import javax.sql.DataSource;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobInstance;
import org.springframework.batch.core.JobParameters;
@@ -30,11 +25,17 @@ import org.springframework.batch.core.StepExecution;
import org.springframework.batch.item.Chunk;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.jdbc.JdbcTestUtils;
import org.springframework.transaction.annotation.Transactional;
@SpringJUnitConfig
import javax.sql.DataSource;
import static org.junit.jupiter.api.Assertions.assertEquals;
@ExtendWith(SpringExtension.class)
@ContextConfiguration
class StagingItemWriterTests {
private JdbcTemplate jdbcTemplate;

View File

@@ -15,32 +15,34 @@
*/
package org.springframework.batch.sample.domain.football.internal;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collections;
import javax.sql.DataSource;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.item.Chunk;
import org.springframework.batch.sample.domain.football.Game;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcOperations;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.transaction.annotation.Transactional;
import javax.sql.DataSource;
import java.sql.ResultSet;
import java.sql.SQLException;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author Lucas Ward
* @author Mahmoud Ben Hassine
* @author Glenn Renfro
*
*/
@SpringJUnitConfig(locations = { "/data-source-context.xml" })
@ExtendWith(SpringExtension.class)
@ContextConfiguration(locations = { "/data-source-context.xml" })
class JdbcGameDaoIntegrationTests {
private JdbcGameDao gameDao;
@@ -58,7 +60,7 @@ class JdbcGameDaoIntegrationTests {
}
@BeforeEach
void onSetUpBeforeTransaction() {
void onSetUpBeforeTransaction() throws Exception {
game.setId("XXXXX00");
game.setYear(1996);
game.setTeam("mia");

View File

@@ -15,29 +15,32 @@
*/
package org.springframework.batch.sample.domain.football.internal;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.sql.DataSource;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.sample.domain.football.Player;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowCallbackHandler;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.jdbc.JdbcTestUtils;
import org.springframework.transaction.annotation.Transactional;
import javax.sql.DataSource;
import java.sql.ResultSet;
import java.sql.SQLException;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author Lucas Ward
* @author Mahmoud Ben Hassine
* @author Glenn Renfro
*
*/
@SpringJUnitConfig(locations = { "/data-source-context.xml" })
@ExtendWith(SpringExtension.class)
@ContextConfiguration(locations = { "/data-source-context.xml" })
class JdbcPlayerDaoIntegrationTests {
private JdbcPlayerDao playerDao;

View File

@@ -15,29 +15,30 @@
*/
package org.springframework.batch.sample.domain.football.internal;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Collections;
import javax.sql.DataSource;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.item.Chunk;
import org.springframework.batch.sample.domain.football.PlayerSummary;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.jdbc.JdbcTestUtils;
import org.springframework.transaction.annotation.Transactional;
import javax.sql.DataSource;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author Lucas Ward
* @author Mahmoud Ben Hassine
* @author Glenn Renfro
*
*/
@SpringJUnitConfig(locations = { "/data-source-context.xml" })
@ExtendWith(SpringExtension.class)
@ContextConfiguration(locations = { "/data-source-context.xml" })
class JdbcPlayerSummaryDaoIntegrationTests {
private JdbcPlayerSummaryDao playerSummaryDao;

View File

@@ -15,16 +15,13 @@
*/
package org.springframework.batch.sample.domain.multiline;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
import org.springframework.batch.item.file.mapping.FieldSetMapper;
import org.springframework.batch.item.file.transform.DefaultFieldSet;
import org.springframework.batch.item.file.transform.FieldSet;
import static org.junit.jupiter.api.Assertions.*;
class AggregateItemFieldSetMapperTests {
private final AggregateItemFieldSetMapper<String> mapper = new AggregateItemFieldSetMapper<>();

View File

@@ -15,21 +15,25 @@
*/
package org.springframework.batch.sample.domain.multiline;
import static org.junit.jupiter.api.Assertions.*;
import java.util.Collection;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.batch.item.ItemReader;
import org.springframework.lang.Nullable;
import java.util.Collection;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
class AggregateItemReaderTests {
private ItemReader<AggregateItem<String>> input;
private AggregateItemReader<String> provider;
@BeforeEach
void setUp() {
ItemReader<AggregateItem<String>> input = new ItemReader<>() {
input = new ItemReader<AggregateItem<String>>() {
private int count = 0;
@Nullable

View File

@@ -15,14 +15,13 @@
*/
package org.springframework.batch.sample.domain.multiline;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
/**
* @author Dave Syer
* @author Glenn Renfro
*
*/
class AggregateItemTests {

View File

@@ -15,13 +15,6 @@
*/
package org.springframework.batch.sample.domain.order;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.batch.item.ItemReader;
@@ -30,6 +23,10 @@ import org.springframework.batch.item.file.transform.DefaultFieldSet;
import org.springframework.batch.item.file.transform.FieldSet;
import org.springframework.batch.sample.domain.order.internal.OrderItemReader;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
class OrderItemReaderTests {
private OrderItemReader provider;

View File

@@ -15,27 +15,28 @@
*/
package org.springframework.batch.sample.domain.order.internal.validator;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.batch.sample.domain.order.*;
import org.springframework.validation.BeanPropertyBindingResult;
import org.springframework.validation.Errors;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.junit.jupiter.api.Test;
import org.springframework.batch.sample.domain.order.Address;
import org.springframework.batch.sample.domain.order.BillingInfo;
import org.springframework.batch.sample.domain.order.Customer;
import org.springframework.batch.sample.domain.order.LineItem;
import org.springframework.batch.sample.domain.order.Order;
import org.springframework.batch.sample.domain.order.ShippingInfo;
import org.springframework.validation.BeanPropertyBindingResult;
import org.springframework.validation.Errors;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
class OrderValidatorTests {
private final OrderValidator orderValidator = new OrderValidator();
private OrderValidator orderValidator;
@BeforeEach
void setUp() throws Exception {
orderValidator = new OrderValidator();
}
@Test
void testSupports() {

View File

@@ -15,9 +15,6 @@
*/
package org.springframework.batch.sample.domain.trade;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.batch.item.file.transform.DefaultFieldSet;
@@ -25,8 +22,12 @@ import org.springframework.batch.item.file.transform.FieldSet;
import org.springframework.batch.item.file.transform.LineTokenizer;
import org.springframework.lang.Nullable;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
/**
* @author Lucas Ward
* @author Glenn Renfro
*
*/
class CompositeCustomerUpdateLineTokenizerTests {

View File

@@ -15,21 +15,20 @@
*/
package org.springframework.batch.sample.domain.trade;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.math.BigDecimal;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.springframework.batch.sample.domain.trade.CustomerOperation.ADD;
import static org.springframework.batch.sample.domain.trade.CustomerOperation.DELETE;
import static org.springframework.batch.sample.domain.trade.CustomerOperation.UPDATE;
import java.math.BigDecimal;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.springframework.batch.sample.domain.trade.CustomerOperation.*;
/**
* @author Lucas Ward
* @author Glenn Renfro
*
*/
class CustomerUpdateProcessorTests {

View File

@@ -15,10 +15,10 @@
*/
package org.springframework.batch.sample.domain.trade;
import java.math.BigDecimal;
import org.junit.jupiter.api.Test;
import java.math.BigDecimal;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;

View File

@@ -15,17 +15,18 @@
*/
package org.springframework.batch.sample.domain.trade.internal;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import org.springframework.batch.sample.domain.trade.CustomerCredit;
import java.math.BigDecimal;
import org.junit.jupiter.api.Test;
import org.springframework.batch.sample.domain.trade.CustomerCredit;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Tests for {@link CustomerCreditIncreaseProcessor}.
*
* @author Robert Kasanicky
* @author Glenn Renfro
*/
class CustomerCreditIncreaseProcessorTests {

View File

@@ -27,6 +27,7 @@ import org.springframework.batch.sample.domain.trade.CustomerCredit;
/**
* @author Dave Syer
* @author Glenn Renfro
*
*/
class CustomerCreditUpdatePreparedStatementSetterTests {

View File

@@ -15,18 +15,16 @@
*/
package org.springframework.batch.sample.domain.trade.internal;
import static org.mockito.Mockito.mock;
import java.math.BigDecimal;
import java.util.Collections;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.batch.item.Chunk;
import org.springframework.batch.sample.domain.trade.CustomerCredit;
import org.springframework.batch.sample.domain.trade.CustomerCreditDao;
import java.math.BigDecimal;
import static org.mockito.Mockito.mock;
class CustomerCreditUpdateProcessorTests {
private CustomerCreditDao dao;

View File

@@ -15,18 +15,16 @@
*/
package org.springframework.batch.sample.domain.trade.internal;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.math.BigDecimal;
import java.util.Collections;
import org.junit.jupiter.api.Test;
import org.springframework.batch.item.Chunk;
import org.springframework.batch.sample.domain.trade.CustomerDebit;
import org.springframework.batch.sample.domain.trade.CustomerDebitDao;
import org.springframework.batch.sample.domain.trade.Trade;
import java.math.BigDecimal;
import static org.junit.jupiter.api.Assertions.assertEquals;
class CustomerUpdateProcessorTests {
@Test

View File

@@ -15,20 +15,18 @@
*/
package org.springframework.batch.sample.domain.trade.internal;
import static org.mockito.Mockito.mock;
import java.math.BigDecimal;
import java.util.Collections;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.batch.item.Chunk;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.ItemStream;
import org.springframework.batch.item.ItemWriter;
import org.springframework.batch.sample.domain.trade.CustomerCredit;
import java.math.BigDecimal;
import static org.mockito.Mockito.mock;
class FlatFileCustomerCreditDaoTests {
private ResourceLifecycleItemWriter output;

View File

@@ -20,12 +20,17 @@ import static org.junit.jupiter.api.Assertions.assertNull;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Tests for {@link GeneratingTradeItemReader}.
*
* @author Robert Kasanicky
* @author Glenn Renfro
*/
public class GeneratingItemReaderTests {
class GeneratingItemReaderTests {
private final GeneratingTradeItemReader reader = new GeneratingTradeItemReader();
@@ -33,7 +38,7 @@ public class GeneratingItemReaderTests {
* Generates a given number of not-null records, consecutive calls return null.
*/
@Test
public void testRead() throws Exception {
void testRead() throws Exception {
int counter = 0;
int limit = 10;
reader.setLimit(limit);

View File

@@ -15,24 +15,26 @@
*/
package org.springframework.batch.sample.domain.trade.internal;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.math.BigDecimal;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.sql.DataSource;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.sample.domain.trade.CustomerDebit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcOperations;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowCallbackHandler;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.transaction.annotation.Transactional;
@SpringJUnitConfig
import javax.sql.DataSource;
import java.math.BigDecimal;
import java.sql.ResultSet;
import java.sql.SQLException;
import static org.junit.jupiter.api.Assertions.assertEquals;
@ExtendWith(SpringExtension.class)
@ContextConfiguration()
class JdbcCustomerDebitDaoTests {
private JdbcOperations jdbcTemplate;

View File

@@ -15,15 +15,8 @@
*/
package org.springframework.batch.sample.domain.trade.internal;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.math.BigDecimal;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.sql.DataSource;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.sample.domain.trade.Trade;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
@@ -32,10 +25,19 @@ import org.springframework.jdbc.core.JdbcOperations;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowCallbackHandler;
import org.springframework.jdbc.support.incrementer.AbstractDataFieldMaxValueIncrementer;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.transaction.annotation.Transactional;
@SpringJUnitConfig(locations = { "/data-source-context.xml" })
import javax.sql.DataSource;
import java.math.BigDecimal;
import java.sql.ResultSet;
import java.sql.SQLException;
import static org.junit.jupiter.api.Assertions.assertEquals;
@ExtendWith(SpringExtension.class)
@ContextConfiguration(locations = { "/data-source-context.xml" })
class JdbcTradeWriterTests implements InitializingBean {
private JdbcOperations jdbcTemplate;

View File

@@ -15,17 +15,14 @@
*/
package org.springframework.batch.sample.domain.trade.internal;
import static org.mockito.Mockito.mock;
import java.util.Collections;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.batch.item.Chunk;
import org.springframework.batch.sample.domain.trade.Trade;
import org.springframework.batch.sample.domain.trade.TradeDao;
import static org.mockito.Mockito.mock;
class TradeProcessorTests {
private TradeDao writer;

View File

@@ -37,6 +37,7 @@ import org.springframework.batch.test.JobLauncherTestUtils;
import org.springframework.batch.test.MetaDataInstanceFactory;
import org.springframework.batch.test.StepScopeTestExecutionListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.TestExecutionListeners;
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
@@ -49,7 +50,7 @@ import org.springframework.test.context.support.DependencyInjectionTestExecution
* @author Robert Kasanicky
* @author Mahmoud Ben Hassine
*/
@SpringJUnitConfig(
@ContextConfiguration(
locations = { "/simple-job-launcher-context.xml", "/job-runner-context.xml", "/jobs/ioSampleJob.xml" })
@TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, StepScopeTestExecutionListener.class })
abstract class AbstractIoSampleTests {

View File

@@ -16,6 +16,8 @@
package org.springframework.batch.sample.iosample;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.scope.context.StepSynchronizationManager;
@@ -23,13 +25,17 @@ import org.springframework.batch.item.ItemReader;
import org.springframework.batch.sample.domain.trade.CustomerCredit;
import org.springframework.batch.test.MetaDataInstanceFactory;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
/**
* @author Dan Garrette
* @author Dave Syer
* @author Glenn Renfro
* @since 2.0
*/
@SpringJUnitConfig(locations = "/jobs/iosample/delimited.xml")
@ExtendWith(SpringExtension.class)
@ContextConfiguration(locations = "/jobs/iosample/delimited.xml")
class DelimitedFunctionalTests extends AbstractIoSampleTests {
@Override

View File

@@ -16,15 +16,18 @@
package org.springframework.batch.sample.iosample;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.scope.context.StepSynchronizationManager;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.sample.domain.trade.CustomerCredit;
import org.springframework.batch.test.MetaDataInstanceFactory;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
@SpringJUnitConfig(locations = "/jobs/iosample/fixedLength.xml")
@ExtendWith(SpringExtension.class)
@ContextConfiguration(locations = "/jobs/iosample/fixedLength.xml")
class FixedLengthFunctionalTests extends AbstractIoSampleTests {
@Override

View File

@@ -15,11 +15,15 @@
*/
package org.springframework.batch.sample.iosample;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.sample.domain.trade.CustomerCredit;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
@SpringJUnitConfig(locations = { "/hibernate-context.xml", "/jobs/iosample/hibernate.xml" })
@ExtendWith(SpringExtension.class)
@ContextConfiguration(locations = { "/hibernate-context.xml", "/jobs/iosample/hibernate.xml" })
class HibernateFunctionalTests extends AbstractIoSampleTests {
@Override

View File

@@ -16,15 +16,19 @@
package org.springframework.batch.sample.iosample;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.sample.domain.trade.CustomerCredit;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
/**
* @author Dan Garrette
* @author Glenn Renfro
* @since 2.0
*/
@SpringJUnitConfig(locations = "/jobs/iosample/jdbcCursor.xml")
@ExtendWith(SpringExtension.class)
@ContextConfiguration(locations = "/jobs/iosample/jdbcCursor.xml")
class JdbcCursorFunctionalTests extends AbstractIoSampleTests {
@Override

View File

@@ -16,20 +16,23 @@
package org.springframework.batch.sample.iosample;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.scope.context.StepSynchronizationManager;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.sample.domain.trade.CustomerCredit;
import org.springframework.batch.test.MetaDataInstanceFactory;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
/**
* @author Dan Garrette
* @author Dave Syer
* @since 2.0
*/
@SpringJUnitConfig(locations = "/jobs/iosample/jdbcPaging.xml")
@ExtendWith(SpringExtension.class)
@ContextConfiguration(locations = "/jobs/iosample/jdbcPaging.xml")
class JdbcPagingFunctionalTests extends AbstractIoSampleTests {
@Override

View File

@@ -15,11 +15,15 @@
*/
package org.springframework.batch.sample.iosample;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.sample.domain.trade.CustomerCredit;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
@SpringJUnitConfig(locations = "/jobs/iosample/jpa.xml")
@ExtendWith(SpringExtension.class)
@ContextConfiguration(locations = "/jobs/iosample/jpa.xml")
class JpaFunctionalTests extends AbstractIoSampleTests {
@Override

View File

@@ -17,20 +17,23 @@
package org.springframework.batch.sample.iosample;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
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;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
/**
* @author Dan Garrette
* @author Mahmoud Ben Hassine
* @author Glenn Renfro
* @since 2.0
*/
@SpringJUnitConfig(
@ExtendWith(SpringExtension.class)
@ContextConfiguration(
locations = { "/simple-job-launcher-context.xml", "/jobs/iosample/multiLine.xml", "/job-runner-context.xml" })
class MultiLineFunctionalTests {

View File

@@ -17,20 +17,24 @@
package org.springframework.batch.sample.iosample;
import org.junit.jupiter.api.Test;
import org.springframework.batch.core.Job;
import org.junit.jupiter.api.extension.ExtendWith;
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;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
/**
* @author Dan Garrette
* @author Mahmoud Ben Hassine
* @author Glenn Renfro
* @since 2.0
*/
@SpringJUnitConfig(locations = { "/simple-job-launcher-context.xml", "/jobs/iosample/multiRecordType.xml",
@ExtendWith(SpringExtension.class)
@ContextConfiguration(locations = { "/simple-job-launcher-context.xml", "/jobs/iosample/multiRecordType.xml",
"/job-runner-context.xml" })
class MultiRecordTypeFunctionalTests {

View File

@@ -16,6 +16,7 @@
package org.springframework.batch.sample.iosample;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.batch.core.StepExecution;
@@ -23,13 +24,16 @@ import org.springframework.batch.core.scope.context.StepSynchronizationManager;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.sample.domain.trade.CustomerCredit;
import org.springframework.batch.test.MetaDataInstanceFactory;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
/**
* @author Dan Garrette
* @author Glenn Renfro
* @since 2.0
*/
@SpringJUnitConfig(locations = "/jobs/iosample/multiResource.xml")
@ExtendWith(SpringExtension.class)
@ContextConfiguration(locations = "/jobs/iosample/multiResource.xml")
class MultiResourceFunctionalTests extends AbstractIoSampleTests {
@Override

View File

@@ -15,15 +15,19 @@
*/
package org.springframework.batch.sample.iosample;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.scope.context.StepSynchronizationManager;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.sample.domain.trade.CustomerCredit;
import org.springframework.batch.test.MetaDataInstanceFactory;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
@SpringJUnitConfig(locations = "/jobs/iosample/repository.xml")
@ExtendWith(SpringExtension.class)
@ContextConfiguration(locations = "/jobs/iosample/repository.xml")
class RepositoryFunctionalTests extends AbstractIoSampleTests {
@Override

View File

@@ -22,6 +22,8 @@ import java.util.Date;
import java.util.concurrent.Callable;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecution;
@@ -38,12 +40,18 @@ import org.springframework.batch.test.StepScopeTestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author Dave Syer
* @author Glenn Renfro
* @since 2.0
*/
@SpringJUnitConfig(
@ExtendWith(SpringExtension.class)
@ContextConfiguration(
locations = { "/simple-job-launcher-context.xml", "/jobs/ioSampleJob.xml", "/jobs/iosample/delimited.xml" })
class TwoJobInstancesDelimitedFunctionalTests {

View File

@@ -16,31 +16,30 @@
package org.springframework.batch.sample.iosample;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotSame;
import java.util.Date;
import javax.sql.DataSource;
import org.junit.jupiter.api.Test;
import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.JobParametersBuilder;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.core.*;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.jdbc.JdbcTestUtils;
import javax.sql.DataSource;
import java.util.Date;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotSame;
/**
* @author Dave Syer
* @author Mahmoud Ben Hassine
* @author Glenn Renfro
* @since 2.0
*/
@SpringJUnitConfig(
@ExtendWith(SpringExtension.class)
@ContextConfiguration(
locations = { "/simple-job-launcher-context.xml", "/jobs/ioSampleJob.xml", "/jobs/iosample/jdbcPaging.xml" })
class TwoJobInstancesPagingFunctionalTests {

View File

@@ -16,18 +16,23 @@
package org.springframework.batch.sample.iosample;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.xml.StaxEventItemReader;
import org.springframework.batch.sample.domain.trade.CustomerCredit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
/**
* @author Dan Garrette
* @author Glenn Renfro
* @since 2.0
*/
@SpringJUnitConfig(locations = "/jobs/iosample/xml.xml")
@ExtendWith(SpringExtension.class)
@ContextConfiguration(locations = "/jobs/iosample/xml.xml")
class XmlFunctionalTests extends AbstractIoSampleTests {
@Autowired

View File

@@ -15,21 +15,21 @@
*/
package org.springframework.batch.sample.jmx;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.ArrayList;
import java.util.List;
import javax.management.Notification;
import org.junit.jupiter.api.Test;
import org.springframework.jmx.export.notification.NotificationPublisher;
import org.springframework.jmx.export.notification.UnableToSendNotificationException;
import javax.management.Notification;
import java.util.ArrayList;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author Dave Syer
* @author Thomas Risberg
* @author Glenn Renfro
*
*/
class JobExecutionNotificationPublisherTests {

View File

@@ -15,18 +15,6 @@
*/
package org.springframework.batch.sample.launch;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotSame;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.management.MalformedObjectNameException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.jupiter.api.AfterAll;
@@ -39,6 +27,13 @@ import org.springframework.jmx.access.InvalidInvocationException;
import org.springframework.jmx.access.MBeanProxyFactoryBean;
import org.springframework.jmx.support.MBeanServerConnectionFactoryBean;
import javax.management.MalformedObjectNameException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import static org.junit.jupiter.api.Assertions.*;
/**
* @author Dave Syer
*

View File

@@ -15,14 +15,6 @@
*/
package org.springframework.batch.sample.quartz;
import static org.mockito.Mockito.mock;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.quartz.Job;
@@ -44,9 +36,18 @@ import org.springframework.batch.core.repository.JobExecutionAlreadyRunningExcep
import org.springframework.batch.core.repository.JobRestartException;
import org.springframework.lang.Nullable;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
/**
* @author Dave Syer
*
* @author Glenn Renfro
*
*/
class JobLauncherDetailsTests {
@@ -57,7 +58,7 @@ class JobLauncherDetailsTests {
private final List<Serializable> list = new ArrayList<>();
@BeforeEach
void setUp() {
public void setUp() throws Exception {
details.setJobLauncher(new JobLauncher() {
@Override
public JobExecution run(org.springframework.batch.core.Job job, JobParameters jobParameters)

View File

@@ -26,6 +26,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
* Encapsulates basic logic for testing custom {@link FieldSetMapper} implementations.
*
* @author Robert Kasanicky
* @author Glenn Renfro
*/
public abstract class AbstractFieldSetMapperTests {

View File

@@ -15,6 +15,7 @@
*/
package org.springframework.batch.sample.support;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -22,12 +23,14 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import org.junit.jupiter.api.Test;
import org.springframework.jdbc.core.RowMapper;
/**
* Encapsulates logic for testing custom {@link RowMapper} implementations.
*
* @author Robert Kasanicky
* @author Glenn Renfro
* @param <T> the item type
*/
public abstract class AbstractRowMapperTests<T> {

View File

@@ -15,22 +15,21 @@
*/
package org.springframework.batch.sample.support;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.io.IOException;
import java.util.Arrays;
import org.junit.jupiter.api.Test;
import org.springframework.batch.item.Chunk;
import org.springframework.batch.sample.domain.trade.Trade;
import org.springframework.batch.sample.domain.trade.internal.ItemTrackingTradeItemWriter;
import java.io.IOException;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
/**
* @author Dave Syer
* @author Mahmoud Ben Hassine
*
* @author Glenn Renfro
*
*/
class ItemTrackingItemWriterTests {

View File

@@ -15,16 +15,12 @@
*/
package org.springframework.batch.sample.support;
import org.junit.jupiter.api.Test;
import org.springframework.batch.item.Chunk;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.util.Arrays;
import java.util.Collections;
import org.junit.jupiter.api.Test;
import org.springframework.batch.item.Chunk;
/**
* Tests for {@link RetrySampleItemWriter}.
*

View File

@@ -16,10 +16,8 @@
package org.springframework.batch.sample.validation;
import java.util.List;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.batch.core.ExitStatus;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecution;
@@ -28,14 +26,19 @@ import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.batch.item.support.ListItemWriter;
import org.springframework.batch.sample.validation.domain.Person;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author Mahmoud Ben Hassine
* @author Glenn Renfro
*/
@SpringJUnitConfig(classes = { ValidationSampleConfiguration.class })
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = { ValidationSampleConfiguration.class })
class ValidationSampleFunctionalTests {
@Autowired

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,18 +16,18 @@
package org.springframework.batch.test;
import static org.junit.Assert.assertEquals;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import org.springframework.core.io.Resource;
import org.springframework.util.Assert;
/**
* This class can be used to assert that two files are the same.
*
* @author Dan Garrette
* @author Glenn Renfro
* @since 2.0
*/
public abstract class AssertFile {
@@ -39,12 +39,13 @@ public abstract class AssertFile {
int lineNum = 1;
for (String expectedLine = null; (expectedLine = expectedReader.readLine()) != null; lineNum++) {
String actualLine = actualReader.readLine();
assertEquals("Line number " + lineNum + " does not match.", expectedLine, actualLine);
Assert.state(assertStringEqual(expectedLine, actualLine),
"Line number " + lineNum + " does not match.");
}
String actualLine = actualReader.readLine();
assertEquals("More lines than expected. There should not be a line number " + lineNum + ".", null,
actualLine);
Assert.state(assertStringEqual(null, actualLine),
"More lines than expected. There should not be a line number " + lineNum + ".");
}
finally {
expectedReader.close();
@@ -63,7 +64,8 @@ public abstract class AssertFile {
while (expectedReader.readLine() != null) {
lineCount++;
}
assertEquals(expectedLineCount, lineCount);
Assert.state(expectedLineCount == lineCount, String
.format("Line count of %d does not match expected count of %d", lineCount, expectedLineCount));
}
finally {
expectedReader.close();
@@ -74,4 +76,13 @@ public abstract class AssertFile {
assertLineCount(expectedLineCount, resource.getFile());
}
private static boolean assertStringEqual(String expected, String actual) {
if (expected == null) {
return actual == null;
}
else {
return expected.equals(actual);
}
}
}

View File

@@ -15,18 +15,17 @@
*/
package org.springframework.batch.test;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.ComparisonFailure;
import org.junit.jupiter.api.Test;
import org.springframework.core.io.FileSystemResource;
import static org.junit.jupiter.api.Assertions.*;
/**
* This class can be used to assert that two files are the same.
*
* @author Dan Garrette
* @author Glenn Renfro
* @since 2.0
*/
class AssertFileTests {
@@ -39,21 +38,36 @@ class AssertFileTests {
}
@Test
void testAssertEquals_notEqual() {
Error error = assertThrows(ComparisonFailure.class, () -> executeAssertEquals("input1.txt", "input2.txt"));
assertTrue(error.getMessage().startsWith("Line number 3 does not match."));
public void testAssertEquals_notEqual() throws Exception {
try {
executeAssertEquals("input1.txt", "input2.txt");
fail();
}
catch (IllegalStateException e) {
assertTrue(e.getMessage().startsWith("Line number 3 does not match."));
}
}
@Test
void testAssertEquals_tooLong() {
Error error = assertThrows(AssertionError.class, () -> executeAssertEquals("input3.txt", "input1.txt"));
assertTrue(error.getMessage().startsWith("More lines than expected. There should not be a line number 4."));
public void testAssertEquals_tooLong() throws Exception {
try {
executeAssertEquals("input3.txt", "input1.txt");
fail();
}
catch (IllegalStateException e) {
assertTrue(e.getMessage().startsWith("More lines than expected. There should not be a line number 4."));
}
}
@Test
void testAssertEquals_tooShort() {
Error error = assertThrows(AssertionError.class, () -> executeAssertEquals("input1.txt", "input3.txt"));
assertTrue(error.getMessage().startsWith("Line number 4 does not match."));
public void testAssertEquals_tooShort() throws Exception {
try {
executeAssertEquals("input1.txt", "input3.txt");
fail();
}
catch (IllegalStateException e) {
assertTrue(e.getMessage().startsWith("Line number 4 does not match."));
}
}
@Test
@@ -62,15 +76,25 @@ class AssertFileTests {
}
@Test
void testAssertEquals_blank_tooLong() {
Error error = assertThrows(AssertionError.class, () -> executeAssertEquals("blank.txt", "input1.txt"));
assertTrue(error.getMessage().startsWith("More lines than expected. There should not be a line number 1."));
public void testAssertEquals_blank_tooLong() throws Exception {
try {
executeAssertEquals("blank.txt", "input1.txt");
fail();
}
catch (IllegalStateException e) {
assertTrue(e.getMessage().startsWith("More lines than expected. There should not be a line number 1."));
}
}
@Test
void testAssertEquals_blank_tooShort() {
Error error = assertThrows(AssertionError.class, () -> executeAssertEquals("input1.txt", "blank.txt"));
assertTrue(error.getMessage().startsWith("Line number 1 does not match."));
public void testAssertEquals_blank_tooShort() throws Exception {
try {
executeAssertEquals("input1.txt", "blank.txt");
fail();
}
catch (IllegalStateException e) {
assertTrue(e.getMessage().startsWith("Line number 1 does not match."));
}
}
private void executeAssertEquals(String expected, String actual) throws Exception {