Migrate Spring Batch Samples to JUnit Jupiter
This commit is contained in:
committed by
Mahmoud Ben Hassine
parent
6117c044fb
commit
1e4a23e3eb
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012 the original author or authors.
|
||||
* Copyright 2012-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.
|
||||
@@ -15,15 +15,13 @@
|
||||
*/
|
||||
package org.springframework.batch.sample;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
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.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -39,10 +37,9 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
* </p>
|
||||
*/
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(
|
||||
@SpringJUnitConfig(
|
||||
locations = { "/simple-job-launcher-context.xml", "/jobs/amqp-example-job.xml", "/job-runner-context.xml" })
|
||||
public class AMQPJobFunctionalTests {
|
||||
class AMQPJobFunctionalTests {
|
||||
|
||||
@Autowired
|
||||
private JobLauncherTestUtils jobLauncherTestUtils;
|
||||
@@ -51,7 +48,7 @@ public class AMQPJobFunctionalTests {
|
||||
private JobExplorer jobExplorer;
|
||||
|
||||
@Test
|
||||
public void testLaunchJob() throws Exception {
|
||||
void testLaunchJob() throws Exception {
|
||||
|
||||
jobLauncherTestUtils.launchJob();
|
||||
|
||||
|
||||
@@ -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,23 +16,20 @@
|
||||
|
||||
package org.springframework.batch.sample;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.test.JobLauncherTestUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { "/simple-job-launcher-context.xml", "/jobs/beanWrapperMapperSampleJob.xml",
|
||||
@SpringJUnitConfig(locations = { "/simple-job-launcher-context.xml", "/jobs/beanWrapperMapperSampleJob.xml",
|
||||
"/job-runner-context.xml" })
|
||||
public class BeanWrapperMapperSampleJobFunctionalTests {
|
||||
class BeanWrapperMapperSampleJobFunctionalTests {
|
||||
|
||||
@Autowired
|
||||
private JobLauncherTestUtils jobLauncherTestUtils;
|
||||
|
||||
@Test
|
||||
public void testJobLaunch() throws Exception {
|
||||
void testJobLaunch() throws Exception {
|
||||
|
||||
jobLauncherTestUtils.launchJob();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2021 the original author or authors.
|
||||
* Copyright 2008-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.
|
||||
@@ -25,24 +25,21 @@ import java.util.List;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
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.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.test.jdbc.JdbcTestUtils;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { "/simple-job-launcher-context.xml", "/jobs/compositeItemWriterSampleJob.xml",
|
||||
@SpringJUnitConfig(locations = { "/simple-job-launcher-context.xml", "/jobs/compositeItemWriterSampleJob.xml",
|
||||
"/job-runner-context.xml" })
|
||||
public class CompositeItemWriterSampleFunctionalTests {
|
||||
class CompositeItemWriterSampleFunctionalTests {
|
||||
|
||||
private static final String GET_TRADES = "SELECT isin, quantity, price, customer FROM TRADE order by isin";
|
||||
|
||||
@@ -63,7 +60,7 @@ public class CompositeItemWriterSampleFunctionalTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJobLaunch() throws Exception {
|
||||
void testJobLaunch() throws Exception {
|
||||
JdbcTestUtils.deleteFromTables(jdbcTemplate, "TRADE");
|
||||
int before = JdbcTestUtils.countRowsInTable(jdbcTemplate, "TRADE");
|
||||
|
||||
@@ -75,7 +72,6 @@ public class CompositeItemWriterSampleFunctionalTests {
|
||||
}
|
||||
|
||||
private void checkOutputTable(int before) {
|
||||
@SuppressWarnings("serial")
|
||||
final List<Trade> trades = new ArrayList<Trade>() {
|
||||
{
|
||||
add(new Trade("UK21341EAH41", 211, new BigDecimal("31.11"), "customer1"));
|
||||
@@ -107,7 +103,6 @@ public class CompositeItemWriterSampleFunctionalTests {
|
||||
}
|
||||
|
||||
private void checkOutputFile(String fileName) throws IOException {
|
||||
@SuppressWarnings("resource")
|
||||
List<String> outputLines = IOUtils.readLines(new FileInputStream(fileName), "UTF-8");
|
||||
|
||||
String output = "";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2021 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,7 +16,7 @@
|
||||
|
||||
package org.springframework.batch.sample;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
@@ -27,23 +27,20 @@ import java.util.Map;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
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.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.test.jdbc.JdbcTestUtils;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(
|
||||
@SpringJUnitConfig(
|
||||
locations = { "/simple-job-launcher-context.xml", "/jobs/customerFilterJob.xml", "/job-runner-context.xml" })
|
||||
public class CustomerFilterJobFunctionalTests {
|
||||
class CustomerFilterJobFunctionalTests {
|
||||
|
||||
private static final String GET_CUSTOMERS = "select NAME, CREDIT from CUSTOMER order by NAME";
|
||||
|
||||
@@ -53,7 +50,7 @@ public class CustomerFilterJobFunctionalTests {
|
||||
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
private Map<String, Double> credits = new HashMap<>();
|
||||
private final Map<String, Double> credits = new HashMap<>();
|
||||
|
||||
@Autowired
|
||||
private JobLauncherTestUtils jobLauncherTestUtils;
|
||||
@@ -63,8 +60,8 @@ public class CustomerFilterJobFunctionalTests {
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void onSetUp() throws Exception {
|
||||
@BeforeEach
|
||||
void onSetUp() {
|
||||
JdbcTestUtils.deleteFromTables(jdbcTemplate, "TRADE");
|
||||
JdbcTestUtils.deleteFromTableWhere(jdbcTemplate, "CUSTOMER", "ID > 4");
|
||||
jdbcTemplate.update("update CUSTOMER set credit=100000");
|
||||
@@ -76,14 +73,14 @@ public class CustomerFilterJobFunctionalTests {
|
||||
}
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
@AfterEach
|
||||
void tearDown() {
|
||||
JdbcTestUtils.deleteFromTables(jdbcTemplate, "TRADE");
|
||||
JdbcTestUtils.deleteFromTableWhere(jdbcTemplate, "CUSTOMER", "ID > 4");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFilterJob() throws Exception {
|
||||
void testFilterJob() throws Exception {
|
||||
JobExecution jobExecution = jobLauncherTestUtils.launchJob();
|
||||
|
||||
customers = Arrays.asList(new Customer("customer1", (credits.get("customer1"))),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2021 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,22 +16,20 @@
|
||||
|
||||
package org.springframework.batch.sample;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
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.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
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.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
* Functional test for graceful shutdown. A batch container is started in a new thread,
|
||||
@@ -41,10 +39,9 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(
|
||||
@SpringJUnitConfig(
|
||||
locations = { "/simple-job-launcher-context.xml", "/jobs/infiniteLoopJob.xml", "/job-runner-context.xml" })
|
||||
public class DatabaseShutdownFunctionalTests {
|
||||
class DatabaseShutdownFunctionalTests {
|
||||
|
||||
/** Logger */
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
@@ -56,7 +53,7 @@ public class DatabaseShutdownFunctionalTests {
|
||||
private JobLauncherTestUtils jobLauncherTestUtils;
|
||||
|
||||
@Test
|
||||
public void testLaunchJob() throws Exception {
|
||||
void testLaunchJob() throws Exception {
|
||||
|
||||
JobExecution jobExecution = jobLauncherTestUtils.launchJob();
|
||||
|
||||
@@ -75,7 +72,7 @@ public class DatabaseShutdownFunctionalTests {
|
||||
count++;
|
||||
}
|
||||
|
||||
assertFalse("Timed out waiting for job to end.", jobExecution.isRunning());
|
||||
assertFalse(jobExecution.isRunning(), "Timed out waiting for job to end.");
|
||||
assertEquals(BatchStatus.STOPPED, jobExecution.getStatus());
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2007-2009 the original author or authors.
|
||||
* Copyright 2007-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.
|
||||
@@ -15,21 +15,18 @@
|
||||
*/
|
||||
package org.springframework.batch.sample;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
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.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(
|
||||
@SpringJUnitConfig(
|
||||
locations = { "/simple-job-launcher-context.xml", "/jobs/delegatingJob.xml", "/job-runner-context.xml" })
|
||||
public class DelegatingJobFunctionalTests {
|
||||
class DelegatingJobFunctionalTests {
|
||||
|
||||
@Autowired
|
||||
private JobLauncherTestUtils jobLauncherTestUtils;
|
||||
@@ -38,7 +35,7 @@ public class DelegatingJobFunctionalTests {
|
||||
private PersonService personService;
|
||||
|
||||
@Test
|
||||
public void testLaunchJob() throws Exception {
|
||||
void testLaunchJob() throws Exception {
|
||||
|
||||
jobLauncherTestUtils.launchJob();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2007-2021 the original author or authors.
|
||||
* Copyright 2007-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.
|
||||
@@ -15,23 +15,20 @@
|
||||
*/
|
||||
package org.springframework.batch.sample;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.test.JobLauncherTestUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.test.jdbc.JdbcTestUtils;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(
|
||||
@SpringJUnitConfig(
|
||||
locations = { "/simple-job-launcher-context.xml", "/jobs/footballJob.xml", "/job-runner-context.xml" })
|
||||
public class FootballJobFunctionalTests {
|
||||
class FootballJobFunctionalTests {
|
||||
|
||||
@Autowired
|
||||
private JobLauncherTestUtils jobLauncherTestUtils;
|
||||
@@ -44,7 +41,7 @@ public class FootballJobFunctionalTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLaunchJob() throws Exception {
|
||||
void testLaunchJob() throws Exception {
|
||||
JdbcTestUtils.deleteFromTables(jdbcTemplate, "PLAYERS", "GAMES", "PLAYER_SUMMARY");
|
||||
|
||||
jobLauncherTestUtils.launchJob();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2021 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,14 +16,13 @@
|
||||
|
||||
package org.springframework.batch.sample;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
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.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
@@ -31,8 +30,7 @@ import org.springframework.batch.core.JobParametersBuilder;
|
||||
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.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
* Functional test for graceful shutdown. A batch container is started in a new thread,
|
||||
@@ -42,10 +40,9 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
* @author Parikshit Dutta
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(
|
||||
@SpringJUnitConfig(
|
||||
locations = { "/simple-job-launcher-context.xml", "/jobs/infiniteLoopJob.xml", "/job-runner-context.xml" })
|
||||
public class GracefulShutdownFunctionalTests {
|
||||
class GracefulShutdownFunctionalTests {
|
||||
|
||||
/** Logger */
|
||||
private final Log logger = LogFactory.getLog(getClass());
|
||||
@@ -57,7 +54,7 @@ public class GracefulShutdownFunctionalTests {
|
||||
private JobOperator jobOperator;
|
||||
|
||||
@Test
|
||||
public void testLaunchJob() throws Exception {
|
||||
void testLaunchJob() throws Exception {
|
||||
|
||||
final JobParameters jobParameters = new JobParametersBuilder().addLong("timestamp", System.currentTimeMillis())
|
||||
.toJobParameters();
|
||||
@@ -78,7 +75,7 @@ public class GracefulShutdownFunctionalTests {
|
||||
count++;
|
||||
}
|
||||
|
||||
assertFalse("Timed out waiting for job to end.", jobExecution.isRunning());
|
||||
assertFalse(jobExecution.isRunning(), "Timed out waiting for job to end.");
|
||||
assertEquals(BatchStatus.STOPPED, jobExecution.getStatus());
|
||||
}
|
||||
|
||||
|
||||
@@ -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,36 +16,32 @@
|
||||
|
||||
package org.springframework.batch.sample;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.test.JobLauncherTestUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(
|
||||
locations = { "/simple-job-launcher-context.xml", "/jobs/groovyJob.xml", "/job-runner-context.xml" })
|
||||
public class GroovyJobFunctionalTests {
|
||||
@SpringJUnitConfig(locations = { "/simple-job-launcher-context.xml", "/jobs/groovyJob.xml", "/job-runner-context.xml" })
|
||||
class GroovyJobFunctionalTests {
|
||||
|
||||
@Autowired
|
||||
private JobLauncherTestUtils jobLauncherTestUtils;
|
||||
|
||||
@Before
|
||||
public void removeOldData() throws IOException {
|
||||
@BeforeEach
|
||||
void removeOldData() throws IOException {
|
||||
FileUtils.deleteDirectory(new File("target/groovyJob"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLaunchJob() throws Exception {
|
||||
void testLaunchJob() throws Exception {
|
||||
assertFalse(new File("target/groovyJob/output/files.zip").exists());
|
||||
jobLauncherTestUtils.launchJob();
|
||||
assertTrue(new File("target/groovyJob/output/files.zip").exists());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2014 the original author or authors.
|
||||
* Copyright 2008-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.
|
||||
@@ -15,24 +15,21 @@
|
||||
*/
|
||||
package org.springframework.batch.sample;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
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.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(
|
||||
@SpringJUnitConfig(
|
||||
locations = { "/simple-job-launcher-context.xml", "/jobs/headerFooterSample.xml", "/job-runner-context.xml" })
|
||||
public class HeaderFooterSampleFunctionalTests {
|
||||
class HeaderFooterSampleFunctionalTests {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("inputResource")
|
||||
@@ -46,7 +43,7 @@ public class HeaderFooterSampleFunctionalTests {
|
||||
private JobLauncherTestUtils jobLauncherTestUtils;
|
||||
|
||||
@Test
|
||||
public void testJob() throws Exception {
|
||||
void testJob() throws Exception {
|
||||
jobLauncherTestUtils.launchJob();
|
||||
|
||||
BufferedReader inputReader = new BufferedReader(new FileReader(input.getFile()));
|
||||
@@ -60,7 +57,7 @@ public class HeaderFooterSampleFunctionalTests {
|
||||
int lineCount = 0;
|
||||
while ((line = inputReader.readLine()) != null) {
|
||||
lineCount++;
|
||||
assertTrue("input line should correspond to output line", outputReader.readLine().contains(line));
|
||||
assertTrue(outputReader.readLine().contains(line), "input line should correspond to output line");
|
||||
}
|
||||
|
||||
// footer contains the item count
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2007-2021 the original author or authors.
|
||||
* Copyright 2007-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.
|
||||
@@ -15,8 +15,8 @@
|
||||
*/
|
||||
package org.springframework.batch.sample;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
@@ -26,8 +26,7 @@ import java.util.List;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.JobParametersBuilder;
|
||||
@@ -40,8 +39,7 @@ 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.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.test.jdbc.JdbcTestUtils;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
@@ -54,10 +52,9 @@ import org.springframework.transaction.support.TransactionTemplate;
|
||||
* @author Dave Syer
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { "/simple-job-launcher-context.xml", "/hibernate-context.xml",
|
||||
"/jobs/hibernateJob.xml", "/job-runner-context.xml" })
|
||||
public class HibernateFailureJobFunctionalTests {
|
||||
@SpringJUnitConfig(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;
|
||||
|
||||
@@ -65,7 +62,7 @@ public class HibernateFailureJobFunctionalTests {
|
||||
|
||||
private static final String CREDIT_COLUMN = "CREDIT";
|
||||
|
||||
private static String[] customers = {
|
||||
private static final String[] customers = {
|
||||
"INSERT INTO CUSTOMER (id, version, name, credit) VALUES (1, 0, 'customer1', 100000)",
|
||||
"INSERT INTO CUSTOMER (id, version, name, credit) VALUES (2, 0, 'customer2', 100000)",
|
||||
"INSERT INTO CUSTOMER (id, version, name, credit) VALUES (3, 0, 'customer3', 100000)",
|
||||
@@ -78,6 +75,7 @@ public class HibernateFailureJobFunctionalTests {
|
||||
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
@Autowired
|
||||
private PlatformTransactionManager transactionManager;
|
||||
|
||||
private List<BigDecimal> creditsBeforeUpdate;
|
||||
@@ -90,13 +88,8 @@ public class HibernateFailureJobFunctionalTests {
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setTransactionManager(PlatformTransactionManager transactionManager) {
|
||||
this.transactionManager = transactionManager;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLaunchJob() throws Exception {
|
||||
void testLaunchJob() throws Exception {
|
||||
validatePreConditions();
|
||||
|
||||
JobParameters params = new JobParametersBuilder().addString("key", "failureJob").toJobParameters();
|
||||
@@ -126,7 +119,7 @@ public class HibernateFailureJobFunctionalTests {
|
||||
/**
|
||||
* All customers have the same credit
|
||||
*/
|
||||
protected void validatePreConditions() throws Exception {
|
||||
protected void validatePreConditions() {
|
||||
ensureState();
|
||||
creditsBeforeUpdate = new TransactionTemplate(transactionManager)
|
||||
.execute(new TransactionCallback<List<BigDecimal>>() {
|
||||
@@ -163,7 +156,7 @@ public class HibernateFailureJobFunctionalTests {
|
||||
/**
|
||||
* Credit was increased by CREDIT_INCREASE
|
||||
*/
|
||||
protected void validatePostConditions() throws Exception {
|
||||
protected void validatePostConditions() {
|
||||
final List<BigDecimal> matches = new ArrayList<>();
|
||||
|
||||
new TransactionTemplate(transactionManager).execute(new TransactionCallback<Void>() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2009 the original author or authors.
|
||||
* Copyright 2008-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.
|
||||
@@ -15,9 +15,10 @@
|
||||
*/
|
||||
package org.springframework.batch.sample;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
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;
|
||||
@@ -25,9 +26,8 @@ import java.util.Set;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.Job;
|
||||
import org.springframework.batch.core.JobParametersBuilder;
|
||||
@@ -35,12 +35,10 @@ 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.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { "/simple-job-launcher-context.xml", "/jobs/infiniteLoopJob.xml" })
|
||||
public class JobOperatorFunctionalTests {
|
||||
@SpringJUnitConfig(locations = { "/simple-job-launcher-context.xml", "/jobs/infiniteLoopJob.xml" })
|
||||
class JobOperatorFunctionalTests {
|
||||
|
||||
private static final Log LOG = LogFactory.getLog(JobOperatorFunctionalTests.class);
|
||||
|
||||
@@ -53,15 +51,15 @@ public class JobOperatorFunctionalTests {
|
||||
@Autowired
|
||||
private JobRegistry jobRegistry;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
@BeforeEach
|
||||
void setUp() throws Exception {
|
||||
if (!jobRegistry.getJobNames().contains(job.getName())) {
|
||||
jobRegistry.register(new ReferenceJobFactory(job));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStartStopResumeJob() throws Exception {
|
||||
void testStartStopResumeJob() throws Exception {
|
||||
String params = new JobParametersBuilder().addLong("jobOperatorTestParam", 7L).toJobParameters().toString();
|
||||
|
||||
long executionId = operator.start(job.getName(), params);
|
||||
@@ -91,10 +89,10 @@ public class JobOperatorFunctionalTests {
|
||||
Thread.sleep(1000);
|
||||
|
||||
Set<Long> runningExecutions = operator.getRunningExecutions(job.getName());
|
||||
assertTrue("Wrong executions: " + runningExecutions + " expected: " + executionId,
|
||||
runningExecutions.contains(executionId));
|
||||
assertTrue("Wrong summary: " + operator.getSummary(executionId),
|
||||
operator.getSummary(executionId).contains(BatchStatus.STARTED.toString()));
|
||||
assertTrue(runningExecutions.contains(executionId),
|
||||
"Wrong executions: " + runningExecutions + " expected: " + executionId);
|
||||
assertTrue(operator.getSummary(executionId).contains(BatchStatus.STARTED.toString()),
|
||||
"Wrong summary: " + operator.getSummary(executionId));
|
||||
|
||||
operator.stop(executionId);
|
||||
|
||||
@@ -106,10 +104,10 @@ public class JobOperatorFunctionalTests {
|
||||
}
|
||||
|
||||
runningExecutions = operator.getRunningExecutions(job.getName());
|
||||
assertFalse("Wrong executions: " + runningExecutions + " expected: " + executionId,
|
||||
runningExecutions.contains(executionId));
|
||||
assertTrue("Wrong summary: " + operator.getSummary(executionId),
|
||||
operator.getSummary(executionId).contains(BatchStatus.STOPPED.toString()));
|
||||
assertFalse(runningExecutions.contains(executionId),
|
||||
"Wrong executions: " + runningExecutions + " expected: " + executionId);
|
||||
assertTrue(operator.getSummary(executionId).contains(BatchStatus.STOPPED.toString()),
|
||||
"Wrong summary: " + operator.getSummary(executionId));
|
||||
|
||||
// there is just a single step in the test job
|
||||
Map<Long, String> summaries = operator.getStepExecutionSummaries(executionId);
|
||||
@@ -118,7 +116,7 @@ public class JobOperatorFunctionalTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultipleSimultaneousInstances() throws Exception {
|
||||
void testMultipleSimultaneousInstances() throws Exception {
|
||||
String jobName = job.getName();
|
||||
|
||||
Set<String> names = operator.getJobNames();
|
||||
@@ -129,7 +127,7 @@ public class JobOperatorFunctionalTests {
|
||||
long exec2 = operator.startNextInstance(jobName);
|
||||
|
||||
assertTrue(exec1 != exec2);
|
||||
assertTrue(!operator.getParameters(exec1).equals(operator.getParameters(exec2)));
|
||||
assertNotEquals(operator.getParameters(exec1), operator.getParameters(exec2));
|
||||
|
||||
// Give the asynchronous task executor a chance to start executions
|
||||
Thread.sleep(1000);
|
||||
@@ -147,8 +145,8 @@ public class JobOperatorFunctionalTests {
|
||||
running = operator.getSummary(exec1).contains("STARTED") && operator.getSummary(exec2).contains("STARTED");
|
||||
}
|
||||
|
||||
assertTrue(String.format("Jobs not started: [%s] and [%s]", operator.getSummary(exec1),
|
||||
operator.getSummary(exec1)), running);
|
||||
assertTrue(running, String.format("Jobs not started: [%s] and [%s]", operator.getSummary(exec1),
|
||||
operator.getSummary(exec1)));
|
||||
|
||||
operator.stop(exec1);
|
||||
operator.stop(exec2);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2021 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,19 +16,17 @@
|
||||
|
||||
package org.springframework.batch.sample;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
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.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.test.jdbc.JdbcTestUtils;
|
||||
|
||||
/**
|
||||
@@ -37,9 +35,8 @@ import org.springframework.test.jdbc.JdbcTestUtils;
|
||||
* @author Dave Syer
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration
|
||||
public class JobStepFunctionalTests {
|
||||
@SpringJUnitConfig
|
||||
class JobStepFunctionalTests {
|
||||
|
||||
@Autowired
|
||||
private JobLauncherTestUtils jobLauncherTestUtils;
|
||||
@@ -52,7 +49,7 @@ public class JobStepFunctionalTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJobLaunch() throws Exception {
|
||||
void testJobLaunch() throws Exception {
|
||||
JdbcTestUtils.deleteFromTables(jdbcTemplate, "TRADE");
|
||||
|
||||
jobLauncherTestUtils
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2021 the original author or authors.
|
||||
* Copyright 2018-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.
|
||||
@@ -23,9 +23,8 @@ import java.nio.file.Paths;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.Job;
|
||||
@@ -52,23 +51,25 @@ import org.springframework.core.io.FileSystemResource;
|
||||
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
|
||||
import org.springframework.util.DigestUtils;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
public class JsonSupportIntegrationTests {
|
||||
class JsonSupportIntegrationTests {
|
||||
|
||||
private static final String INPUT_FILE_DIRECTORY = "src/test/resources/org/springframework/batch/item/json/";
|
||||
|
||||
private static final String OUTPUT_FILE_DIRECTORY = "target/";
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
@BeforeEach
|
||||
void setUp() throws Exception {
|
||||
Files.deleteIfExists(Paths.get("build", "trades.json"));
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EnableBatchProcessing
|
||||
public static class JobConfiguration {
|
||||
static class JobConfiguration {
|
||||
|
||||
@Autowired
|
||||
private JobBuilderFactory jobs;
|
||||
@@ -109,13 +110,13 @@ public class JsonSupportIntegrationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJsonReadingAndWriting() throws Exception {
|
||||
void testJsonReadingAndWriting() throws Exception {
|
||||
ApplicationContext context = new AnnotationConfigApplicationContext(JobConfiguration.class);
|
||||
JobLauncher jobLauncher = context.getBean(JobLauncher.class);
|
||||
Job job = context.getBean(Job.class);
|
||||
JobExecution jobExecution = jobLauncher.run(job, new JobParameters());
|
||||
|
||||
Assert.assertEquals(ExitStatus.COMPLETED.getExitCode(), jobExecution.getExitStatus().getExitCode());
|
||||
assertEquals(ExitStatus.COMPLETED.getExitCode(), jobExecution.getExitStatus().getExitCode());
|
||||
assertFileEquals(new File(INPUT_FILE_DIRECTORY + "trades.json"),
|
||||
new File(OUTPUT_FILE_DIRECTORY + "trades.json"));
|
||||
}
|
||||
@@ -123,7 +124,7 @@ public class JsonSupportIntegrationTests {
|
||||
private void assertFileEquals(File expected, File actual) throws Exception {
|
||||
String expectedHash = DigestUtils.md5DigestAsHex(new FileInputStream(expected));
|
||||
String actualHash = DigestUtils.md5DigestAsHex(new FileInputStream(actual));
|
||||
Assert.assertEquals(expectedHash, actualHash);
|
||||
assertEquals(expectedHash, actualHash);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -15,15 +15,13 @@
|
||||
*/
|
||||
package org.springframework.batch.sample;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
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.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
* Checks that expected number of items have been processed.
|
||||
@@ -31,10 +29,9 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
* @author Dan Garrette
|
||||
* @since 2.0
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(
|
||||
@SpringJUnitConfig(
|
||||
locations = { "/simple-job-launcher-context.xml", "/jobs/loopFlowSample.xml", "/job-runner-context.xml" })
|
||||
public class LoopFlowSampleFunctionalTests {
|
||||
class LoopFlowSampleFunctionalTests {
|
||||
|
||||
@Autowired
|
||||
private ItemTrackingTradeItemWriter itemWriter;
|
||||
@@ -43,7 +40,7 @@ public class LoopFlowSampleFunctionalTests {
|
||||
private JobLauncherTestUtils jobLauncherTestUtils;
|
||||
|
||||
@Test
|
||||
public void testJobLaunch() throws Exception {
|
||||
void testJobLaunch() throws Exception {
|
||||
jobLauncherTestUtils.launchJob();
|
||||
// items processed = items read + 2 exceptions
|
||||
assertEquals(10, itemWriter.getItems().size());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2021 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.
|
||||
@@ -15,17 +15,16 @@
|
||||
*/
|
||||
package org.springframework.batch.sample;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.sample.domain.mail.internal.TestMailErrorHandler;
|
||||
@@ -35,20 +34,17 @@ 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.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.test.jdbc.JdbcTestUtils;
|
||||
|
||||
/**
|
||||
* @author Dan Garrette
|
||||
* @author Dave Syer
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @Since 2.1
|
||||
* @since 2.1
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(
|
||||
locations = { "/simple-job-launcher-context.xml", "/jobs/mailJob.xml", "/job-runner-context.xml" })
|
||||
public class MailJobFunctionalTests {
|
||||
@SpringJUnitConfig(locations = { "/simple-job-launcher-context.xml", "/jobs/mailJob.xml", "/job-runner-context.xml" })
|
||||
class MailJobFunctionalTests {
|
||||
|
||||
private static final String email = "to@company.com";
|
||||
|
||||
@@ -84,20 +80,20 @@ public class MailJobFunctionalTests {
|
||||
jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
@BeforeEach
|
||||
void before() {
|
||||
mailSender.clear();
|
||||
errorHandler.clear();
|
||||
jdbcTemplate.update("create table USERS (ID INTEGER, NAME VARCHAR(40), EMAIL VARCHAR(20))");
|
||||
}
|
||||
|
||||
@After
|
||||
public void after() throws Exception {
|
||||
@AfterEach
|
||||
void after() {
|
||||
JdbcTestUtils.dropTables(jdbcTemplate, "USERS");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSkip() throws Exception {
|
||||
void testSkip() throws Exception {
|
||||
this.createUsers(new Object[][] { USER1, USER2_SKIP, USER3, USER4_SKIP, USER5, USER6, USER7, USER8 });
|
||||
|
||||
JobExecution jobExecution = jobLauncherTestUtils.launchJob();
|
||||
|
||||
@@ -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.
|
||||
@@ -17,23 +17,20 @@
|
||||
package org.springframework.batch.sample;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
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.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(
|
||||
@SpringJUnitConfig(
|
||||
locations = { "/simple-job-launcher-context.xml", "/jobs/multilineJob.xml", "/job-runner-context.xml" })
|
||||
public class MultilineJobFunctionalTests {
|
||||
class MultilineJobFunctionalTests {
|
||||
|
||||
@Autowired
|
||||
private JobLauncherTestUtils jobLauncherTestUtils;
|
||||
@@ -43,10 +40,10 @@ public class MultilineJobFunctionalTests {
|
||||
private static final String EXPECTED_RESULT = "[Trade: [isin=UK21341EAH45,quantity=978,price=98.34,customer=customer1], Trade: [isin=UK21341EAH46,quantity=112,price=18.12,customer=customer2]]"
|
||||
+ "[Trade: [isin=UK21341EAH47,quantity=245,price=12.78,customer=customer2], Trade: [isin=UK21341EAH48,quantity=108,price=9.25,customer=customer3], Trade: [isin=UK21341EAH49,quantity=854,price=23.39,customer=customer4]]";
|
||||
|
||||
private Resource output = new FileSystemResource("target/test-outputs/20070122.testStream.multilineStep.txt");
|
||||
private final Resource output = new FileSystemResource("target/test-outputs/20070122.testStream.multilineStep.txt");
|
||||
|
||||
@Test
|
||||
public void testJobLaunch() throws Exception {
|
||||
void testJobLaunch() throws Exception {
|
||||
jobLauncherTestUtils.launchJob();
|
||||
assertEquals(EXPECTED_RESULT, StringUtils.replace(IOUtils.toString(output.getInputStream(), "UTF-8"),
|
||||
System.getProperty("line.separator"), ""));
|
||||
|
||||
@@ -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.
|
||||
@@ -18,19 +18,16 @@ package org.springframework.batch.sample;
|
||||
|
||||
import static org.springframework.batch.test.AssertFile.assertFileEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
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.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(
|
||||
@SpringJUnitConfig(
|
||||
locations = { "/simple-job-launcher-context.xml", "/jobs/multilineOrderJob.xml", "/job-runner-context.xml" })
|
||||
public class MultilineOrderJobFunctionalTests {
|
||||
class MultilineOrderJobFunctionalTests {
|
||||
|
||||
private static final String ACTUAL = "target/test-outputs/multilineOrderOutput.txt";
|
||||
|
||||
@@ -40,7 +37,7 @@ public class MultilineOrderJobFunctionalTests {
|
||||
private JobLauncherTestUtils jobLauncherTestUtils;
|
||||
|
||||
@Test
|
||||
public void testJobLaunch() throws Exception {
|
||||
void testJobLaunch() throws Exception {
|
||||
jobLauncherTestUtils.launchJob();
|
||||
assertFileEquals(new ClassPathResource(EXPECTED), new FileSystemResource(ACTUAL));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2012 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,25 +16,22 @@
|
||||
|
||||
package org.springframework.batch.sample;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
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.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(
|
||||
@SpringJUnitConfig(
|
||||
locations = { "/simple-job-launcher-context.xml", "/jobs/parallelJob.xml", "/job-runner-context.xml" })
|
||||
public class ParallelJobFunctionalTests {
|
||||
class ParallelJobFunctionalTests {
|
||||
|
||||
@Autowired
|
||||
private JobLauncherTestUtils jobLauncherTestUtils;
|
||||
@@ -47,7 +44,7 @@ public class ParallelJobFunctionalTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLaunchJob() throws Exception {
|
||||
void testLaunchJob() throws Exception {
|
||||
int before = JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_STAGING");
|
||||
JobExecution execution = jobLauncherTestUtils.launchJob();
|
||||
int after = JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_STAGING");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2014 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,16 +16,15 @@
|
||||
|
||||
package org.springframework.batch.sample;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
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.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
@@ -39,13 +38,11 @@ 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.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(
|
||||
@SpringJUnitConfig(
|
||||
locations = { "/simple-job-launcher-context.xml", "/jobs/partitionFileJob.xml", "/job-runner-context.xml" })
|
||||
public class PartitionFileJobFunctionalTests implements ApplicationContextAware {
|
||||
class PartitionFileJobFunctionalTests implements ApplicationContextAware {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("inputTestReader")
|
||||
@@ -65,9 +62,9 @@ public class PartitionFileJobFunctionalTests implements ApplicationContextAware
|
||||
* Check the resulting credits correspond to inputs increased by fixed amount.
|
||||
*/
|
||||
@Test
|
||||
public void testUpdateCredit() throws Exception {
|
||||
assertTrue("Define a prototype bean called 'outputTestReader' to check the output",
|
||||
applicationContext.containsBeanDefinition("outputTestReader"));
|
||||
void testUpdateCredit() throws Exception {
|
||||
assertTrue(applicationContext.containsBeanDefinition("outputTestReader"),
|
||||
"Define a prototype bean called 'outputTestReader' to check the output");
|
||||
|
||||
open(inputReader);
|
||||
List<CustomerCredit> inputs = new ArrayList<>(getCredits(inputReader));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2014 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,16 +16,15 @@
|
||||
|
||||
package org.springframework.batch.sample;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
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.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
@@ -39,13 +38,11 @@ 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.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(
|
||||
@SpringJUnitConfig(
|
||||
locations = { "/simple-job-launcher-context.xml", "/jobs/partitionJdbcJob.xml", "/job-runner-context.xml" })
|
||||
public class PartitionJdbcJobFunctionalTests implements ApplicationContextAware {
|
||||
class PartitionJdbcJobFunctionalTests implements ApplicationContextAware {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("inputTestReader")
|
||||
@@ -65,9 +62,9 @@ public class PartitionJdbcJobFunctionalTests implements ApplicationContextAware
|
||||
* Check the resulting credits correspond to inputs increased by fixed amount.
|
||||
*/
|
||||
@Test
|
||||
public void testUpdateCredit() throws Exception {
|
||||
assertTrue("Define a prototype bean called 'outputTestReader' to check the output",
|
||||
applicationContext.containsBeanDefinition("outputTestReader"));
|
||||
void testUpdateCredit() throws Exception {
|
||||
assertTrue(applicationContext.containsBeanDefinition("outputTestReader"),
|
||||
"Define a prototype bean called 'outputTestReader' to check the output");
|
||||
|
||||
open(inputReader);
|
||||
List<CustomerCredit> inputs = new ArrayList<>(getCredits(inputReader));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2021 the original author or authors.
|
||||
* Copyright 2018-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.
|
||||
@@ -18,12 +18,9 @@ package org.springframework.batch.sample;
|
||||
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.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
@@ -32,11 +29,11 @@ import org.springframework.batch.sample.remotechunking.ManagerConfiguration;
|
||||
import org.springframework.batch.sample.remotechunking.WorkerConfiguration;
|
||||
import org.springframework.batch.test.JobLauncherTestUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* The manager step of the job under test will read data and send chunks to the worker
|
||||
@@ -45,22 +42,19 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
*
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration(classes = { JobRunnerConfiguration.class, ManagerConfiguration.class })
|
||||
@SpringJUnitConfig(classes = { JobRunnerConfiguration.class, ManagerConfiguration.class })
|
||||
@PropertySource("classpath:remote-chunking.properties")
|
||||
public class RemoteChunkingJobFunctionalTests {
|
||||
|
||||
private static final String BROKER_DATA_DIRECTORY = "target/activemq-data";
|
||||
class RemoteChunkingJobFunctionalTests {
|
||||
|
||||
@Autowired
|
||||
private JobLauncherTestUtils jobLauncherTestUtils;
|
||||
|
||||
private static EmbeddedActiveMQ brokerService;
|
||||
private EmbeddedActiveMQ brokerService;
|
||||
|
||||
private AnnotationConfigApplicationContext workerApplicationContext;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
@BeforeEach
|
||||
void setUp() throws Exception {
|
||||
Configuration configuration = new ConfigurationImpl().addAcceptorConfiguration("jms", "tcp://localhost:61616")
|
||||
.setPersistenceEnabled(false).setSecurityEnabled(false).setJMXManagementEnabled(false)
|
||||
.setJournalDatasync(false);
|
||||
@@ -68,21 +62,21 @@ public class RemoteChunkingJobFunctionalTests {
|
||||
this.workerApplicationContext = new AnnotationConfigApplicationContext(WorkerConfiguration.class);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
@AfterEach
|
||||
void tearDown() throws Exception {
|
||||
this.workerApplicationContext.close();
|
||||
this.brokerService.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoteChunkingJob() throws Exception {
|
||||
void testRemoteChunkingJob() throws Exception {
|
||||
// when
|
||||
JobExecution jobExecution = this.jobLauncherTestUtils.launchJob();
|
||||
|
||||
// then
|
||||
Assert.assertEquals(ExitStatus.COMPLETED.getExitCode(), jobExecution.getExitStatus().getExitCode());
|
||||
Assert.assertEquals("Waited for 2 results.", // the manager sent 2 chunks ({1, 2,
|
||||
// 3} and {4, 5, 6}) to workers
|
||||
assertEquals(ExitStatus.COMPLETED.getExitCode(), jobExecution.getExitStatus().getExitCode());
|
||||
assertEquals("Waited for 2 results.", // the manager sent 2 chunks ({1, 2,
|
||||
// 3} and {4, 5, 6}) to workers
|
||||
jobExecution.getExitStatus().getExitDescription());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2021 the original author or authors.
|
||||
* Copyright 2018-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.
|
||||
@@ -20,11 +20,9 @@ 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.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
@@ -35,14 +33,14 @@ 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.junit4.SpringRunner;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* Base class for remote partitioning tests.
|
||||
*
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@PropertySource("classpath:remote-partitioning.properties")
|
||||
public abstract class RemotePartitioningJobFunctionalTests {
|
||||
|
||||
@@ -63,8 +61,8 @@ public abstract class RemotePartitioningJobFunctionalTests {
|
||||
|
||||
protected abstract Class<?> getWorkerConfigurationClass();
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
@BeforeEach
|
||||
void setUp() throws Exception {
|
||||
Configuration configuration = new ConfigurationImpl().addAcceptorConfiguration("jms", "tcp://localhost:61617")
|
||||
.setPersistenceEnabled(false).setSecurityEnabled(false).setJMXManagementEnabled(false)
|
||||
.setJournalDatasync(false);
|
||||
@@ -77,18 +75,18 @@ public abstract class RemotePartitioningJobFunctionalTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemotePartitioningJob() throws Exception {
|
||||
void testRemotePartitioningJob() throws Exception {
|
||||
// when
|
||||
JobExecution jobExecution = this.jobLauncherTestUtils.launchJob();
|
||||
|
||||
// then
|
||||
Assert.assertEquals(ExitStatus.COMPLETED.getExitCode(), jobExecution.getExitStatus().getExitCode());
|
||||
Assert.assertEquals(4, jobExecution.getStepExecutions().size()); // manager + 3
|
||||
// workers
|
||||
assertEquals(ExitStatus.COMPLETED.getExitCode(), jobExecution.getExitStatus().getExitCode());
|
||||
assertEquals(4, jobExecution.getStepExecutions().size()); // manager + 3
|
||||
// workers
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
@AfterEach
|
||||
void tearDown() throws Exception {
|
||||
this.workerApplicationContext.close();
|
||||
this.brokerService.stop();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2019 the original author or authors.
|
||||
* Copyright 2018-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.
|
||||
@@ -18,15 +18,15 @@ package org.springframework.batch.sample;
|
||||
import org.springframework.batch.sample.config.JobRunnerConfiguration;
|
||||
import org.springframework.batch.sample.remotepartitioning.aggregating.ManagerConfiguration;
|
||||
import org.springframework.batch.sample.remotepartitioning.aggregating.WorkerConfiguration;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
* The manager step of the job under test will create 3 partitions for workers to process.
|
||||
*
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
@ContextConfiguration(classes = { JobRunnerConfiguration.class, ManagerConfiguration.class })
|
||||
public class RemotePartitioningJobWithMessageAggregationFunctionalTests extends RemotePartitioningJobFunctionalTests {
|
||||
@SpringJUnitConfig(classes = { JobRunnerConfiguration.class, ManagerConfiguration.class })
|
||||
class RemotePartitioningJobWithMessageAggregationFunctionalTests extends RemotePartitioningJobFunctionalTests {
|
||||
|
||||
@Override
|
||||
protected Class<WorkerConfiguration> getWorkerConfigurationClass() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2019 the original author or authors.
|
||||
* Copyright 2018-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.
|
||||
@@ -18,15 +18,15 @@ package org.springframework.batch.sample;
|
||||
import org.springframework.batch.sample.config.JobRunnerConfiguration;
|
||||
import org.springframework.batch.sample.remotepartitioning.polling.ManagerConfiguration;
|
||||
import org.springframework.batch.sample.remotepartitioning.polling.WorkerConfiguration;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
* The manager step of the job under test will create 3 partitions for workers to process.
|
||||
*
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
@ContextConfiguration(classes = { JobRunnerConfiguration.class, ManagerConfiguration.class })
|
||||
public class RemotePartitioningJobWithRepositoryPollingFunctionalTests extends RemotePartitioningJobFunctionalTests {
|
||||
@SpringJUnitConfig(classes = { JobRunnerConfiguration.class, ManagerConfiguration.class })
|
||||
class RemotePartitioningJobWithRepositoryPollingFunctionalTests extends RemotePartitioningJobFunctionalTests {
|
||||
|
||||
@Override
|
||||
protected Class<WorkerConfiguration> getWorkerConfigurationClass() {
|
||||
|
||||
@@ -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,12 +16,11 @@
|
||||
|
||||
package org.springframework.batch.sample;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
@@ -31,17 +30,15 @@ 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.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
* @author Dan Garrette
|
||||
* @since 2.0
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(
|
||||
@SpringJUnitConfig(
|
||||
locations = { "/simple-job-launcher-context.xml", "/jobs/restartFileSampleJob.xml", "/job-runner-context.xml" })
|
||||
public class RestartFileSampleFunctionalTests {
|
||||
class RestartFileSampleFunctionalTests {
|
||||
|
||||
@Autowired
|
||||
private Resource outputResource;
|
||||
@@ -50,7 +47,7 @@ public class RestartFileSampleFunctionalTests {
|
||||
private JobLauncherTestUtils jobLauncherTestUtils;
|
||||
|
||||
@Test
|
||||
public void runTest() throws Exception {
|
||||
void runTest() throws Exception {
|
||||
JobParameters jobParameters = jobLauncherTestUtils.getUniqueJobParameters();
|
||||
|
||||
JobExecution je1 = jobLauncherTestUtils.launchJob(jobParameters);
|
||||
@@ -62,7 +59,7 @@ public class RestartFileSampleFunctionalTests {
|
||||
AssertFile.assertLineCount(20, outputResource);
|
||||
}
|
||||
|
||||
public static class CustomerCreditFlatFileItemWriter extends FlatFileItemWriter<CustomerCredit> {
|
||||
static class CustomerCreditFlatFileItemWriter extends FlatFileItemWriter<CustomerCredit> {
|
||||
|
||||
private boolean failed = false;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2021 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,12 +16,12 @@
|
||||
|
||||
package org.springframework.batch.sample;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.converter.DefaultJobParametersConverter;
|
||||
@@ -29,8 +29,7 @@ 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.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.test.context.transaction.BeforeTransaction;
|
||||
import org.springframework.test.jdbc.JdbcTestUtils;
|
||||
|
||||
@@ -41,10 +40,9 @@ import org.springframework.test.jdbc.JdbcTestUtils;
|
||||
* @author Dave Syer
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(
|
||||
@SpringJUnitConfig(
|
||||
locations = { "/simple-job-launcher-context.xml", "/jobs/restartSample.xml", "/job-runner-context.xml" })
|
||||
public class RestartFunctionalTests {
|
||||
class RestartFunctionalTests {
|
||||
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
@@ -57,7 +55,7 @@ public class RestartFunctionalTests {
|
||||
}
|
||||
|
||||
@BeforeTransaction
|
||||
public void onTearDown() throws Exception {
|
||||
void onTearDown() {
|
||||
JdbcTestUtils.deleteFromTables(jdbcTemplate, "TRADE");
|
||||
}
|
||||
|
||||
@@ -69,19 +67,14 @@ public class RestartFunctionalTests {
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testLaunchJob() throws Exception {
|
||||
void testLaunchJob() throws Exception {
|
||||
int before = JdbcTestUtils.countRowsInTable(jdbcTemplate, "TRADE");
|
||||
|
||||
JobExecution jobExecution = runJobForRestartTest();
|
||||
assertEquals(BatchStatus.FAILED, jobExecution.getStatus());
|
||||
|
||||
Throwable ex = jobExecution.getAllFailureExceptions().get(0);
|
||||
if (ex.getMessage().toLowerCase().indexOf("planned") < 0) {
|
||||
if (ex instanceof Exception) {
|
||||
throw (Exception) ex;
|
||||
}
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
assertTrue(ex.getMessage().toLowerCase().contains("planned"));
|
||||
|
||||
int medium = JdbcTestUtils.countRowsInTable(jdbcTemplate, "TRADE");
|
||||
// assert based on commit interval = 2
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012 the original author or authors.
|
||||
* Copyright 2012-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.
|
||||
@@ -15,10 +15,9 @@
|
||||
*/
|
||||
package org.springframework.batch.sample;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.sample.config.DataSourceConfiguration;
|
||||
import org.springframework.batch.sample.config.JobRunnerConfiguration;
|
||||
import org.springframework.batch.sample.config.RetrySampleConfiguration;
|
||||
@@ -26,8 +25,7 @@ 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.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
* Checks that expected number of items have been processed.
|
||||
@@ -35,10 +33,9 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
* @author Robert Kasanicky
|
||||
* @author Dave Syer
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(
|
||||
@SpringJUnitConfig(
|
||||
classes = { DataSourceConfiguration.class, RetrySampleConfiguration.class, JobRunnerConfiguration.class })
|
||||
public class RetrySampleConfigurationTests {
|
||||
class RetrySampleConfigurationTests {
|
||||
|
||||
@Autowired
|
||||
private GeneratingTradeItemReader itemGenerator;
|
||||
@@ -50,7 +47,7 @@ public class RetrySampleConfigurationTests {
|
||||
private JobLauncherTestUtils jobLauncherTestUtils;
|
||||
|
||||
@Test
|
||||
public void testLaunchJob() throws Exception {
|
||||
void testLaunchJob() throws Exception {
|
||||
jobLauncherTestUtils.launchJob();
|
||||
// items processed = items read + 2 exceptions
|
||||
assertEquals(itemGenerator.getLimit() + 2, itemProcessor.getCounter());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2009 the original author or authors.
|
||||
* Copyright 2008-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.
|
||||
@@ -15,26 +15,23 @@
|
||||
*/
|
||||
package org.springframework.batch.sample;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
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.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
* Checks that expected number of items have been processed.
|
||||
*
|
||||
* @author Robert Kasanicky
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(
|
||||
@SpringJUnitConfig(
|
||||
locations = { "/simple-job-launcher-context.xml", "/jobs/retrySample.xml", "/job-runner-context.xml" })
|
||||
public class RetrySampleFunctionalTests {
|
||||
class RetrySampleFunctionalTests {
|
||||
|
||||
@Autowired
|
||||
private GeneratingTradeItemReader itemGenerator;
|
||||
@@ -46,7 +43,7 @@ public class RetrySampleFunctionalTests {
|
||||
private JobLauncherTestUtils jobLauncherTestUtils;
|
||||
|
||||
@Test
|
||||
public void testLaunchJob() throws Exception {
|
||||
void testLaunchJob() throws Exception {
|
||||
jobLauncherTestUtils.launchJob();
|
||||
// items processed = items read + 2 exceptions
|
||||
assertEquals(itemGenerator.getLimit() + 2, itemProcessor.getCounter());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2021 the original author or authors.
|
||||
* Copyright 2008-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.
|
||||
@@ -15,17 +15,18 @@
|
||||
*/
|
||||
package org.springframework.batch.sample;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
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.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
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;
|
||||
@@ -54,8 +55,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
* Error is encountered during writing - transaction is rolled back and the error item is
|
||||
@@ -65,9 +65,8 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
* @author Dan Garrette
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { "/skipSample-job-launcher-context.xml" })
|
||||
public class SkipSampleFunctionalTests {
|
||||
@SpringJUnitConfig(locations = { "/skipSample-job-launcher-context.xml" })
|
||||
class SkipSampleFunctionalTests {
|
||||
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
@@ -86,8 +85,8 @@ public class SkipSampleFunctionalTests {
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
JdbcTestUtils.deleteFromTables(jdbcTemplate, "TRADE", "CUSTOMER");
|
||||
for (int i = 1; i < 10; i++) {
|
||||
jdbcTemplate.update("INSERT INTO CUSTOMER (ID, VERSION, NAME, CREDIT) VALUES (" + incrementer.nextIntValue()
|
||||
@@ -155,7 +154,7 @@ public class SkipSampleFunctionalTests {
|
||||
* </ul>
|
||||
*/
|
||||
@Test
|
||||
public void testJobIncrementing() {
|
||||
void testJobIncrementing() {
|
||||
//
|
||||
// Launch 1
|
||||
//
|
||||
@@ -184,7 +183,7 @@ public class SkipSampleFunctionalTests {
|
||||
// instances
|
||||
//
|
||||
assertTrue(id1 != id2);
|
||||
assertTrue(!execution1.getJobId().equals(execution2.getJobId()));
|
||||
assertNotEquals(execution1.getJobId(), execution2.getJobId());
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -193,7 +192,7 @@ public class SkipSampleFunctionalTests {
|
||||
* written).
|
||||
*/
|
||||
@Test
|
||||
public void testSkippableExceptionDuringRead() throws Exception {
|
||||
void testSkippableExceptionDuringRead() throws Exception {
|
||||
// given
|
||||
ApplicationContext context = new AnnotationConfigApplicationContext(SkippableExceptionDuringReadSample.class);
|
||||
JobLauncher jobLauncher = context.getBean(JobLauncher.class);
|
||||
@@ -216,7 +215,7 @@ public class SkipSampleFunctionalTests {
|
||||
* the writer).
|
||||
*/
|
||||
@Test
|
||||
public void testSkippableExceptionDuringProcess() throws Exception {
|
||||
void testSkippableExceptionDuringProcess() throws Exception {
|
||||
// given
|
||||
ApplicationContext context = new AnnotationConfigApplicationContext(
|
||||
SkippableExceptionDuringProcessSample.class);
|
||||
@@ -242,7 +241,7 @@ public class SkipSampleFunctionalTests {
|
||||
* re-processed/re-written in its own transaction).
|
||||
*/
|
||||
@Test
|
||||
public void testSkippableExceptionDuringWrite() throws Exception {
|
||||
void testSkippableExceptionDuringWrite() throws Exception {
|
||||
// given
|
||||
ApplicationContext context = new AnnotationConfigApplicationContext(SkippableExceptionDuringWriteSample.class);
|
||||
JobLauncher jobLauncher = context.getBean(JobLauncher.class);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2018 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,36 +16,33 @@
|
||||
|
||||
package org.springframework.batch.sample;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
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.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(
|
||||
@SpringJUnitConfig(
|
||||
locations = { "/simple-job-launcher-context.xml", "/jobs/taskletJob.xml", "/job-runner-context.xml" })
|
||||
public class TaskletJobFunctionalTests {
|
||||
class TaskletJobFunctionalTests {
|
||||
|
||||
@Autowired
|
||||
private JobLauncherTestUtils jobLauncherTestUtils;
|
||||
|
||||
@Test
|
||||
public void testLaunchJob() throws Exception {
|
||||
void testLaunchJob() throws Exception {
|
||||
JobExecution jobExecution = jobLauncherTestUtils
|
||||
.launchJob(new JobParametersBuilder().addString("value", "foo").toJobParameters());
|
||||
assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
|
||||
assertEquals("yes", jobExecution.getExecutionContext().getString("done"));
|
||||
}
|
||||
|
||||
public static class TestBean {
|
||||
static class TestBean {
|
||||
|
||||
private String value;
|
||||
|
||||
@@ -62,7 +59,7 @@ public class TaskletJobFunctionalTests {
|
||||
|
||||
}
|
||||
|
||||
public static class Task {
|
||||
static class Task {
|
||||
|
||||
public boolean doWork(ChunkContext chunkContext) {
|
||||
chunkContext.getStepContext().getStepExecution().getJobExecution().getExecutionContext().put("done", "yes");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2021 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,8 +16,8 @@
|
||||
|
||||
package org.springframework.batch.sample;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
@@ -29,23 +29,19 @@ import java.util.Map;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
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.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.test.jdbc.JdbcTestUtils;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(
|
||||
locations = { "/simple-job-launcher-context.xml", "/jobs/tradeJob.xml", "/job-runner-context.xml" })
|
||||
public class TradeJobFunctionalTests {
|
||||
@SpringJUnitConfig(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";
|
||||
|
||||
@@ -59,7 +55,7 @@ public class TradeJobFunctionalTests {
|
||||
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
private Map<String, Double> credits = new HashMap<>();
|
||||
private final Map<String, Double> credits = new HashMap<>();
|
||||
|
||||
@Autowired
|
||||
private JobLauncherTestUtils jobLauncherTestUtils;
|
||||
@@ -69,8 +65,8 @@ public class TradeJobFunctionalTests {
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void onSetUp() throws Exception {
|
||||
@BeforeEach
|
||||
void onSetUp() {
|
||||
JdbcTestUtils.deleteFromTables(jdbcTemplate, "TRADE");
|
||||
List<Map<String, Object>> list = jdbcTemplate.queryForList("select NAME, CREDIT from CUSTOMER");
|
||||
|
||||
@@ -79,13 +75,13 @@ public class TradeJobFunctionalTests {
|
||||
}
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
@AfterEach
|
||||
void tearDown() {
|
||||
JdbcTestUtils.deleteFromTables(jdbcTemplate, "TRADE");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLaunchJob() throws Exception {
|
||||
void testLaunchJob() throws Exception {
|
||||
jobLauncherTestUtils.launchJob();
|
||||
|
||||
customers = Arrays.asList(new Customer("customer1", (credits.get("customer1") - 98.34)),
|
||||
@@ -104,10 +100,10 @@ public class TradeJobFunctionalTests {
|
||||
public void processRow(ResultSet rs) throws SQLException {
|
||||
Trade trade = trades.get(activeRow++);
|
||||
|
||||
assertTrue(trade.getIsin().equals(rs.getString(1)));
|
||||
assertTrue(trade.getQuantity() == rs.getLong(2));
|
||||
assertTrue(trade.getPrice().equals(rs.getBigDecimal(3)));
|
||||
assertTrue(trade.getCustomer().equals(rs.getString(4)));
|
||||
assertEquals(trade.getIsin(), rs.getString(1));
|
||||
assertEquals(trade.getQuantity(), rs.getLong(2));
|
||||
assertEquals(trade.getPrice(), rs.getBigDecimal(3));
|
||||
assertEquals(trade.getCustomer(), rs.getString(4));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2009 the original author or authors.
|
||||
* Copyright 2009-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.
|
||||
@@ -15,34 +15,27 @@
|
||||
*/
|
||||
package org.springframework.batch.sample.common;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration
|
||||
public class ColumnRangePartitionerTests {
|
||||
|
||||
private DataSource dataSource;
|
||||
@SpringJUnitConfig
|
||||
class ColumnRangePartitionerTests {
|
||||
|
||||
@Autowired
|
||||
public void setDataSource(DataSource dataSource) {
|
||||
this.dataSource = dataSource;
|
||||
}
|
||||
private DataSource dataSource;
|
||||
|
||||
private ColumnRangePartitioner partitioner = new ColumnRangePartitioner();
|
||||
private final ColumnRangePartitioner partitioner = new ColumnRangePartitioner();
|
||||
|
||||
@Test
|
||||
public void testPartition() {
|
||||
void testPartition() {
|
||||
partitioner.setDataSource(dataSource);
|
||||
partitioner.setTable("CUSTOMER");
|
||||
partitioner.setColumn("ID");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2019 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.
|
||||
@@ -15,14 +15,14 @@
|
||||
*/
|
||||
package org.springframework.batch.sample.common;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
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.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.batch.item.ItemStream;
|
||||
@@ -37,17 +37,12 @@ import org.springframework.lang.Nullable;
|
||||
* @author Lucas Ward
|
||||
*
|
||||
*/
|
||||
public class CustomItemReaderTests {
|
||||
class CustomItemReaderTests {
|
||||
|
||||
private ItemReader<String> itemReader;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see junit.framework.TestCase#setUp()
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
List<String> items = new ArrayList<>();
|
||||
items.add("1");
|
||||
items.add("2");
|
||||
@@ -57,7 +52,7 @@ public class CustomItemReaderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRead() throws Exception {
|
||||
void testRead() throws Exception {
|
||||
assertEquals("1", itemReader.read());
|
||||
assertEquals("2", itemReader.read());
|
||||
assertEquals("3", itemReader.read());
|
||||
@@ -65,7 +60,7 @@ public class CustomItemReaderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRestart() throws Exception {
|
||||
void testRestart() throws Exception {
|
||||
ExecutionContext executionContext = new ExecutionContext();
|
||||
((ItemStream) itemReader).open(executionContext);
|
||||
assertEquals("1", itemReader.read());
|
||||
@@ -80,7 +75,7 @@ public class CustomItemReaderTests {
|
||||
assertEquals("2", itemReader.read());
|
||||
}
|
||||
|
||||
public static class CustomItemReader<T> implements ItemReader<T>, ItemStream {
|
||||
static class CustomItemReader<T> implements ItemReader<T>, ItemStream {
|
||||
|
||||
private static final String CURRENT_INDEX = "current.index";
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2014 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.
|
||||
@@ -15,13 +15,13 @@
|
||||
*/
|
||||
package org.springframework.batch.sample.common;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.item.ItemWriter;
|
||||
import org.springframework.batch.support.transaction.TransactionAwareProxyFactory;
|
||||
|
||||
@@ -33,10 +33,10 @@ import org.springframework.batch.support.transaction.TransactionAwareProxyFactor
|
||||
* @author Lucas Ward
|
||||
*
|
||||
*/
|
||||
public class CustomItemWriterTests {
|
||||
class CustomItemWriterTests {
|
||||
|
||||
@Test
|
||||
public void testFlush() throws Exception {
|
||||
void testFlush() throws Exception {
|
||||
CustomItemWriter<String> itemWriter = new CustomItemWriter<>();
|
||||
itemWriter.write(Collections.singletonList("1"));
|
||||
assertEquals(1, itemWriter.getOutput().size());
|
||||
@@ -44,7 +44,7 @@ public class CustomItemWriterTests {
|
||||
assertEquals(3, itemWriter.getOutput().size());
|
||||
}
|
||||
|
||||
public static class CustomItemWriter<T> implements ItemWriter<T> {
|
||||
static class CustomItemWriter<T> implements ItemWriter<T> {
|
||||
|
||||
private List<T> output = TransactionAwareProxyFactory.createTransactionalList();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2014 the original author or authors.
|
||||
* Copyright 2008-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.
|
||||
@@ -15,47 +15,36 @@
|
||||
*/
|
||||
package org.springframework.batch.sample.common;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
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 org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.core.UnexpectedJobExecutionException;
|
||||
import org.springframework.batch.item.support.ListItemReader;
|
||||
import org.springframework.batch.repeat.context.RepeatContextSupport;
|
||||
import org.springframework.batch.repeat.support.RepeatSynchronizationManager;
|
||||
import org.springframework.batch.sample.support.ExceptionThrowingItemReaderProxy;
|
||||
|
||||
public class ExceptionThrowingItemReaderProxyTests {
|
||||
class ExceptionThrowingItemReaderProxyTests {
|
||||
|
||||
// expected call count before exception is thrown (exception should be thrown in next
|
||||
// iteration)
|
||||
private static final int ITER_COUNT = 5;
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
@AfterEach
|
||||
void tearDown() {
|
||||
RepeatSynchronizationManager.clear();
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Test
|
||||
public void testProcess() throws Exception {
|
||||
void testProcess() throws Exception {
|
||||
|
||||
// create module and set item processor and iteration count
|
||||
ExceptionThrowingItemReaderProxy<String> itemReader = new ExceptionThrowingItemReaderProxy<>();
|
||||
itemReader.setDelegate(new ListItemReader<>(new ArrayList<String>() {
|
||||
{
|
||||
add("a");
|
||||
add("b");
|
||||
add("c");
|
||||
add("d");
|
||||
add("e");
|
||||
add("f");
|
||||
}
|
||||
}));
|
||||
|
||||
itemReader.setDelegate(new ListItemReader<>(List.of("a", "b", "c", "d", "e", "f")));
|
||||
itemReader.setThrowExceptionOnRecordNumber(ITER_COUNT + 1);
|
||||
|
||||
RepeatSynchronizationManager.register(new RepeatContextSupport(null));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2009 the original author or authors.
|
||||
* Copyright 2009-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.
|
||||
@@ -15,33 +15,33 @@
|
||||
*/
|
||||
package org.springframework.batch.sample.common;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class OutputFileListenerTests {
|
||||
class OutputFileListenerTests {
|
||||
|
||||
private OutputFileListener listener = new OutputFileListener();
|
||||
private final OutputFileListener listener = new OutputFileListener();
|
||||
|
||||
private StepExecution stepExecution = new StepExecution("foo", new JobExecution(0L), 1L);
|
||||
private final StepExecution stepExecution = new StepExecution("foo", new JobExecution(0L), 1L);
|
||||
|
||||
@Test
|
||||
public void testCreateOutputNameFromInput() {
|
||||
void testCreateOutputNameFromInput() {
|
||||
listener.createOutputNameFromInput(stepExecution);
|
||||
assertEquals("{outputFile=file:./target/output/foo.csv}", stepExecution.getExecutionContext().toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetPath() {
|
||||
void testSetPath() {
|
||||
listener.setPath("spam/");
|
||||
listener.createOutputNameFromInput(stepExecution);
|
||||
assertEquals("{outputFile=spam/foo.csv}", stepExecution.getExecutionContext().toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetOutputKeyName() {
|
||||
void testSetOutputKeyName() {
|
||||
listener.setPath("");
|
||||
listener.setOutputKeyName("spam");
|
||||
listener.createOutputNameFromInput(stepExecution);
|
||||
@@ -49,7 +49,7 @@ public class OutputFileListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetInputKeyName() {
|
||||
void testSetInputKeyName() {
|
||||
listener.setPath("");
|
||||
listener.setInputKeyName("spam");
|
||||
stepExecution.getExecutionContext().putString("spam", "bar");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2021 the original author or authors.
|
||||
* Copyright 2008-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.
|
||||
@@ -15,23 +15,21 @@
|
||||
*/
|
||||
package org.springframework.batch.sample.common;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
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.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobInstance;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.test.context.transaction.AfterTransaction;
|
||||
import org.springframework.test.context.transaction.BeforeTransaction;
|
||||
import org.springframework.test.jdbc.JdbcTestUtils;
|
||||
@@ -42,9 +40,8 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.support.TransactionCallback;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration()
|
||||
public class StagingItemReaderTests {
|
||||
@SpringJUnitConfig
|
||||
class StagingItemReaderTests {
|
||||
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
@@ -57,7 +54,7 @@ public class StagingItemReaderTests {
|
||||
@Autowired
|
||||
private StagingItemReader<String> reader;
|
||||
|
||||
private Long jobId = 113L;
|
||||
private final Long jobId = 113L;
|
||||
|
||||
@Autowired
|
||||
public void setDataSource(DataSource dataSource) {
|
||||
@@ -65,7 +62,7 @@ public class StagingItemReaderTests {
|
||||
}
|
||||
|
||||
@BeforeTransaction
|
||||
public void onSetUpBeforeTransaction() throws Exception {
|
||||
void onSetUpBeforeTransaction() {
|
||||
StepExecution stepExecution = new StepExecution("stepName",
|
||||
new JobExecution(new JobInstance(jobId, "testJob"), new JobParameters()));
|
||||
writer.beforeStep(stepExecution);
|
||||
@@ -74,14 +71,14 @@ public class StagingItemReaderTests {
|
||||
}
|
||||
|
||||
@AfterTransaction
|
||||
public void onTearDownAfterTransaction() throws Exception {
|
||||
void onTearDownAfterTransaction() throws Exception {
|
||||
reader.destroy();
|
||||
JdbcTestUtils.deleteFromTables(jdbcTemplate, "BATCH_STAGING");
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Test
|
||||
public void testReaderWithProcessorUpdatesProcessIndicator() throws Exception {
|
||||
void testReaderWithProcessorUpdatesProcessIndicator() throws Exception {
|
||||
long id = jdbcTemplate.queryForObject("SELECT MIN(ID) from BATCH_STAGING where JOB_ID=?", Long.class, jobId);
|
||||
String before = jdbcTemplate.queryForObject("SELECT PROCESSED from BATCH_STAGING where ID=?", String.class, id);
|
||||
assertEquals(StagingItemWriter.NEW, before);
|
||||
@@ -100,7 +97,7 @@ public class StagingItemReaderTests {
|
||||
|
||||
@Transactional
|
||||
@Test
|
||||
public void testUpdateProcessIndicatorAfterCommit() throws Exception {
|
||||
void testUpdateProcessIndicatorAfterCommit() {
|
||||
TransactionTemplate txTemplate = new TransactionTemplate(transactionManager);
|
||||
txTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
|
||||
txTemplate.execute(new TransactionCallback<Void>() {
|
||||
@@ -122,7 +119,7 @@ public class StagingItemReaderTests {
|
||||
|
||||
@Transactional
|
||||
@Test
|
||||
public void testReaderRollsBackProcessIndicator() throws Exception {
|
||||
void testReaderRollsBackProcessIndicator() {
|
||||
TransactionTemplate txTemplate = new TransactionTemplate(transactionManager);
|
||||
txTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2021 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.
|
||||
@@ -15,29 +15,26 @@
|
||||
*/
|
||||
package org.springframework.batch.sample.common;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobInstance;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.test.jdbc.JdbcTestUtils;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration
|
||||
public class StagingItemWriterTests {
|
||||
@SpringJUnitConfig
|
||||
class StagingItemWriterTests {
|
||||
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
@@ -49,8 +46,8 @@ public class StagingItemWriterTests {
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void onSetUpBeforeTransaction() throws Exception {
|
||||
@BeforeEach
|
||||
void onSetUpBeforeTransaction() {
|
||||
StepExecution stepExecution = new StepExecution("stepName",
|
||||
new JobExecution(new JobInstance(12L, "testJob"), new JobParameters()));
|
||||
writer.beforeStep(stepExecution);
|
||||
@@ -58,7 +55,7 @@ public class StagingItemWriterTests {
|
||||
|
||||
@Transactional
|
||||
@Test
|
||||
public void testProcessInsertsNewItem() throws Exception {
|
||||
void testProcessInsertsNewItem() {
|
||||
int before = JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_STAGING");
|
||||
writer.write(Collections.singletonList("FOO"));
|
||||
int after = JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_STAGING");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2014 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.
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.batch.sample.domain.football.internal;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
@@ -23,30 +23,27 @@ import java.util.Collections;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
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.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* @author Lucas Ward
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { "/data-source-context.xml" })
|
||||
public class JdbcGameDaoIntegrationTests {
|
||||
@SpringJUnitConfig(locations = { "/data-source-context.xml" })
|
||||
class JdbcGameDaoIntegrationTests {
|
||||
|
||||
private JdbcGameDao gameDao;
|
||||
|
||||
private Game game = new Game();
|
||||
private final Game game = new Game();
|
||||
|
||||
private JdbcOperations jdbcTemplate;
|
||||
|
||||
@@ -58,8 +55,8 @@ public class JdbcGameDaoIntegrationTests {
|
||||
gameDao.afterPropertiesSet();
|
||||
}
|
||||
|
||||
@Before
|
||||
public void onSetUpBeforeTransaction() throws Exception {
|
||||
@BeforeEach
|
||||
void onSetUpBeforeTransaction() {
|
||||
game.setId("XXXXX00");
|
||||
game.setYear(1996);
|
||||
game.setTeam("mia");
|
||||
@@ -79,7 +76,7 @@ public class JdbcGameDaoIntegrationTests {
|
||||
|
||||
@Transactional
|
||||
@Test
|
||||
public void testWrite() {
|
||||
void testWrite() {
|
||||
gameDao.write(Collections.singletonList(game));
|
||||
|
||||
Game tempGame = jdbcTemplate.queryForObject("SELECT * FROM GAMES where PLAYER_ID=? AND YEAR_NO=?",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2021 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.
|
||||
@@ -15,22 +15,20 @@
|
||||
*/
|
||||
package org.springframework.batch.sample.domain.football.internal;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
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.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.test.jdbc.JdbcTestUtils;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -39,9 +37,8 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { "/data-source-context.xml" })
|
||||
public class JdbcPlayerDaoIntegrationTests {
|
||||
@SpringJUnitConfig(locations = { "/data-source-context.xml" })
|
||||
class JdbcPlayerDaoIntegrationTests {
|
||||
|
||||
private JdbcPlayerDao playerDao;
|
||||
|
||||
@@ -66,14 +63,14 @@ public class JdbcPlayerDaoIntegrationTests {
|
||||
player.setDebutYear(1998);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void onSetUpInTransaction() throws Exception {
|
||||
@BeforeEach
|
||||
void onSetUpInTransaction() {
|
||||
JdbcTestUtils.deleteFromTables(jdbcTemplate, "PLAYERS");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
public void testSavePlayer() {
|
||||
void testSavePlayer() {
|
||||
playerDao.savePlayer(player);
|
||||
jdbcTemplate.query(GET_PLAYER, new RowCallbackHandler() {
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2021 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.
|
||||
@@ -15,20 +15,18 @@
|
||||
*/
|
||||
package org.springframework.batch.sample.domain.football.internal;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
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.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.test.jdbc.JdbcTestUtils;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -37,9 +35,8 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { "/data-source-context.xml" })
|
||||
public class JdbcPlayerSummaryDaoIntegrationTests {
|
||||
@SpringJUnitConfig(locations = { "/data-source-context.xml" })
|
||||
class JdbcPlayerSummaryDaoIntegrationTests {
|
||||
|
||||
private JdbcPlayerSummaryDao playerSummaryDao;
|
||||
|
||||
@@ -68,14 +65,14 @@ public class JdbcPlayerSummaryDaoIntegrationTests {
|
||||
summary.setTotalTd(0);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void onSetUpInTransaction() throws Exception {
|
||||
@BeforeEach
|
||||
void onSetUpInTransaction() {
|
||||
JdbcTestUtils.deleteFromTables(jdbcTemplate, "PLAYER_SUMMARY");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
public void testWrite() {
|
||||
void testWrite() {
|
||||
playerSummaryDao.write(Collections.singletonList(summary));
|
||||
|
||||
PlayerSummary testSummary = jdbcTemplate.queryForObject("SELECT * FROM PLAYER_SUMMARY",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2014 the original author or authors.
|
||||
* Copyright 2008-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.
|
||||
@@ -15,57 +15,51 @@
|
||||
*/
|
||||
package org.springframework.batch.sample.domain.multiline;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
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.Test;
|
||||
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;
|
||||
|
||||
public class AggregateItemFieldSetMapperTests {
|
||||
class AggregateItemFieldSetMapperTests {
|
||||
|
||||
private AggregateItemFieldSetMapper<String> mapper = new AggregateItemFieldSetMapper<>();
|
||||
private final AggregateItemFieldSetMapper<String> mapper = new AggregateItemFieldSetMapper<>();
|
||||
|
||||
@Test
|
||||
public void testDefaultBeginRecord() throws Exception {
|
||||
void testDefaultBeginRecord() throws Exception {
|
||||
assertTrue(mapper.mapFieldSet(new DefaultFieldSet(new String[] { "BEGIN" })).isHeader());
|
||||
assertFalse(mapper.mapFieldSet(new DefaultFieldSet(new String[] { "BEGIN" })).isFooter());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetBeginRecord() throws Exception {
|
||||
void testSetBeginRecord() throws Exception {
|
||||
mapper.setBegin("FOO");
|
||||
assertTrue(mapper.mapFieldSet(new DefaultFieldSet(new String[] { "FOO" })).isHeader());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultEndRecord() throws Exception {
|
||||
void testDefaultEndRecord() throws Exception {
|
||||
assertFalse(mapper.mapFieldSet(new DefaultFieldSet(new String[] { "END" })).isHeader());
|
||||
assertTrue(mapper.mapFieldSet(new DefaultFieldSet(new String[] { "END" })).isFooter());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetEndRecord() throws Exception {
|
||||
void testSetEndRecord() throws Exception {
|
||||
mapper.setEnd("FOO");
|
||||
assertTrue(mapper.mapFieldSet(new DefaultFieldSet(new String[] { "FOO" })).isFooter());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMandatoryProperties() throws Exception {
|
||||
try {
|
||||
mapper.afterPropertiesSet();
|
||||
fail("Expected IllegalArgumentException");
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
// expected
|
||||
}
|
||||
void testMandatoryProperties() {
|
||||
assertThrows(IllegalArgumentException.class, mapper::afterPropertiesSet);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDelegate() throws Exception {
|
||||
void testDelegate() throws Exception {
|
||||
mapper.setDelegate(new FieldSetMapper<String>() {
|
||||
@Override
|
||||
public String mapFieldSet(FieldSet fs) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2019 the original author or authors.
|
||||
* Copyright 2008-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.
|
||||
@@ -15,23 +15,21 @@
|
||||
*/
|
||||
package org.springframework.batch.sample.domain.multiline;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
public class AggregateItemReaderTests {
|
||||
|
||||
private ItemReader<AggregateItem<String>> input;
|
||||
class AggregateItemReaderTests {
|
||||
|
||||
private AggregateItemReader<String> provider;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
input = new ItemReader<AggregateItem<String>>() {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
ItemReader<AggregateItem<String>> input = new ItemReader<>() {
|
||||
private int count = 0;
|
||||
|
||||
@Nullable
|
||||
@@ -58,7 +56,7 @@ public class AggregateItemReaderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNext() throws Exception {
|
||||
void testNext() throws Exception {
|
||||
Object result = provider.read();
|
||||
|
||||
Collection<?> lines = (Collection<?>) result;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2014 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.
|
||||
@@ -15,58 +15,38 @@
|
||||
*/
|
||||
package org.springframework.batch.sample.domain.multiline;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
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.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class AggregateItemTests {
|
||||
class AggregateItemTests {
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.sample.domain.multiline.AggregateItem#getFooter()}.
|
||||
*/
|
||||
@Test
|
||||
public void testGetFooter() {
|
||||
void testGetFooter() {
|
||||
assertTrue(AggregateItem.getFooter().isFooter());
|
||||
assertFalse(AggregateItem.getFooter().isHeader());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.sample.domain.multiline.AggregateItem#getHeader()}.
|
||||
*/
|
||||
@Test
|
||||
public void testGetHeader() {
|
||||
void testGetHeader() {
|
||||
assertTrue(AggregateItem.getHeader().isHeader());
|
||||
assertFalse(AggregateItem.getHeader().isFooter());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBeginRecordHasNoItem() throws Exception {
|
||||
try {
|
||||
AggregateItem.getHeader().getItem();
|
||||
fail("Expected IllegalStateException");
|
||||
}
|
||||
catch (IllegalStateException e) {
|
||||
// expected
|
||||
}
|
||||
void testBeginRecordHasNoItem() {
|
||||
assertThrows(IllegalStateException.class, () -> AggregateItem.getHeader().getItem());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEndRecordHasNoItem() throws Exception {
|
||||
try {
|
||||
AggregateItem.getFooter().getItem();
|
||||
fail("Expected IllegalStateException");
|
||||
}
|
||||
catch (IllegalStateException e) {
|
||||
// expected
|
||||
}
|
||||
void testEndRecordHasNoItem() {
|
||||
assertThrows(IllegalStateException.class, () -> AggregateItem.getFooter().getItem());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2014 the original author or authors.
|
||||
* Copyright 2008-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.
|
||||
@@ -21,7 +21,7 @@ import org.springframework.batch.item.file.transform.FieldSet;
|
||||
import org.springframework.batch.sample.domain.order.internal.mapper.AddressFieldSetMapper;
|
||||
import org.springframework.batch.sample.support.AbstractFieldSetMapperTests;
|
||||
|
||||
public class AddressFieldSetMapperTests extends AbstractFieldSetMapperTests {
|
||||
class AddressFieldSetMapperTests extends AbstractFieldSetMapperTests {
|
||||
|
||||
private static final String ADDRESSEE = "Jan Hrach";
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2014 the original author or authors.
|
||||
* Copyright 2008-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.
|
||||
@@ -21,7 +21,7 @@ import org.springframework.batch.item.file.transform.FieldSet;
|
||||
import org.springframework.batch.sample.domain.order.internal.mapper.BillingFieldSetMapper;
|
||||
import org.springframework.batch.sample.support.AbstractFieldSetMapperTests;
|
||||
|
||||
public class BillingFieldSetMapperTests extends AbstractFieldSetMapperTests {
|
||||
class BillingFieldSetMapperTests extends AbstractFieldSetMapperTests {
|
||||
|
||||
private static final String PAYMENT_ID = "777";
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2014 the original author or authors.
|
||||
* Copyright 2008-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.
|
||||
@@ -21,7 +21,7 @@ import org.springframework.batch.item.file.transform.FieldSet;
|
||||
import org.springframework.batch.sample.domain.order.internal.mapper.CustomerFieldSetMapper;
|
||||
import org.springframework.batch.sample.support.AbstractFieldSetMapperTests;
|
||||
|
||||
public class CustomerFieldSetMapperTests extends AbstractFieldSetMapperTests {
|
||||
class CustomerFieldSetMapperTests extends AbstractFieldSetMapperTests {
|
||||
|
||||
private static final boolean BUSINESS_CUSTOMER = false;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2014 the original author or authors.
|
||||
* Copyright 2008-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.
|
||||
@@ -23,7 +23,7 @@ import org.springframework.batch.item.file.transform.FieldSet;
|
||||
import org.springframework.batch.sample.domain.order.internal.mapper.HeaderFieldSetMapper;
|
||||
import org.springframework.batch.sample.support.AbstractFieldSetMapperTests;
|
||||
|
||||
public class HeaderFieldSetMapperTests extends AbstractFieldSetMapperTests {
|
||||
class HeaderFieldSetMapperTests extends AbstractFieldSetMapperTests {
|
||||
|
||||
private static final long ORDER_ID = 1;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2014 the original author or authors.
|
||||
* Copyright 2008-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.
|
||||
@@ -23,7 +23,7 @@ import org.springframework.batch.item.file.transform.FieldSet;
|
||||
import org.springframework.batch.sample.domain.order.internal.mapper.OrderItemFieldSetMapper;
|
||||
import org.springframework.batch.sample.support.AbstractFieldSetMapperTests;
|
||||
|
||||
public class OrderItemFieldSetMapperTests extends AbstractFieldSetMapperTests {
|
||||
class OrderItemFieldSetMapperTests extends AbstractFieldSetMapperTests {
|
||||
|
||||
private static final BigDecimal DISCOUNT_AMOUNT = new BigDecimal("1");
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2014 the original author or authors.
|
||||
* Copyright 2008-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.
|
||||
@@ -15,30 +15,30 @@
|
||||
*/
|
||||
package org.springframework.batch.sample.domain.order;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
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.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
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 org.springframework.batch.sample.domain.order.internal.OrderItemReader;
|
||||
|
||||
public class OrderItemReaderTests {
|
||||
class OrderItemReaderTests {
|
||||
|
||||
private OrderItemReader provider;
|
||||
|
||||
private ItemReader<FieldSet> input;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setUp() {
|
||||
void setUp() {
|
||||
input = mock(ItemReader.class);
|
||||
|
||||
provider = new OrderItemReader();
|
||||
@@ -56,7 +56,7 @@ public class OrderItemReaderTests {
|
||||
*/
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testNext() throws Exception {
|
||||
void testNext() throws Exception {
|
||||
FieldSet headerFS = new DefaultFieldSet(new String[] { Order.LINE_ID_HEADER });
|
||||
FieldSet customerFS = new DefaultFieldSet(new String[] { Customer.LINE_ID_NON_BUSINESS_CUST });
|
||||
FieldSet billingFS = new DefaultFieldSet(new String[] { Address.LINE_ID_BILLING_ADDR });
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2014 the original author or authors.
|
||||
* Copyright 2008-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.
|
||||
@@ -21,7 +21,7 @@ import org.springframework.batch.item.file.transform.FieldSet;
|
||||
import org.springframework.batch.sample.domain.order.internal.mapper.ShippingFieldSetMapper;
|
||||
import org.springframework.batch.sample.support.AbstractFieldSetMapperTests;
|
||||
|
||||
public class ShippingFieldSetMapperTests extends AbstractFieldSetMapperTests {
|
||||
class ShippingFieldSetMapperTests extends AbstractFieldSetMapperTests {
|
||||
|
||||
private static final String SHIPPER_ID = "1";
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
* Copyright 2014-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.
|
||||
@@ -15,16 +15,15 @@
|
||||
*/
|
||||
package org.springframework.batch.sample.domain.order.internal.validator;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
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;
|
||||
@@ -34,22 +33,17 @@ import org.springframework.batch.sample.domain.order.ShippingInfo;
|
||||
import org.springframework.validation.BeanPropertyBindingResult;
|
||||
import org.springframework.validation.Errors;
|
||||
|
||||
public class OrderValidatorTests {
|
||||
class OrderValidatorTests {
|
||||
|
||||
private OrderValidator orderValidator;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
orderValidator = new OrderValidator();
|
||||
}
|
||||
private final OrderValidator orderValidator = new OrderValidator();
|
||||
|
||||
@Test
|
||||
public void testSupports() {
|
||||
void testSupports() {
|
||||
assertTrue(orderValidator.supports(Order.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotAnOrder() {
|
||||
void testNotAnOrder() {
|
||||
String notAnOrder = "order";
|
||||
Errors errors = new BeanPropertyBindingResult(notAnOrder, "validOrder");
|
||||
|
||||
@@ -65,7 +59,7 @@ public class OrderValidatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidOrder() {
|
||||
void testValidOrder() {
|
||||
Order order = new Order();
|
||||
order.setOrderId(-5);
|
||||
order.setOrderDate(new Date(new Date().getTime() + 1000000000L));
|
||||
@@ -113,7 +107,7 @@ public class OrderValidatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidCustomer() {
|
||||
void testValidCustomer() {
|
||||
Order order = new Order();
|
||||
Customer customer = new Customer();
|
||||
customer.setRegistered(false);
|
||||
@@ -182,7 +176,7 @@ public class OrderValidatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidAddress() {
|
||||
void testValidAddress() {
|
||||
Order order = new Order();
|
||||
|
||||
Errors errors = new BeanPropertyBindingResult(order, "validOrder");
|
||||
@@ -240,7 +234,7 @@ public class OrderValidatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidPayment() {
|
||||
void testValidPayment() {
|
||||
Order order = new Order();
|
||||
BillingInfo info = new BillingInfo();
|
||||
info.setPaymentId("INVALID");
|
||||
@@ -266,7 +260,7 @@ public class OrderValidatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidShipping() {
|
||||
void testValidShipping() {
|
||||
Order order = new Order();
|
||||
ShippingInfo info = new ShippingInfo();
|
||||
info.setShipperId("INVALID");
|
||||
@@ -306,7 +300,7 @@ public class OrderValidatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidLineItems() {
|
||||
void testValidLineItems() {
|
||||
Order order = new Order();
|
||||
List<LineItem> lineItems = new ArrayList<>();
|
||||
lineItems.add(buildLineItem(-5, 5.00, 0, 0, 2, 3, 3, 30));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2019 the original author or authors.
|
||||
* Copyright 2008-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.
|
||||
@@ -15,10 +15,11 @@
|
||||
*/
|
||||
package org.springframework.batch.sample.domain.trade;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.item.file.transform.DefaultFieldSet;
|
||||
import org.springframework.batch.item.file.transform.FieldSet;
|
||||
import org.springframework.batch.item.file.transform.LineTokenizer;
|
||||
@@ -28,18 +29,18 @@ import org.springframework.lang.Nullable;
|
||||
* @author Lucas Ward
|
||||
*
|
||||
*/
|
||||
public class CompositeCustomerUpdateLineTokenizerTests {
|
||||
class CompositeCustomerUpdateLineTokenizerTests {
|
||||
|
||||
private StubLineTokenizer customerTokenizer;
|
||||
|
||||
private FieldSet customerFieldSet = new DefaultFieldSet(null);
|
||||
private final FieldSet customerFieldSet = new DefaultFieldSet(null);
|
||||
|
||||
private FieldSet footerFieldSet = new DefaultFieldSet(null);
|
||||
private final FieldSet footerFieldSet = new DefaultFieldSet(null);
|
||||
|
||||
private CompositeCustomerUpdateLineTokenizer compositeTokenizer;
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
@BeforeEach
|
||||
void init() {
|
||||
customerTokenizer = new StubLineTokenizer(customerFieldSet);
|
||||
compositeTokenizer = new CompositeCustomerUpdateLineTokenizer();
|
||||
compositeTokenizer.setCustomerTokenizer(customerTokenizer);
|
||||
@@ -47,7 +48,7 @@ public class CompositeCustomerUpdateLineTokenizerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomerAdd() throws Exception {
|
||||
void testCustomerAdd() {
|
||||
String customerAddLine = "AFDASFDASFDFSA";
|
||||
FieldSet fs = compositeTokenizer.tokenize(customerAddLine);
|
||||
assertEquals(customerFieldSet, fs);
|
||||
@@ -55,7 +56,7 @@ public class CompositeCustomerUpdateLineTokenizerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomerDelete() throws Exception {
|
||||
void testCustomerDelete() {
|
||||
String customerAddLine = "DFDASFDASFDFSA";
|
||||
FieldSet fs = compositeTokenizer.tokenize(customerAddLine);
|
||||
assertEquals(customerFieldSet, fs);
|
||||
@@ -63,17 +64,17 @@ public class CompositeCustomerUpdateLineTokenizerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomerUpdate() throws Exception {
|
||||
void testCustomerUpdate() {
|
||||
String customerAddLine = "UFDASFDASFDFSA";
|
||||
FieldSet fs = compositeTokenizer.tokenize(customerAddLine);
|
||||
assertEquals(customerFieldSet, fs);
|
||||
assertEquals(customerAddLine, customerTokenizer.getTokenizedLine());
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidLine() throws Exception {
|
||||
@Test
|
||||
void testInvalidLine() {
|
||||
String invalidLine = "INVALID";
|
||||
compositeTokenizer.tokenize(invalidLine);
|
||||
assertThrows(IllegalArgumentException.class, () -> compositeTokenizer.tokenize(invalidLine));
|
||||
}
|
||||
|
||||
private static class StubLineTokenizer implements LineTokenizer {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2013 the original author or authors.
|
||||
* Copyright 2008-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.
|
||||
@@ -15,8 +15,8 @@
|
||||
*/
|
||||
package org.springframework.batch.sample.domain.trade;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
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;
|
||||
@@ -25,14 +25,14 @@ import static org.springframework.batch.sample.domain.trade.CustomerOperation.UP
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* @author Lucas Ward
|
||||
*
|
||||
*/
|
||||
public class CustomerUpdateProcessorTests {
|
||||
class CustomerUpdateProcessorTests {
|
||||
|
||||
private CustomerDao customerDao;
|
||||
|
||||
@@ -40,8 +40,8 @@ public class CustomerUpdateProcessorTests {
|
||||
|
||||
private CustomerUpdateProcessor processor;
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
@BeforeEach
|
||||
void init() {
|
||||
customerDao = mock(CustomerDao.class);
|
||||
logger = mock(InvalidCustomerLogger.class);
|
||||
processor = new CustomerUpdateProcessor();
|
||||
@@ -50,40 +50,40 @@ public class CustomerUpdateProcessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccessfulAdd() throws Exception {
|
||||
void testSuccessfulAdd() throws Exception {
|
||||
CustomerUpdate customerUpdate = new CustomerUpdate(ADD, "test customer", new BigDecimal("232.2"));
|
||||
when(customerDao.getCustomerByName("test customer")).thenReturn(null);
|
||||
assertEquals(customerUpdate, processor.process(customerUpdate));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalidAdd() throws Exception {
|
||||
void testInvalidAdd() throws Exception {
|
||||
CustomerUpdate customerUpdate = new CustomerUpdate(ADD, "test customer", new BigDecimal("232.2"));
|
||||
when(customerDao.getCustomerByName("test customer")).thenReturn(new CustomerCredit());
|
||||
logger.log(customerUpdate);
|
||||
assertNull("Processor should return null", processor.process(customerUpdate));
|
||||
assertNull(processor.process(customerUpdate), "Processor should return null");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDelete() throws Exception {
|
||||
void testDelete() throws Exception {
|
||||
CustomerUpdate customerUpdate = new CustomerUpdate(DELETE, "test customer", new BigDecimal("232.2"));
|
||||
logger.log(customerUpdate);
|
||||
assertNull("Processor should return null", processor.process(customerUpdate));
|
||||
assertNull(processor.process(customerUpdate), "Processor should return null");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccessfulUpdate() throws Exception {
|
||||
void testSuccessfulUpdate() throws Exception {
|
||||
CustomerUpdate customerUpdate = new CustomerUpdate(UPDATE, "test customer", new BigDecimal("232.2"));
|
||||
when(customerDao.getCustomerByName("test customer")).thenReturn(new CustomerCredit());
|
||||
assertEquals(customerUpdate, processor.process(customerUpdate));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalidUpdate() throws Exception {
|
||||
void testInvalidUpdate() throws Exception {
|
||||
CustomerUpdate customerUpdate = new CustomerUpdate(UPDATE, "test customer", new BigDecimal("232.2"));
|
||||
when(customerDao.getCustomerByName("test customer")).thenReturn(null);
|
||||
logger.log(customerUpdate);
|
||||
assertNull("Processor should return null", processor.process(customerUpdate));
|
||||
assertNull(processor.process(customerUpdate), "Processor should return null");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 the original author or authors.
|
||||
* Copyright 2008-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.
|
||||
@@ -17,21 +17,21 @@ package org.springframework.batch.sample.domain.trade;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||
|
||||
public class TradeTests {
|
||||
class TradeTests {
|
||||
|
||||
@Test
|
||||
public void testEquality() {
|
||||
void testEquality() {
|
||||
Trade trade1 = new Trade("isin", 1, new BigDecimal("1.1"), "customer1");
|
||||
Trade trade1Clone = new Trade("isin", 1, new BigDecimal("1.1"), "customer1");
|
||||
Trade trade2 = new Trade("isin", 1, new BigDecimal("2.3"), "customer2");
|
||||
|
||||
assertEquals(trade1, trade1Clone);
|
||||
assertFalse(trade1.equals(trade2));
|
||||
assertNotEquals(trade1, trade2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 the original author or authors.
|
||||
* Copyright 2008-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.
|
||||
@@ -15,11 +15,11 @@
|
||||
*/
|
||||
package org.springframework.batch.sample.domain.trade.internal;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.sample.domain.trade.CustomerCredit;
|
||||
|
||||
/**
|
||||
@@ -27,15 +27,15 @@ import org.springframework.batch.sample.domain.trade.CustomerCredit;
|
||||
*
|
||||
* @author Robert Kasanicky
|
||||
*/
|
||||
public class CustomerCreditIncreaseProcessorTests {
|
||||
class CustomerCreditIncreaseProcessorTests {
|
||||
|
||||
private CustomerCreditIncreaseProcessor tested = new CustomerCreditIncreaseProcessor();
|
||||
private final CustomerCreditIncreaseProcessor tested = new CustomerCreditIncreaseProcessor();
|
||||
|
||||
/*
|
||||
* Increases customer's credit by fixed value
|
||||
*/
|
||||
@Test
|
||||
public void testProcess() throws Exception {
|
||||
void testProcess() throws Exception {
|
||||
final BigDecimal oldCredit = new BigDecimal("10.54");
|
||||
CustomerCredit customerCredit = new CustomerCredit();
|
||||
customerCredit.setCredit(oldCredit);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2014 the original author or authors.
|
||||
* Copyright 2008-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.
|
||||
@@ -25,7 +25,7 @@ import org.springframework.batch.sample.domain.trade.CustomerCredit;
|
||||
import org.springframework.batch.sample.support.AbstractRowMapperTests;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
|
||||
public class CustomerCreditRowMapperTests extends AbstractRowMapperTests<CustomerCredit> {
|
||||
class CustomerCreditRowMapperTests extends AbstractRowMapperTests<CustomerCredit> {
|
||||
|
||||
private static final int ID = 12;
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -21,24 +21,24 @@ import java.math.BigDecimal;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.sample.domain.trade.CustomerCredit;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class CustomerCreditUpdatePreparedStatementSetterTests {
|
||||
class CustomerCreditUpdatePreparedStatementSetterTests {
|
||||
|
||||
private CustomerCreditUpdatePreparedStatementSetter setter = new CustomerCreditUpdatePreparedStatementSetter();
|
||||
private final CustomerCreditUpdatePreparedStatementSetter setter = new CustomerCreditUpdatePreparedStatementSetter();
|
||||
|
||||
private CustomerCredit credit;
|
||||
|
||||
private PreparedStatement ps;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
ps = mock(PreparedStatement.class);
|
||||
credit = new CustomerCredit();
|
||||
credit.setId(13);
|
||||
@@ -46,13 +46,8 @@ public class CustomerCreditUpdatePreparedStatementSetterTests {
|
||||
credit.setName("foo");
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for {@link org.springframework.batch.sample.domain.trade.internal.
|
||||
* CustomerCreditUpdatePreparedStatementSetter#setValues(CustomerCredit,
|
||||
* PreparedStatement) }
|
||||
*/
|
||||
@Test
|
||||
public void testSetValues() throws SQLException {
|
||||
void testSetValues() throws SQLException {
|
||||
ps.setBigDecimal(1, credit.getCredit().add(CustomerCreditUpdatePreparedStatementSetter.FIXED_AMOUNT));
|
||||
ps.setLong(2, credit.getId());
|
||||
setter.setValues(credit, ps);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2014 the original author or authors.
|
||||
* Copyright 2008-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.
|
||||
@@ -20,12 +20,12 @@ import static org.mockito.Mockito.mock;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.sample.domain.trade.CustomerCredit;
|
||||
import org.springframework.batch.sample.domain.trade.CustomerCreditDao;
|
||||
|
||||
public class CustomerCreditUpdateProcessorTests {
|
||||
class CustomerCreditUpdateProcessorTests {
|
||||
|
||||
private CustomerCreditDao dao;
|
||||
|
||||
@@ -33,8 +33,8 @@ public class CustomerCreditUpdateProcessorTests {
|
||||
|
||||
private static final double CREDIT_FILTER = 355.0;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
dao = mock(CustomerCreditDao.class);
|
||||
|
||||
writer = new CustomerCreditUpdateWriter();
|
||||
@@ -43,7 +43,7 @@ public class CustomerCreditUpdateProcessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcess() throws Exception {
|
||||
void testProcess() throws Exception {
|
||||
CustomerCredit credit = new CustomerCredit();
|
||||
credit.setCredit(new BigDecimal(CREDIT_FILTER));
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2014 the original author or authors.
|
||||
* Copyright 2008-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.
|
||||
@@ -15,20 +15,20 @@
|
||||
*/
|
||||
package org.springframework.batch.sample.domain.trade.internal;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.sample.domain.trade.CustomerDebit;
|
||||
import org.springframework.batch.sample.domain.trade.CustomerDebitDao;
|
||||
import org.springframework.batch.sample.domain.trade.Trade;
|
||||
|
||||
public class CustomerUpdateProcessorTests {
|
||||
class CustomerUpdateProcessorTests {
|
||||
|
||||
@Test
|
||||
public void testProcess() {
|
||||
void testProcess() {
|
||||
Trade trade = new Trade();
|
||||
trade.setCustomer("testCustomerName");
|
||||
trade.setPrice(new BigDecimal("123.0"));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2008 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.
|
||||
@@ -20,21 +20,21 @@ import static org.mockito.Mockito.mock;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
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;
|
||||
|
||||
public class FlatFileCustomerCreditDaoTests {
|
||||
class FlatFileCustomerCreditDaoTests {
|
||||
|
||||
private ResourceLifecycleItemWriter output;
|
||||
|
||||
private FlatFileCustomerCreditDao writer;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
output = mock(ResourceLifecycleItemWriter.class);
|
||||
|
||||
writer = new FlatFileCustomerCreditDao();
|
||||
@@ -42,7 +42,7 @@ public class FlatFileCustomerCreditDaoTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOpen() throws Exception {
|
||||
void testOpen() throws Exception {
|
||||
ExecutionContext executionContext = new ExecutionContext();
|
||||
|
||||
output.open(executionContext);
|
||||
@@ -51,14 +51,14 @@ public class FlatFileCustomerCreditDaoTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClose() throws Exception {
|
||||
void testClose() throws Exception {
|
||||
output.close();
|
||||
|
||||
writer.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWrite() throws Exception {
|
||||
void testWrite() throws Exception {
|
||||
CustomerCredit credit = new CustomerCredit();
|
||||
credit.setCredit(new BigDecimal(1));
|
||||
credit.setName("testName");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 the original author or authors.
|
||||
* Copyright 2008-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.
|
||||
@@ -15,9 +15,10 @@
|
||||
*/
|
||||
package org.springframework.batch.sample.domain.trade.internal;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Tests for {@link GeneratingTradeItemReader}.
|
||||
@@ -26,7 +27,7 @@ import org.junit.Test;
|
||||
*/
|
||||
public class GeneratingItemReaderTests {
|
||||
|
||||
private GeneratingTradeItemReader reader = new GeneratingTradeItemReader();
|
||||
private final GeneratingTradeItemReader reader = new GeneratingTradeItemReader();
|
||||
|
||||
/*
|
||||
* Generates a given number of not-null records, consecutive calls return null.
|
||||
@@ -41,7 +42,7 @@ public class GeneratingItemReaderTests {
|
||||
counter++;
|
||||
}
|
||||
|
||||
assertEquals(null, reader.read());
|
||||
assertNull(reader.read());
|
||||
assertEquals(limit, counter);
|
||||
assertEquals(counter, reader.getCounter());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2014 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.
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.batch.sample.domain.trade.internal;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
@@ -23,20 +23,17 @@ import java.sql.SQLException;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
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.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration()
|
||||
public class JdbcCustomerDebitDaoTests {
|
||||
@SpringJUnitConfig
|
||||
class JdbcCustomerDebitDaoTests {
|
||||
|
||||
private JdbcOperations jdbcTemplate;
|
||||
|
||||
@@ -50,7 +47,7 @@ public class JdbcCustomerDebitDaoTests {
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
public void testWrite() {
|
||||
void testWrite() {
|
||||
jdbcTemplate.execute("INSERT INTO CUSTOMER VALUES (99, 0, 'testName', 100)");
|
||||
|
||||
CustomerDebit customerDebit = new CustomerDebit();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2014 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.
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.batch.sample.domain.trade.internal;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
@@ -23,8 +23,7 @@ import java.sql.SQLException;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.sample.domain.trade.Trade;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -33,13 +32,11 @@ 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.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { "/data-source-context.xml" })
|
||||
public class JdbcTradeWriterTests implements InitializingBean {
|
||||
@SpringJUnitConfig(locations = { "/data-source-context.xml" })
|
||||
class JdbcTradeWriterTests implements InitializingBean {
|
||||
|
||||
private JdbcOperations jdbcTemplate;
|
||||
|
||||
@@ -62,7 +59,7 @@ public class JdbcTradeWriterTests implements InitializingBean {
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
public void testWrite() {
|
||||
void testWrite() {
|
||||
Trade trade = new Trade();
|
||||
trade.setCustomer("testCustomer");
|
||||
trade.setIsin("5647238492");
|
||||
@@ -82,7 +79,7 @@ public class JdbcTradeWriterTests implements InitializingBean {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
public void afterPropertiesSet() {
|
||||
this.writer.setIncrementer(incrementer);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2014 the original author or authors.
|
||||
* Copyright 2008-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.
|
||||
@@ -23,7 +23,7 @@ import org.springframework.batch.item.file.transform.FieldSet;
|
||||
import org.springframework.batch.sample.domain.trade.Trade;
|
||||
import org.springframework.batch.sample.support.AbstractFieldSetMapperTests;
|
||||
|
||||
public class TradeFieldSetMapperTests extends AbstractFieldSetMapperTests {
|
||||
class TradeFieldSetMapperTests extends AbstractFieldSetMapperTests {
|
||||
|
||||
private static final String CUSTOMER = "Mike Tomcat";
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2013 the original author or authors.
|
||||
* Copyright 2008-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.
|
||||
@@ -19,19 +19,19 @@ import static org.mockito.Mockito.mock;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.sample.domain.trade.Trade;
|
||||
import org.springframework.batch.sample.domain.trade.TradeDao;
|
||||
|
||||
public class TradeProcessorTests {
|
||||
class TradeProcessorTests {
|
||||
|
||||
private TradeDao writer;
|
||||
|
||||
private TradeWriter processor;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
writer = mock(TradeDao.class);
|
||||
|
||||
processor = new TradeWriter();
|
||||
@@ -39,7 +39,7 @@ public class TradeProcessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcess() {
|
||||
void testProcess() {
|
||||
Trade trade = new Trade();
|
||||
|
||||
writer.writeTrade(trade);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2014 the original author or authors.
|
||||
* Copyright 2008-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.
|
||||
@@ -25,7 +25,7 @@ import org.springframework.batch.sample.domain.trade.Trade;
|
||||
import org.springframework.batch.sample.support.AbstractRowMapperTests;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
|
||||
public class TradeRowMapperTests extends AbstractRowMapperTests<Trade> {
|
||||
class TradeRowMapperTests extends AbstractRowMapperTests<Trade> {
|
||||
|
||||
private static final String ISIN = "jsgk342";
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2020 the original author or authors.
|
||||
* Copyright 2008-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.
|
||||
@@ -15,13 +15,13 @@
|
||||
*/
|
||||
package org.springframework.batch.sample.iosample;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
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 org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
@@ -36,7 +36,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;
|
||||
|
||||
@@ -47,10 +47,10 @@ import org.springframework.test.context.support.DependencyInjectionTestExecution
|
||||
*
|
||||
* @author Robert Kasanicky
|
||||
*/
|
||||
@ContextConfiguration(
|
||||
@SpringJUnitConfig(
|
||||
locations = { "/simple-job-launcher-context.xml", "/job-runner-context.xml", "/jobs/ioSampleJob.xml" })
|
||||
@TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, StepScopeTestExecutionListener.class })
|
||||
public abstract class AbstractIoSampleTests {
|
||||
abstract class AbstractIoSampleTests {
|
||||
|
||||
@Autowired
|
||||
private JobLauncherTestUtils jobLauncherTestUtils;
|
||||
@@ -62,7 +62,7 @@ public abstract class AbstractIoSampleTests {
|
||||
* Check the resulting credits correspond to inputs increased by fixed amount.
|
||||
*/
|
||||
@Test
|
||||
public void testUpdateCredit() throws Exception {
|
||||
void testUpdateCredit() throws Exception {
|
||||
|
||||
open(reader);
|
||||
List<CustomerCredit> inputs = getCredits(reader);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2020 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,24 +16,21 @@
|
||||
|
||||
package org.springframework.batch.sample.iosample;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
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.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
* @author Dan Garrette
|
||||
* @author Dave Syer
|
||||
* @since 2.0
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = "/jobs/iosample/delimited.xml")
|
||||
public class DelimitedFunctionalTests extends AbstractIoSampleTests {
|
||||
@SpringJUnitConfig(locations = "/jobs/iosample/delimited.xml")
|
||||
class DelimitedFunctionalTests extends AbstractIoSampleTests {
|
||||
|
||||
@Override
|
||||
protected void pointReaderToOutput(ItemReader<CustomerCredit> reader) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2020 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,19 +16,16 @@
|
||||
|
||||
package org.springframework.batch.sample.iosample;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
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.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = "/jobs/iosample/fixedLength.xml")
|
||||
public class FixedLengthFunctionalTests extends AbstractIoSampleTests {
|
||||
@SpringJUnitConfig(locations = "/jobs/iosample/fixedLength.xml")
|
||||
class FixedLengthFunctionalTests extends AbstractIoSampleTests {
|
||||
|
||||
@Override
|
||||
protected void pointReaderToOutput(ItemReader<CustomerCredit> reader) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2009 the original author or authors.
|
||||
* Copyright 2008-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.
|
||||
@@ -15,15 +15,12 @@
|
||||
*/
|
||||
package org.springframework.batch.sample.iosample;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.batch.sample.domain.trade.CustomerCredit;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { "/hibernate-context.xml", "/jobs/iosample/hibernate.xml" })
|
||||
public class HibernateFunctionalTests extends AbstractIoSampleTests {
|
||||
@SpringJUnitConfig(locations = { "/hibernate-context.xml", "/jobs/iosample/hibernate.xml" })
|
||||
class HibernateFunctionalTests extends AbstractIoSampleTests {
|
||||
|
||||
@Override
|
||||
protected void pointReaderToOutput(ItemReader<CustomerCredit> reader) {
|
||||
|
||||
@@ -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,19 +16,16 @@
|
||||
|
||||
package org.springframework.batch.sample.iosample;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.batch.sample.domain.trade.CustomerCredit;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
* @author Dan Garrette
|
||||
* @since 2.0
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = "/jobs/iosample/jdbcCursor.xml")
|
||||
public class JdbcCursorFunctionalTests extends AbstractIoSampleTests {
|
||||
@SpringJUnitConfig(locations = "/jobs/iosample/jdbcCursor.xml")
|
||||
class JdbcCursorFunctionalTests extends AbstractIoSampleTests {
|
||||
|
||||
@Override
|
||||
protected void pointReaderToOutput(ItemReader<CustomerCredit> reader) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2020 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,24 +16,21 @@
|
||||
|
||||
package org.springframework.batch.sample.iosample;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
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.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
* @author Dan Garrette
|
||||
* @author Dave Syer
|
||||
* @since 2.0
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = "/jobs/iosample/jdbcPaging.xml")
|
||||
public class JdbcPagingFunctionalTests extends AbstractIoSampleTests {
|
||||
@SpringJUnitConfig(locations = "/jobs/iosample/jdbcPaging.xml")
|
||||
class JdbcPagingFunctionalTests extends AbstractIoSampleTests {
|
||||
|
||||
@Override
|
||||
protected void pointReaderToOutput(ItemReader<CustomerCredit> reader) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2009 the original author or authors.
|
||||
* Copyright 2008-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.
|
||||
@@ -15,15 +15,12 @@
|
||||
*/
|
||||
package org.springframework.batch.sample.iosample;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.batch.sample.domain.trade.CustomerCredit;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = "/jobs/iosample/jpa.xml")
|
||||
public class JpaFunctionalTests extends AbstractIoSampleTests {
|
||||
@SpringJUnitConfig(locations = "/jobs/iosample/jpa.xml")
|
||||
class JpaFunctionalTests extends AbstractIoSampleTests {
|
||||
|
||||
@Override
|
||||
protected void pointReaderToOutput(ItemReader<CustomerCredit> reader) {
|
||||
|
||||
@@ -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,23 +16,20 @@
|
||||
|
||||
package org.springframework.batch.sample.iosample;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
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.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
* @author Dan Garrette
|
||||
* @since 2.0
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(
|
||||
@SpringJUnitConfig(
|
||||
locations = { "/simple-job-launcher-context.xml", "/jobs/iosample/multiLine.xml", "/job-runner-context.xml" })
|
||||
public class MultiLineFunctionalTests {
|
||||
class MultiLineFunctionalTests {
|
||||
|
||||
private static final String OUTPUT_FILE = "target/test-outputs/multiLineOutput.txt";
|
||||
|
||||
@@ -45,7 +42,7 @@ public class MultiLineFunctionalTests {
|
||||
* Output should be the same as input
|
||||
*/
|
||||
@Test
|
||||
public void testJob() throws Exception {
|
||||
void testJob() throws Exception {
|
||||
jobLauncherTestUtils.launchJob();
|
||||
AssertFile.assertFileEquals(new FileSystemResource(INPUT_FILE), new FileSystemResource(OUTPUT_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,23 +16,20 @@
|
||||
|
||||
package org.springframework.batch.sample.iosample;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
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.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
* @author Dan Garrette
|
||||
* @since 2.0
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { "/simple-job-launcher-context.xml", "/jobs/iosample/multiRecordType.xml",
|
||||
@SpringJUnitConfig(locations = { "/simple-job-launcher-context.xml", "/jobs/iosample/multiRecordType.xml",
|
||||
"/job-runner-context.xml" })
|
||||
public class MultiRecordTypeFunctionalTests {
|
||||
class MultiRecordTypeFunctionalTests {
|
||||
|
||||
private static final String OUTPUT_FILE = "target/test-outputs/multiRecordTypeOutput.txt";
|
||||
|
||||
@@ -45,7 +42,7 @@ public class MultiRecordTypeFunctionalTests {
|
||||
* Output should be the same as input
|
||||
*/
|
||||
@Test
|
||||
public void testJob() throws Exception {
|
||||
void testJob() throws Exception {
|
||||
jobLauncherTestUtils.launchJob();
|
||||
AssertFile.assertFileEquals(new FileSystemResource(INPUT_FILE), new FileSystemResource(OUTPUT_FILE));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2020 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,7 +16,6 @@
|
||||
|
||||
package org.springframework.batch.sample.iosample;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.JobParametersBuilder;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
@@ -24,16 +23,14 @@ 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.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
* @author Dan Garrette
|
||||
* @since 2.0
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = "/jobs/iosample/multiResource.xml")
|
||||
public class MultiResourceFunctionalTests extends AbstractIoSampleTests {
|
||||
@SpringJUnitConfig(locations = "/jobs/iosample/multiResource.xml")
|
||||
class MultiResourceFunctionalTests extends AbstractIoSampleTests {
|
||||
|
||||
@Override
|
||||
protected void pointReaderToOutput(ItemReader<CustomerCredit> reader) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2020 the original author or authors.
|
||||
* Copyright 2013-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.
|
||||
@@ -15,19 +15,16 @@
|
||||
*/
|
||||
package org.springframework.batch.sample.iosample;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
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.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = "/jobs/iosample/repository.xml")
|
||||
public class RepositoryFunctionalTests extends AbstractIoSampleTests {
|
||||
@SpringJUnitConfig(locations = "/jobs/iosample/repository.xml")
|
||||
class RepositoryFunctionalTests extends AbstractIoSampleTests {
|
||||
|
||||
@Override
|
||||
protected void pointReaderToOutput(ItemReader<CustomerCredit> reader) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2014 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,13 +16,12 @@
|
||||
|
||||
package org.springframework.batch.sample.iosample;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.Job;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
@@ -38,17 +37,15 @@ import org.springframework.batch.test.MetaDataInstanceFactory;
|
||||
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.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
* @since 2.0
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(
|
||||
@SpringJUnitConfig(
|
||||
locations = { "/simple-job-launcher-context.xml", "/jobs/ioSampleJob.xml", "/jobs/iosample/delimited.xml" })
|
||||
public class TwoJobInstancesDelimitedFunctionalTests {
|
||||
class TwoJobInstancesDelimitedFunctionalTests {
|
||||
|
||||
@Autowired
|
||||
private JobLauncher launcher;
|
||||
@@ -64,7 +61,7 @@ public class TwoJobInstancesDelimitedFunctionalTests {
|
||||
private ItemStream readerStream;
|
||||
|
||||
@Test
|
||||
public void testLaunchJobTwice() throws Exception {
|
||||
void testLaunchJobTwice() throws Exception {
|
||||
JobExecution jobExecution = launcher.run(this.job, getJobParameters("data/iosample/input/delimited.csv"));
|
||||
assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
|
||||
verifyOutput(6);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2021 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,15 +16,14 @@
|
||||
|
||||
package org.springframework.batch.sample.iosample;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
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.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.Job;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
@@ -33,8 +32,7 @@ import org.springframework.batch.core.JobParametersBuilder;
|
||||
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.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.test.jdbc.JdbcTestUtils;
|
||||
|
||||
/**
|
||||
@@ -42,10 +40,9 @@ import org.springframework.test.jdbc.JdbcTestUtils;
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @since 2.0
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(
|
||||
@SpringJUnitConfig(
|
||||
locations = { "/simple-job-launcher-context.xml", "/jobs/ioSampleJob.xml", "/jobs/iosample/jdbcPaging.xml" })
|
||||
public class TwoJobInstancesPagingFunctionalTests {
|
||||
class TwoJobInstancesPagingFunctionalTests {
|
||||
|
||||
@Autowired
|
||||
private JobLauncher launcher;
|
||||
@@ -61,13 +58,13 @@ public class TwoJobInstancesPagingFunctionalTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLaunchJobTwice() throws Exception {
|
||||
void testLaunchJobTwice() throws Exception {
|
||||
int first = JdbcTestUtils.countRowsInTableWhere(jdbcTemplate, "CUSTOMER", "credit>1000");
|
||||
JobExecution jobExecution = launcher.run(this.job, getJobParameters(1000.));
|
||||
assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
|
||||
assertEquals(first, jobExecution.getStepExecutions().iterator().next().getWriteCount());
|
||||
int second = JdbcTestUtils.countRowsInTableWhere(jdbcTemplate, "CUSTOMER", "credit>1000000");
|
||||
assertNotSame("The number of records above the threshold did not change", first, second);
|
||||
assertNotSame(first, second, "The number of records above the threshold did not change");
|
||||
jobExecution = launcher.run(this.job, getJobParameters(1000000.));
|
||||
assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
|
||||
assertEquals(second, jobExecution.getStepExecutions().iterator().next().getWriteCount());
|
||||
|
||||
@@ -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,22 +16,19 @@
|
||||
|
||||
package org.springframework.batch.sample.iosample;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
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.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
* @author Dan Garrette
|
||||
* @since 2.0
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = "/jobs/iosample/xml.xml")
|
||||
public class XmlFunctionalTests extends AbstractIoSampleTests {
|
||||
@SpringJUnitConfig(locations = "/jobs/iosample/xml.xml")
|
||||
class XmlFunctionalTests extends AbstractIoSampleTests {
|
||||
|
||||
@Autowired
|
||||
private Resource outputResource;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2014 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.
|
||||
@@ -15,15 +15,15 @@
|
||||
*/
|
||||
package org.springframework.batch.sample.jmx;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
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.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.jmx.export.notification.NotificationPublisher;
|
||||
import org.springframework.jmx.export.notification.UnableToSendNotificationException;
|
||||
|
||||
@@ -32,12 +32,12 @@ import org.springframework.jmx.export.notification.UnableToSendNotificationExcep
|
||||
* @author Thomas Risberg
|
||||
*
|
||||
*/
|
||||
public class JobExecutionNotificationPublisherTests {
|
||||
class JobExecutionNotificationPublisherTests {
|
||||
|
||||
JobExecutionNotificationPublisher publisher = new JobExecutionNotificationPublisher();
|
||||
private final JobExecutionNotificationPublisher publisher = new JobExecutionNotificationPublisher();
|
||||
|
||||
@Test
|
||||
public void testRepeatOperationsOpenUsed() throws Exception {
|
||||
void testRepeatOperationsOpenUsed() {
|
||||
final List<Notification> list = new ArrayList<>();
|
||||
|
||||
publisher.setNotificationPublisher(new NotificationPublisher() {
|
||||
@@ -50,7 +50,7 @@ public class JobExecutionNotificationPublisherTests {
|
||||
publisher.onApplicationEvent(new SimpleMessageApplicationEvent(this, "foo"));
|
||||
assertEquals(1, list.size());
|
||||
String message = list.get(0).getMessage();
|
||||
assertTrue("Message does not contain 'foo': ", message.indexOf("foo") > 0);
|
||||
assertTrue(message.contains("foo"), "Message does not contain 'foo': ");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2014 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.
|
||||
@@ -15,10 +15,11 @@
|
||||
*/
|
||||
package org.springframework.batch.sample.launch;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
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;
|
||||
@@ -28,9 +29,9 @@ import javax.management.MalformedObjectNameException;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.core.launch.JobOperator;
|
||||
import org.springframework.batch.core.launch.support.JobRegistryBackgroundJobRunner;
|
||||
import org.springframework.jmx.MBeanServerNotFoundException;
|
||||
@@ -42,19 +43,18 @@ import org.springframework.jmx.support.MBeanServerConnectionFactoryBean;
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class RemoteLauncherTests {
|
||||
class RemoteLauncherTests {
|
||||
|
||||
private static Log logger = LogFactory.getLog(RemoteLauncherTests.class);
|
||||
private static final Log logger = LogFactory.getLog(RemoteLauncherTests.class);
|
||||
|
||||
private static List<Exception> errors = new ArrayList<>();
|
||||
private static final List<Exception> errors = new ArrayList<>();
|
||||
|
||||
private static JobOperator launcher;
|
||||
|
||||
private static JobLoader loader;
|
||||
static private Thread thread;
|
||||
|
||||
@Test
|
||||
public void testConnect() throws Exception {
|
||||
void testConnect() throws Exception {
|
||||
String message = errors.isEmpty() ? "" : errors.get(0).getMessage();
|
||||
|
||||
if (!errors.isEmpty()) {
|
||||
@@ -65,29 +65,25 @@ public class RemoteLauncherTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLaunchBadJob() throws Exception {
|
||||
void testLaunchBadJob() throws Exception {
|
||||
assertEquals(0, errors.size());
|
||||
assertTrue(isConnected());
|
||||
|
||||
try {
|
||||
launcher.start("foo", "time=" + (new Date().getTime()));
|
||||
fail("Expected RuntimeException");
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
String message = e.getMessage();
|
||||
assertTrue("Wrong message: " + message, message.contains("NoSuchJobException"));
|
||||
}
|
||||
Exception exception = assertThrows(RuntimeException.class,
|
||||
() -> launcher.start("foo", "time=" + (new Date().getTime())));
|
||||
String message = exception.getMessage();
|
||||
assertTrue(message.contains("NoSuchJobException"), "Wrong message: " + message);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAvailableJobs() throws Exception {
|
||||
void testAvailableJobs() throws Exception {
|
||||
assertEquals(0, errors.size());
|
||||
assertTrue(isConnected());
|
||||
assertTrue(launcher.getJobNames().contains("loopJob"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPauseJob() throws Exception {
|
||||
void testPauseJob() throws Exception {
|
||||
final int SLEEP_INTERVAL = 600;
|
||||
|
||||
assertTrue(isConnected());
|
||||
@@ -105,7 +101,7 @@ public class RemoteLauncherTests {
|
||||
|
||||
logger.debug(launcher.getSummary(executionId));
|
||||
long resumedId = launcher.restart(executionId);
|
||||
assertNotSame("Picked up the same execution after pause and resume", executionId, resumedId);
|
||||
assertNotSame(executionId, resumedId, "Picked up the same execution after pause and resume");
|
||||
|
||||
Thread.sleep(SLEEP_INTERVAL);
|
||||
launcher.stop(resumedId);
|
||||
@@ -113,22 +109,17 @@ public class RemoteLauncherTests {
|
||||
|
||||
logger.debug(launcher.getSummary(resumedId));
|
||||
long resumeId2 = launcher.restart(resumedId);
|
||||
assertNotSame("Picked up the same execution after pause and resume", executionId, resumeId2);
|
||||
assertNotSame(executionId, resumeId2, "Picked up the same execution after pause and resume");
|
||||
|
||||
Thread.sleep(SLEEP_INTERVAL);
|
||||
launcher.stop(resumeId2);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see junit.framework.TestCase#setUp()
|
||||
*/
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
@BeforeAll
|
||||
static void setUp() throws Exception {
|
||||
System.setProperty("com.sun.management.jmxremote", "");
|
||||
|
||||
thread = new Thread(new Runnable() {
|
||||
Thread thread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
@@ -149,8 +140,8 @@ public class RemoteLauncherTests {
|
||||
}
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void cleanUp() {
|
||||
@AfterAll
|
||||
static void cleanUp() {
|
||||
JobRegistryBackgroundJobRunner.stop();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2019 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,15 +16,15 @@
|
||||
package org.springframework.batch.sample.quartz;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
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.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobDetail;
|
||||
import org.quartz.JobExecutionContext;
|
||||
@@ -48,16 +48,16 @@ import org.springframework.lang.Nullable;
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class JobLauncherDetailsTests {
|
||||
class JobLauncherDetailsTests {
|
||||
|
||||
private JobLauncherDetails details = new JobLauncherDetails();
|
||||
private final JobLauncherDetails details = new JobLauncherDetails();
|
||||
|
||||
private TriggerFiredBundle firedBundle;
|
||||
|
||||
private List<Serializable> list = new ArrayList<>();
|
||||
private final List<Serializable> list = new ArrayList<>();
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
details.setJobLauncher(new JobLauncher() {
|
||||
@Override
|
||||
public JobExecution run(org.springframework.batch.core.Job job, JobParameters jobParameters)
|
||||
@@ -82,12 +82,8 @@ public class JobLauncherDetailsTests {
|
||||
return new StubJobExecutionContext();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.sample.quartz.JobLauncherDetails#executeInternal(org.quartz.JobExecutionContext)}.
|
||||
*/
|
||||
@Test
|
||||
public void testExecuteWithNoJobParameters() {
|
||||
void testExecuteWithNoJobParameters() {
|
||||
JobDetail jobDetail = new JobDetailImpl();
|
||||
JobExecutionContext context = createContext(jobDetail);
|
||||
details.executeInternal(context);
|
||||
@@ -96,12 +92,8 @@ public class JobLauncherDetailsTests {
|
||||
assertEquals(0, parameters.getParameters().size());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.sample.quartz.JobLauncherDetails#executeInternal(org.quartz.JobExecutionContext)}.
|
||||
*/
|
||||
@Test
|
||||
public void testExecuteWithJobName() {
|
||||
void testExecuteWithJobName() {
|
||||
JobDetail jobDetail = new JobDetailImpl();
|
||||
jobDetail.getJobDataMap().put(JobLauncherDetails.JOB_NAME, "FOO");
|
||||
JobExecutionContext context = createContext(jobDetail);
|
||||
@@ -110,12 +102,8 @@ public class JobLauncherDetailsTests {
|
||||
assertEquals("FOO", list.get(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.sample.quartz.JobLauncherDetails#executeInternal(org.quartz.JobExecutionContext)}.
|
||||
*/
|
||||
@Test
|
||||
public void testExecuteWithSomeJobParameters() {
|
||||
void testExecuteWithSomeJobParameters() {
|
||||
JobDetail jobDetail = new JobDetailImpl();
|
||||
jobDetail.getJobDataMap().put("foo", "bar");
|
||||
JobExecutionContext context = createContext(jobDetail);
|
||||
@@ -125,12 +113,8 @@ public class JobLauncherDetailsTests {
|
||||
assertEquals(1, parameters.getParameters().size());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.sample.quartz.JobLauncherDetails#executeInternal(org.quartz.JobExecutionContext)}.
|
||||
*/
|
||||
@Test
|
||||
public void testExecuteWithJobNameAndParameters() {
|
||||
void testExecuteWithJobNameAndParameters() {
|
||||
JobDetail jobDetail = new JobDetailImpl();
|
||||
jobDetail.getJobDataMap().put(JobLauncherDetails.JOB_NAME, "FOO");
|
||||
jobDetail.getJobDataMap().put("foo", "bar");
|
||||
@@ -142,12 +126,8 @@ public class JobLauncherDetailsTests {
|
||||
assertEquals(1, parameters.getParameters().size());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.sample.quartz.JobLauncherDetails#executeInternal(org.quartz.JobExecutionContext)}.
|
||||
*/
|
||||
@Test
|
||||
public void testExecuteWithJobNameAndComplexParameters() {
|
||||
void testExecuteWithJobNameAndComplexParameters() {
|
||||
JobDetail jobDetail = new JobDetailImpl();
|
||||
jobDetail.getJobDataMap().put(JobLauncherDetails.JOB_NAME, "FOO");
|
||||
jobDetail.getJobDataMap().put("foo", this);
|
||||
@@ -160,7 +140,6 @@ public class JobLauncherDetailsTests {
|
||||
assertEquals(0, parameters.getParameters().size());
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
private final class StubJobExecutionContext extends JobExecutionContextImpl {
|
||||
|
||||
private StubJobExecutionContext() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 the original author or authors.
|
||||
* Copyright 2008-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.
|
||||
@@ -15,12 +15,12 @@
|
||||
*/
|
||||
package org.springframework.batch.sample.support;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.item.file.mapping.FieldSetMapper;
|
||||
import org.springframework.batch.item.file.transform.FieldSet;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* Encapsulates basic logic for testing custom {@link FieldSetMapper} implementations.
|
||||
@@ -51,7 +51,7 @@ public abstract class AbstractFieldSetMapperTests {
|
||||
* <code>equals(Object other)</code>
|
||||
*/
|
||||
@Test
|
||||
public void testRegularUse() throws Exception {
|
||||
void testRegularUse() throws Exception {
|
||||
assertEquals(expectedDomainObject(), fieldSetMapper().mapFieldSet(fieldSet()));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2014 the original author or authors.
|
||||
* Copyright 2008-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,12 +16,12 @@
|
||||
package org.springframework.batch.sample.support;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
|
||||
/**
|
||||
@@ -36,7 +36,7 @@ public abstract class AbstractRowMapperTests<T> {
|
||||
private static final int IGNORED_ROW_NUMBER = 0;
|
||||
|
||||
// mock result set
|
||||
private ResultSet rs = mock(ResultSet.class);
|
||||
private final ResultSet rs = mock(ResultSet.class);
|
||||
|
||||
/**
|
||||
* @return Expected result of mapping the mock <code>ResultSet</code> by the mapper
|
||||
@@ -58,7 +58,7 @@ public abstract class AbstractRowMapperTests<T> {
|
||||
* Regular usage scenario.
|
||||
*/
|
||||
@Test
|
||||
public void testRegularUse() throws SQLException {
|
||||
void testRegularUse() throws SQLException {
|
||||
setUpResultSetMock(rs);
|
||||
|
||||
assertEquals(expectedDomainObject(), rowMapper().mapRow(rs, IGNORED_ROW_NUMBER));
|
||||
|
||||
@@ -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.
|
||||
@@ -15,13 +15,13 @@
|
||||
*/
|
||||
package org.springframework.batch.sample.support;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
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.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.sample.domain.trade.Trade;
|
||||
import org.springframework.batch.sample.domain.trade.internal.ItemTrackingTradeItemWriter;
|
||||
|
||||
@@ -29,17 +29,12 @@ import org.springframework.batch.sample.domain.trade.internal.ItemTrackingTradeI
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class ItemTrackingItemWriterTests {
|
||||
class ItemTrackingItemWriterTests {
|
||||
|
||||
private ItemTrackingTradeItemWriter writer = new ItemTrackingTradeItemWriter();
|
||||
private final ItemTrackingTradeItemWriter writer = new ItemTrackingTradeItemWriter();
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.sample.domain.trade.internal.ItemTrackingTradeItemWriter#write(java.util.List)}.
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testWrite() throws Exception {
|
||||
void testWrite() throws Exception {
|
||||
assertEquals(0, writer.getItems().size());
|
||||
Trade a = new Trade("a", 0, null, null);
|
||||
Trade b = new Trade("b", 0, null, null);
|
||||
@@ -49,19 +44,12 @@ public class ItemTrackingItemWriterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWriteFailure() throws Exception {
|
||||
void testWriteFailure() throws Exception {
|
||||
writer.setWriteFailureISIN("c");
|
||||
try {
|
||||
Trade a = new Trade("a", 0, null, null);
|
||||
Trade b = new Trade("b", 0, null, null);
|
||||
Trade c = new Trade("c", 0, null, null);
|
||||
writer.write(Arrays.asList(a, b, c));
|
||||
fail("Expected Write Failure Exception");
|
||||
}
|
||||
catch (IOException e) {
|
||||
// expected
|
||||
}
|
||||
// the failed item is removed
|
||||
Trade a = new Trade("a", 0, null, null);
|
||||
Trade b = new Trade("b", 0, null, null);
|
||||
Trade c = new Trade("c", 0, null, null);
|
||||
assertThrows(IOException.class, () -> writer.write(Arrays.asList(a, b, c)));
|
||||
assertEquals(0, writer.getItems().size());
|
||||
|
||||
Trade e = new Trade("e", 0, null, null);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 the original author or authors.
|
||||
* Copyright 2008-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.
|
||||
@@ -15,38 +15,32 @@
|
||||
*/
|
||||
package org.springframework.batch.sample.support;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
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.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Tests for {@link RetrySampleItemWriter}.
|
||||
*
|
||||
* @author Robert Kasanicky
|
||||
*/
|
||||
public class RetrySampleItemWriterTests {
|
||||
class RetrySampleItemWriterTests {
|
||||
|
||||
private RetrySampleItemWriter<Object> processor = new RetrySampleItemWriter<>();
|
||||
private final RetrySampleItemWriter<Object> processor = new RetrySampleItemWriter<>();
|
||||
|
||||
/*
|
||||
* Processing throws exception on 2nd and 3rd call.
|
||||
*/
|
||||
@Test
|
||||
public void testProcess() throws Exception {
|
||||
void testProcess() throws Exception {
|
||||
Object item = null;
|
||||
processor.write(Collections.singletonList(item));
|
||||
|
||||
try {
|
||||
processor.write(Arrays.asList(item, item, item));
|
||||
fail();
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
// expected
|
||||
}
|
||||
assertThrows(RuntimeException.class, () -> processor.write(Arrays.asList(item, item, item)));
|
||||
|
||||
processor.write(Collections.singletonList(item));
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018 the original author or authors.
|
||||
* Copyright 2018-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.
|
||||
@@ -18,9 +18,7 @@ package org.springframework.batch.sample.validation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.Job;
|
||||
@@ -30,15 +28,15 @@ 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.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration(classes = { ValidationSampleConfiguration.class })
|
||||
public class ValidationSampleFunctionalTests {
|
||||
@SpringJUnitConfig(classes = { ValidationSampleConfiguration.class })
|
||||
class ValidationSampleFunctionalTests {
|
||||
|
||||
@Autowired
|
||||
private Job job;
|
||||
@@ -50,7 +48,7 @@ public class ValidationSampleFunctionalTests {
|
||||
private ListItemWriter<Person> listItemWriter;
|
||||
|
||||
@Test
|
||||
public void testItemValidation() throws Exception {
|
||||
void testItemValidation() throws Exception {
|
||||
// given
|
||||
JobParameters jobParameters = new JobParameters();
|
||||
|
||||
@@ -58,10 +56,10 @@ public class ValidationSampleFunctionalTests {
|
||||
JobExecution jobExecution = this.jobLauncher.run(this.job, jobParameters);
|
||||
|
||||
// then
|
||||
Assert.assertEquals(ExitStatus.COMPLETED.getExitCode(), jobExecution.getExitStatus().getExitCode());
|
||||
assertEquals(ExitStatus.COMPLETED.getExitCode(), jobExecution.getExitStatus().getExitCode());
|
||||
List<? extends Person> writtenItems = this.listItemWriter.getWrittenItems();
|
||||
Assert.assertEquals(1, writtenItems.size());
|
||||
Assert.assertEquals("foo", writtenItems.get(0).getName());
|
||||
assertEquals(1, writtenItems.size());
|
||||
assertEquals("foo", writtenItems.get(0).getName());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user