Migrate Spring Batch Core to JUnit Jupiter
This commit is contained in:
committed by
Mahmoud Ben Hassine
parent
feefc1cd9e
commit
2fdb68d28e
@@ -87,6 +87,12 @@
|
||||
</dependency>
|
||||
|
||||
<!-- test dependencies -->
|
||||
<dependency>
|
||||
<groupId>org.testcontainers</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<version>${testcontainers.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hsqldb</groupId>
|
||||
<artifactId>hsqldb</artifactId>
|
||||
@@ -196,21 +202,9 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>hamcrest-core</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.vintage</groupId>
|
||||
<artifactId>junit-vintage-engine</artifactId>
|
||||
<version>${junit-vintage-engine.version}</version>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<version>${junit-jupiter.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -233,7 +227,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-junit-jupiter</artifactId>
|
||||
<version>${mockito.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -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,14 +16,14 @@
|
||||
|
||||
package org.springframework.batch.core;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public abstract class AbstractExceptionTests extends AbstractExceptionWithCauseTests {
|
||||
|
||||
@Test
|
||||
public void testExceptionString() throws Exception {
|
||||
void testExceptionString() throws Exception {
|
||||
Exception exception = getException("foo");
|
||||
assertEquals("foo", exception.getMessage());
|
||||
}
|
||||
|
||||
@@ -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,14 +16,14 @@
|
||||
|
||||
package org.springframework.batch.core;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public abstract class AbstractExceptionWithCauseTests {
|
||||
|
||||
@Test
|
||||
public void testExceptionStringThrowable() throws Exception {
|
||||
void testExceptionStringThrowable() throws Exception {
|
||||
Exception exception = getException("foo", new IllegalStateException());
|
||||
assertEquals("foo", exception.getMessage().substring(0, 3));
|
||||
}
|
||||
|
||||
@@ -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,36 +15,35 @@
|
||||
*/
|
||||
package org.springframework.batch.core;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNull;
|
||||
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 java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
*/
|
||||
public class BatchStatusTests {
|
||||
class BatchStatusTests {
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.BatchStatus#toString()}.
|
||||
*/
|
||||
@Test
|
||||
public void testToString() {
|
||||
void testToString() {
|
||||
assertEquals("ABANDONED", BatchStatus.ABANDONED.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMaxStatus() {
|
||||
void testMaxStatus() {
|
||||
assertEquals(BatchStatus.FAILED, BatchStatus.max(BatchStatus.FAILED, BatchStatus.COMPLETED));
|
||||
assertEquals(BatchStatus.FAILED, BatchStatus.max(BatchStatus.COMPLETED, BatchStatus.FAILED));
|
||||
assertEquals(BatchStatus.FAILED, BatchStatus.max(BatchStatus.FAILED, BatchStatus.FAILED));
|
||||
@@ -53,13 +52,13 @@ public class BatchStatusTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpgradeStatusFinished() {
|
||||
void testUpgradeStatusFinished() {
|
||||
assertEquals(BatchStatus.FAILED, BatchStatus.FAILED.upgradeTo(BatchStatus.COMPLETED));
|
||||
assertEquals(BatchStatus.FAILED, BatchStatus.COMPLETED.upgradeTo(BatchStatus.FAILED));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpgradeStatusUnfinished() {
|
||||
void testUpgradeStatusUnfinished() {
|
||||
assertEquals(BatchStatus.COMPLETED, BatchStatus.STARTING.upgradeTo(BatchStatus.COMPLETED));
|
||||
assertEquals(BatchStatus.COMPLETED, BatchStatus.COMPLETED.upgradeTo(BatchStatus.STARTING));
|
||||
assertEquals(BatchStatus.STARTED, BatchStatus.STARTING.upgradeTo(BatchStatus.STARTED));
|
||||
@@ -67,7 +66,7 @@ public class BatchStatusTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsRunning() {
|
||||
void testIsRunning() {
|
||||
assertFalse(BatchStatus.FAILED.isRunning());
|
||||
assertFalse(BatchStatus.COMPLETED.isRunning());
|
||||
assertTrue(BatchStatus.STARTED.isRunning());
|
||||
@@ -75,7 +74,7 @@ public class BatchStatusTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsUnsuccessful() {
|
||||
void testIsUnsuccessful() {
|
||||
assertTrue(BatchStatus.FAILED.isUnsuccessful());
|
||||
assertFalse(BatchStatus.COMPLETED.isUnsuccessful());
|
||||
assertFalse(BatchStatus.STARTED.isUnsuccessful());
|
||||
@@ -83,28 +82,22 @@ public class BatchStatusTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetStatus() {
|
||||
void testGetStatus() {
|
||||
assertEquals(BatchStatus.FAILED, BatchStatus.valueOf(BatchStatus.FAILED.toString()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetStatusWrongCode() {
|
||||
try {
|
||||
BatchStatus.valueOf("foo");
|
||||
fail();
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
@Test(expected = NullPointerException.class)
|
||||
public void testGetStatusNullCode() {
|
||||
assertNull(BatchStatus.valueOf(null));
|
||||
void testGetStatusWrongCode() {
|
||||
assertThrows(IllegalArgumentException.class, () -> BatchStatus.valueOf("foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSerialization() throws Exception {
|
||||
void testGetStatusNullCode() {
|
||||
assertThrows(NullPointerException.class, () -> BatchStatus.valueOf(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSerialization() throws Exception {
|
||||
|
||||
ByteArrayOutputStream bout = new ByteArrayOutputStream();
|
||||
ObjectOutputStream out = new ObjectOutputStream(bout);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2021 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,27 +15,22 @@
|
||||
*/
|
||||
package org.springframework.batch.core;
|
||||
|
||||
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.Test;
|
||||
|
||||
public class DefaultJobKeyGeneratorTests {
|
||||
class DefaultJobKeyGeneratorTests {
|
||||
|
||||
private JobKeyGenerator<JobParameters> jobKeyGenerator;
|
||||
private final JobKeyGenerator<JobParameters> jobKeyGenerator = new DefaultJobKeyGenerator();
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
jobKeyGenerator = new DefaultJobKeyGenerator();
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testNullParameters() {
|
||||
jobKeyGenerator.generateKey(null);
|
||||
@Test
|
||||
void testNullParameters() {
|
||||
assertThrows(IllegalArgumentException.class, () -> jobKeyGenerator.generateKey(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMixedParameters() {
|
||||
void testMixedParameters() {
|
||||
JobParameters jobParameters1 = new JobParametersBuilder().addString("foo", "bar").addString("bar", "foo")
|
||||
.toJobParameters();
|
||||
JobParameters jobParameters2 = new JobParametersBuilder().addString("foo", "bar", true)
|
||||
@@ -46,7 +41,7 @@ public class DefaultJobKeyGeneratorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateJobKey() {
|
||||
void testCreateJobKey() {
|
||||
JobParameters jobParameters = new JobParametersBuilder().addString("foo", "bar").addString("bar", "foo")
|
||||
.toJobParameters();
|
||||
String key = jobKeyGenerator.generateKey(jobParameters);
|
||||
@@ -54,7 +49,7 @@ public class DefaultJobKeyGeneratorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateJobKeyOrdering() {
|
||||
void testCreateJobKeyOrdering() {
|
||||
JobParameters jobParameters1 = new JobParametersBuilder().addString("foo", "bar").addString("bar", "foo")
|
||||
.toJobParameters();
|
||||
String key1 = jobKeyGenerator.generateKey(jobParameters1);
|
||||
|
||||
@@ -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,121 +15,94 @@
|
||||
*/
|
||||
package org.springframework.batch.core;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotSame;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class EntityTests extends TestCase {
|
||||
class EntityTests {
|
||||
|
||||
Entity entity = new Entity(11L);
|
||||
private Entity entity = new Entity(11L);
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.Entity#hashCode()}.
|
||||
*/
|
||||
public void testHashCode() {
|
||||
@Test
|
||||
void testHashCode() {
|
||||
assertEquals(entity.hashCode(), new Entity(entity.getId()).hashCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.Entity#hashCode()}.
|
||||
*/
|
||||
public void testHashCodeNullId() {
|
||||
@Test
|
||||
void testHashCodeNullId() {
|
||||
int withoutNull = entity.hashCode();
|
||||
entity.setId(null);
|
||||
int withNull = entity.hashCode();
|
||||
assertTrue(withoutNull != withNull);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.Entity#getVersion()}.
|
||||
*/
|
||||
public void testGetVersion() {
|
||||
assertEquals(null, entity.getVersion());
|
||||
@Test
|
||||
void testGetVersion() {
|
||||
assertNull(entity.getVersion());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.Entity#getVersion()}.
|
||||
*/
|
||||
public void testIncrementVersion() {
|
||||
@Test
|
||||
void testIncrementVersion() {
|
||||
entity.incrementVersion();
|
||||
assertEquals(Integer.valueOf(0), entity.getVersion());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.Entity#getVersion()}.
|
||||
*/
|
||||
public void testIncrementVersionTwice() {
|
||||
@Test
|
||||
void testIncrementVersionTwice() {
|
||||
entity.incrementVersion();
|
||||
entity.incrementVersion();
|
||||
assertEquals(Integer.valueOf(1), entity.getVersion());
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testToString() throws Exception {
|
||||
@Test
|
||||
void testToString() {
|
||||
Entity job = new Entity();
|
||||
assertTrue(job.toString().indexOf("id=null") >= 0);
|
||||
assertTrue(job.toString().contains("id=null"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.Entity#equals(java.lang.Object)}.
|
||||
*/
|
||||
public void testEqualsSelf() {
|
||||
@Test
|
||||
void testEqualsSelf() {
|
||||
assertEquals(entity, entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.Entity#equals(java.lang.Object)}.
|
||||
*/
|
||||
public void testEqualsSelfWithNullId() {
|
||||
@Test
|
||||
void testEqualsSelfWithNullId() {
|
||||
entity = new Entity(null);
|
||||
assertEquals(entity, entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.Entity#equals(java.lang.Object)}.
|
||||
*/
|
||||
public void testEqualsEntityWithNullId() {
|
||||
@Test
|
||||
void testEqualsEntityWithNullId() {
|
||||
entity = new Entity(null);
|
||||
assertNotSame(entity, new Entity(null));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.Entity#equals(java.lang.Object)}.
|
||||
*/
|
||||
public void testEqualsEntity() {
|
||||
@Test
|
||||
void testEqualsEntity() {
|
||||
assertEquals(entity, new Entity(entity.getId()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.Entity#equals(java.lang.Object)}.
|
||||
*/
|
||||
public void testEqualsEntityWrongId() {
|
||||
assertFalse(entity.equals(new Entity()));
|
||||
@Test
|
||||
void testEqualsEntityWrongId() {
|
||||
assertNotEquals(entity, new Entity());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.Entity#equals(java.lang.Object)}.
|
||||
*/
|
||||
public void testEqualsObject() {
|
||||
assertFalse(entity.equals(new Object()));
|
||||
@Test
|
||||
void testEqualsObject() {
|
||||
assertNotEquals(entity, new Object());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.Entity#equals(java.lang.Object)}.
|
||||
*/
|
||||
public void testEqualsNull() {
|
||||
assertFalse(entity.equals(null));
|
||||
@Test
|
||||
void testEqualsNull() {
|
||||
assertNotEquals(null, entity);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
*/
|
||||
package org.springframework.batch.core;
|
||||
|
||||
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.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.util.SerializationUtils;
|
||||
|
||||
/**
|
||||
@@ -27,206 +27,159 @@ import org.springframework.util.SerializationUtils;
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
*/
|
||||
public class ExitStatusTests {
|
||||
class ExitStatusTests {
|
||||
|
||||
@Test
|
||||
public void testExitStatusNullDescription() {
|
||||
void testExitStatusNullDescription() {
|
||||
ExitStatus status = new ExitStatus("10", null);
|
||||
assertEquals("", status.getExitDescription());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExitStatusBooleanInt() {
|
||||
void testExitStatusBooleanInt() {
|
||||
ExitStatus status = new ExitStatus("10");
|
||||
assertEquals("10", status.getExitCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExitStatusConstantsContinuable() {
|
||||
void testExitStatusConstantsContinuable() {
|
||||
ExitStatus status = ExitStatus.EXECUTING;
|
||||
assertEquals("EXECUTING", status.getExitCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExitStatusConstantsFinished() {
|
||||
void testExitStatusConstantsFinished() {
|
||||
ExitStatus status = ExitStatus.COMPLETED;
|
||||
assertEquals("COMPLETED", status.getExitCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test equality of exit statuses.
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testEqualsWithSameProperties() throws Exception {
|
||||
void testEqualsWithSameProperties() {
|
||||
assertEquals(ExitStatus.EXECUTING, new ExitStatus("EXECUTING"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEqualsSelf() {
|
||||
void testEqualsSelf() {
|
||||
ExitStatus status = new ExitStatus("test");
|
||||
assertEquals(status, status);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEquals() {
|
||||
void testEquals() {
|
||||
assertEquals(new ExitStatus("test"), new ExitStatus("test"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test equality of exit statuses.
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testEqualsWithNull() throws Exception {
|
||||
void testEqualsWithNull() {
|
||||
assertFalse(ExitStatus.EXECUTING.equals(null));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test equality of exit statuses.
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testHashcode() throws Exception {
|
||||
void testHashcode() {
|
||||
assertEquals(ExitStatus.EXECUTING.toString().hashCode(), ExitStatus.EXECUTING.hashCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.ExitStatus#and(org.springframework.batch.core.ExitStatus)}
|
||||
* .
|
||||
*/
|
||||
@Test
|
||||
public void testAndExitStatusStillExecutable() {
|
||||
void testAndExitStatusStillExecutable() {
|
||||
assertEquals(ExitStatus.EXECUTING.getExitCode(), ExitStatus.EXECUTING.and(ExitStatus.EXECUTING).getExitCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.ExitStatus#and(org.springframework.batch.core.ExitStatus)}
|
||||
* .
|
||||
*/
|
||||
@Test
|
||||
public void testAndExitStatusWhenFinishedAddedToContinuable() {
|
||||
void testAndExitStatusWhenFinishedAddedToContinuable() {
|
||||
assertEquals(ExitStatus.COMPLETED.getExitCode(), ExitStatus.EXECUTING.and(ExitStatus.COMPLETED).getExitCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.ExitStatus#and(org.springframework.batch.core.ExitStatus)}
|
||||
* .
|
||||
*/
|
||||
@Test
|
||||
public void testAndExitStatusWhenContinuableAddedToFinished() {
|
||||
void testAndExitStatusWhenContinuableAddedToFinished() {
|
||||
assertEquals(ExitStatus.COMPLETED.getExitCode(), ExitStatus.COMPLETED.and(ExitStatus.EXECUTING).getExitCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.ExitStatus#and(org.springframework.batch.core.ExitStatus)}
|
||||
* .
|
||||
*/
|
||||
@Test
|
||||
public void testAndExitStatusWhenCustomContinuableAddedToContinuable() {
|
||||
void testAndExitStatusWhenCustomContinuableAddedToContinuable() {
|
||||
assertEquals("CUSTOM", ExitStatus.EXECUTING.and(ExitStatus.EXECUTING.replaceExitCode("CUSTOM")).getExitCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.ExitStatus#and(org.springframework.batch.core.ExitStatus)}
|
||||
* .
|
||||
*/
|
||||
@Test
|
||||
public void testAndExitStatusWhenCustomCompletedAddedToCompleted() {
|
||||
void testAndExitStatusWhenCustomCompletedAddedToCompleted() {
|
||||
assertEquals("COMPLETED_CUSTOM",
|
||||
ExitStatus.COMPLETED.and(ExitStatus.EXECUTING.replaceExitCode("COMPLETED_CUSTOM")).getExitCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.ExitStatus#and(org.springframework.batch.core.ExitStatus)}
|
||||
* .
|
||||
*/
|
||||
@Test
|
||||
public void testAndExitStatusFailedPlusFinished() {
|
||||
void testAndExitStatusFailedPlusFinished() {
|
||||
assertEquals("FAILED", ExitStatus.COMPLETED.and(ExitStatus.FAILED).getExitCode());
|
||||
assertEquals("FAILED", ExitStatus.FAILED.and(ExitStatus.COMPLETED).getExitCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.ExitStatus#and(org.springframework.batch.core.ExitStatus)}
|
||||
* .
|
||||
*/
|
||||
@Test
|
||||
public void testAndExitStatusWhenCustomContinuableAddedToFinished() {
|
||||
void testAndExitStatusWhenCustomContinuableAddedToFinished() {
|
||||
assertEquals("CUSTOM", ExitStatus.COMPLETED.and(ExitStatus.EXECUTING.replaceExitCode("CUSTOM")).getExitCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddExitCode() throws Exception {
|
||||
void testAddExitCode() {
|
||||
ExitStatus status = ExitStatus.EXECUTING.replaceExitCode("FOO");
|
||||
assertTrue(ExitStatus.EXECUTING != status);
|
||||
assertEquals("FOO", status.getExitCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddExitCodeToExistingStatus() throws Exception {
|
||||
void testAddExitCodeToExistingStatus() {
|
||||
ExitStatus status = ExitStatus.EXECUTING.replaceExitCode("FOO").replaceExitCode("BAR");
|
||||
assertTrue(ExitStatus.EXECUTING != status);
|
||||
assertEquals("BAR", status.getExitCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddExitCodeToSameStatus() throws Exception {
|
||||
void testAddExitCodeToSameStatus() {
|
||||
ExitStatus status = ExitStatus.EXECUTING.replaceExitCode(ExitStatus.EXECUTING.getExitCode());
|
||||
assertTrue(ExitStatus.EXECUTING != status);
|
||||
assertEquals(ExitStatus.EXECUTING.getExitCode(), status.getExitCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddExitDescription() throws Exception {
|
||||
void testAddExitDescription() {
|
||||
ExitStatus status = ExitStatus.EXECUTING.addExitDescription("Foo");
|
||||
assertTrue(ExitStatus.EXECUTING != status);
|
||||
assertEquals("Foo", status.getExitDescription());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddExitDescriptionWIthStacktrace() throws Exception {
|
||||
void testAddExitDescriptionWIthStacktrace() {
|
||||
ExitStatus status = ExitStatus.EXECUTING.addExitDescription(new RuntimeException("Foo"));
|
||||
assertTrue(ExitStatus.EXECUTING != status);
|
||||
String description = status.getExitDescription();
|
||||
assertTrue("Wrong description: " + description, description.contains("Foo"));
|
||||
assertTrue("Wrong description: " + description, description.contains("RuntimeException"));
|
||||
assertTrue(description.contains("Foo"), "Wrong description: " + description);
|
||||
assertTrue(description.contains("RuntimeException"), "Wrong description: " + description);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddExitDescriptionToSameStatus() throws Exception {
|
||||
void testAddExitDescriptionToSameStatus() {
|
||||
ExitStatus status = ExitStatus.EXECUTING.addExitDescription("Foo").addExitDescription("Foo");
|
||||
assertTrue(ExitStatus.EXECUTING != status);
|
||||
assertEquals("Foo", status.getExitDescription());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddEmptyExitDescription() throws Exception {
|
||||
void testAddEmptyExitDescription() {
|
||||
ExitStatus status = ExitStatus.EXECUTING.addExitDescription("Foo").addExitDescription((String) null);
|
||||
assertEquals("Foo", status.getExitDescription());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddExitCodeWithDescription() throws Exception {
|
||||
void testAddExitCodeWithDescription() {
|
||||
ExitStatus status = new ExitStatus("BAR", "Bar").replaceExitCode("FOO");
|
||||
assertEquals("FOO", status.getExitCode());
|
||||
assertEquals("Bar", status.getExitDescription());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnknownIsRunning() throws Exception {
|
||||
void testUnknownIsRunning() {
|
||||
assertTrue(ExitStatus.UNKNOWN.isRunning());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSerializable() {
|
||||
void testSerializable() {
|
||||
ExitStatus status = ExitStatus.EXECUTING.replaceExitCode("FOO");
|
||||
ExitStatus clone = SerializationUtils.clone(status);
|
||||
assertEquals(status.getExitCode(), clone.getExitCode());
|
||||
|
||||
@@ -15,17 +15,17 @@
|
||||
*/
|
||||
package org.springframework.batch.core;
|
||||
|
||||
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.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.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.util.SerializationUtils;
|
||||
|
||||
/**
|
||||
@@ -34,12 +34,12 @@ import org.springframework.util.SerializationUtils;
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
*/
|
||||
public class JobExecutionTests {
|
||||
class JobExecutionTests {
|
||||
|
||||
private JobExecution execution = new JobExecution(new JobInstance(11L, "foo"), 12L, new JobParameters());
|
||||
|
||||
@Test
|
||||
public void testJobExecution() {
|
||||
void testJobExecution() {
|
||||
assertNull(new JobExecution(new JobInstance(null, "foo"), null).getId());
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class JobExecutionTests {
|
||||
* Test method for {@link org.springframework.batch.core.JobExecution#getEndTime()}.
|
||||
*/
|
||||
@Test
|
||||
public void testGetEndTime() {
|
||||
void testGetEndTime() {
|
||||
assertNull(execution.getEndTime());
|
||||
execution.setEndTime(new Date(100L));
|
||||
assertEquals(100L, execution.getEndTime().getTime());
|
||||
@@ -57,7 +57,7 @@ public class JobExecutionTests {
|
||||
* Test method for {@link org.springframework.batch.core.JobExecution#getEndTime()}.
|
||||
*/
|
||||
@Test
|
||||
public void testIsRunning() {
|
||||
void testIsRunning() {
|
||||
execution.setStartTime(new Date());
|
||||
assertTrue(execution.isRunning());
|
||||
execution.setEndTime(new Date(100L));
|
||||
@@ -68,7 +68,7 @@ public class JobExecutionTests {
|
||||
* Test method for {@link org.springframework.batch.core.JobExecution#getStartTime()}.
|
||||
*/
|
||||
@Test
|
||||
public void testGetStartTime() {
|
||||
void testGetStartTime() {
|
||||
execution.setStartTime(new Date(0L));
|
||||
assertEquals(0L, execution.getStartTime().getTime());
|
||||
}
|
||||
@@ -77,7 +77,7 @@ public class JobExecutionTests {
|
||||
* Test method for {@link org.springframework.batch.core.JobExecution#getStatus()}.
|
||||
*/
|
||||
@Test
|
||||
public void testGetStatus() {
|
||||
void testGetStatus() {
|
||||
assertEquals(BatchStatus.STARTING, execution.getStatus());
|
||||
execution.setStatus(BatchStatus.COMPLETED);
|
||||
assertEquals(BatchStatus.COMPLETED, execution.getStatus());
|
||||
@@ -87,7 +87,7 @@ public class JobExecutionTests {
|
||||
* Test method for {@link org.springframework.batch.core.JobExecution#getStatus()}.
|
||||
*/
|
||||
@Test
|
||||
public void testUpgradeStatus() {
|
||||
void testUpgradeStatus() {
|
||||
assertEquals(BatchStatus.STARTING, execution.getStatus());
|
||||
execution.upgradeStatus(BatchStatus.COMPLETED);
|
||||
assertEquals(BatchStatus.COMPLETED, execution.getStatus());
|
||||
@@ -97,7 +97,7 @@ public class JobExecutionTests {
|
||||
* Test method for {@link org.springframework.batch.core.JobExecution#getStatus()}.
|
||||
*/
|
||||
@Test
|
||||
public void testDowngradeStatus() {
|
||||
void testDowngradeStatus() {
|
||||
execution.setStatus(BatchStatus.FAILED);
|
||||
execution.upgradeStatus(BatchStatus.COMPLETED);
|
||||
assertEquals(BatchStatus.FAILED, execution.getStatus());
|
||||
@@ -107,7 +107,7 @@ public class JobExecutionTests {
|
||||
* Test method for {@link org.springframework.batch.core.JobExecution#getJobId()}.
|
||||
*/
|
||||
@Test
|
||||
public void testGetJobId() {
|
||||
void testGetJobId() {
|
||||
assertEquals(11, execution.getJobId().longValue());
|
||||
execution = new JobExecution(new JobInstance(23L, "testJob"), null, new JobParameters());
|
||||
assertEquals(23, execution.getJobId().longValue());
|
||||
@@ -117,7 +117,7 @@ public class JobExecutionTests {
|
||||
* Test method for {@link org.springframework.batch.core.JobExecution#getJobId()}.
|
||||
*/
|
||||
@Test
|
||||
public void testGetJobIdForNullJob() {
|
||||
void testGetJobIdForNullJob() {
|
||||
execution = new JobExecution((JobInstance) null, (JobParameters) null);
|
||||
assertEquals(null, execution.getJobId());
|
||||
}
|
||||
@@ -126,7 +126,7 @@ public class JobExecutionTests {
|
||||
* Test method for {@link org.springframework.batch.core.JobExecution#getJobId()}.
|
||||
*/
|
||||
@Test
|
||||
public void testGetJob() {
|
||||
void testGetJob() {
|
||||
assertNotNull(execution.getJobInstance());
|
||||
}
|
||||
|
||||
@@ -135,26 +135,26 @@ public class JobExecutionTests {
|
||||
* {@link org.springframework.batch.core.JobExecution#getExitStatus()}.
|
||||
*/
|
||||
@Test
|
||||
public void testGetExitCode() {
|
||||
void testGetExitCode() {
|
||||
assertEquals(ExitStatus.UNKNOWN, execution.getExitStatus());
|
||||
execution.setExitStatus(new ExitStatus("23"));
|
||||
assertEquals("23", execution.getExitStatus().getExitCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testContextContainsInfo() throws Exception {
|
||||
void testContextContainsInfo() throws Exception {
|
||||
assertEquals("foo", execution.getJobInstance().getJobName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddAndRemoveStepExecution() throws Exception {
|
||||
void testAddAndRemoveStepExecution() throws Exception {
|
||||
assertEquals(0, execution.getStepExecutions().size());
|
||||
execution.createStepExecution("step");
|
||||
assertEquals(1, execution.getStepExecutions().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStepExecutionsWithSameName() throws Exception {
|
||||
void testStepExecutionsWithSameName() throws Exception {
|
||||
assertEquals(0, execution.getStepExecutions().size());
|
||||
execution.createStepExecution("step");
|
||||
assertEquals(1, execution.getStepExecutions().size());
|
||||
@@ -163,14 +163,14 @@ public class JobExecutionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetStepExecutions() throws Exception {
|
||||
void testSetStepExecutions() throws Exception {
|
||||
assertEquals(0, execution.getStepExecutions().size());
|
||||
execution.addStepExecutions(Arrays.asList(new StepExecution("step", execution)));
|
||||
assertEquals(1, execution.getStepExecutions().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetStepExecutionsWithIds() throws Exception {
|
||||
void testSetStepExecutionsWithIds() throws Exception {
|
||||
assertEquals(0, execution.getStepExecutions().size());
|
||||
new StepExecution("step", execution, 1L);
|
||||
assertEquals(1, execution.getStepExecutions().size());
|
||||
@@ -179,20 +179,20 @@ public class JobExecutionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToString() throws Exception {
|
||||
assertTrue("JobExecution string does not contain id", execution.toString().indexOf("id=") >= 0);
|
||||
assertTrue("JobExecution string does not contain name: " + execution, execution.toString().indexOf("foo") >= 0);
|
||||
void testToString() throws Exception {
|
||||
assertTrue(execution.toString().contains("id="), "JobExecution string does not contain id");
|
||||
assertTrue(execution.toString().contains("foo"), "JobExecution string does not contain name: " + execution);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToStringWithNullJob() throws Exception {
|
||||
void testToStringWithNullJob() {
|
||||
execution = new JobExecution(new JobInstance(null, "foo"), null);
|
||||
assertTrue("JobExecution string does not contain id", execution.toString().indexOf("id=") >= 0);
|
||||
assertTrue("JobExecution string does not contain job: " + execution, execution.toString().indexOf("job=") >= 0);
|
||||
assertTrue(execution.toString().contains("id="), "JobExecution string does not contain id");
|
||||
assertTrue(execution.toString().contains("job="), "JobExecution string does not contain job: " + execution);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSerialization() {
|
||||
void testSerialization() {
|
||||
JobExecution clone = SerializationUtils.clone(execution);
|
||||
assertEquals(execution, clone);
|
||||
assertNotNull(clone.createStepExecution("foo"));
|
||||
@@ -200,7 +200,7 @@ public class JobExecutionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailureExceptions() {
|
||||
void testFailureExceptions() {
|
||||
|
||||
RuntimeException exception = new RuntimeException();
|
||||
assertEquals(0, execution.getFailureExceptions().size());
|
||||
|
||||
@@ -15,55 +15,46 @@
|
||||
*/
|
||||
package org.springframework.batch.core;
|
||||
|
||||
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 org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.util.SerializationUtils;
|
||||
|
||||
/**
|
||||
* @author dsyer
|
||||
*
|
||||
*/
|
||||
public class JobInstanceTests {
|
||||
**/
|
||||
class JobInstanceTests {
|
||||
|
||||
private JobInstance instance = new JobInstance(11L, "job");
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.JobInstance#getJobName()}.
|
||||
*/
|
||||
@Test
|
||||
public void testGetName() {
|
||||
void testGetName() {
|
||||
instance = new JobInstance(1L, "foo");
|
||||
assertEquals("foo", instance.getJobName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetJob() {
|
||||
void testGetJob() {
|
||||
assertEquals("job", instance.getJobName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateWithNulls() {
|
||||
try {
|
||||
new JobInstance(null, null);
|
||||
fail("job instance can't exist without job specified");
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
// expected
|
||||
}
|
||||
void testCreateWithNulls() {
|
||||
assertThrows(IllegalArgumentException.class, () -> new JobInstance(null, null));
|
||||
instance = new JobInstance(null, "testJob");
|
||||
assertEquals("testJob", instance.getJobName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSerialization() {
|
||||
void testSerialization() {
|
||||
instance = new JobInstance(1L, "jobName");
|
||||
assertEquals(instance, SerializationUtils.clone(instance));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetInstanceId() {
|
||||
void testGetInstanceId() {
|
||||
assertEquals(11, instance.getInstanceId());
|
||||
}
|
||||
|
||||
|
||||
@@ -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,72 +15,72 @@
|
||||
*/
|
||||
package org.springframework.batch.core;
|
||||
|
||||
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.assertThrows;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* @author Lucas Ward
|
||||
*
|
||||
*/
|
||||
public class JobParameterTests {
|
||||
class JobParameterTests {
|
||||
|
||||
JobParameter jobParameter;
|
||||
|
||||
@Test
|
||||
public void testStringParameter() {
|
||||
void testStringParameter() {
|
||||
jobParameter = new JobParameter("test", true);
|
||||
assertEquals("test", jobParameter.getValue());
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testNullStringParameter() {
|
||||
jobParameter = new JobParameter((String) null, true);
|
||||
@Test
|
||||
void testNullStringParameter() {
|
||||
assertThrows(IllegalArgumentException.class, () -> new JobParameter((String) null, true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLongParameter() {
|
||||
void testLongParameter() {
|
||||
jobParameter = new JobParameter(1L, true);
|
||||
assertEquals(1L, jobParameter.getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDoubleParameter() {
|
||||
void testDoubleParameter() {
|
||||
jobParameter = new JobParameter(1.1, true);
|
||||
assertEquals(1.1, jobParameter.getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDateParameter() {
|
||||
void testDateParameter() {
|
||||
Date epoch = new Date(0L);
|
||||
jobParameter = new JobParameter(epoch, true);
|
||||
assertEquals(new Date(0L), jobParameter.getValue());
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testNullDateParameter() {
|
||||
jobParameter = new JobParameter((Date) null, true);
|
||||
@Test
|
||||
void testNullDateParameter() {
|
||||
assertThrows(IllegalArgumentException.class, () -> new JobParameter((Date) null, true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDateParameterToString() {
|
||||
void testDateParameterToString() {
|
||||
Date epoch = new Date(0L);
|
||||
jobParameter = new JobParameter(epoch, true);
|
||||
assertEquals("0", jobParameter.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEquals() {
|
||||
void testEquals() {
|
||||
jobParameter = new JobParameter("test", true);
|
||||
JobParameter testParameter = new JobParameter("test", true);
|
||||
assertTrue(jobParameter.equals(testParameter));
|
||||
assertEquals(jobParameter, testParameter);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHashcode() {
|
||||
void testHashcode() {
|
||||
jobParameter = new JobParameter("test", true);
|
||||
JobParameter testParameter = new JobParameter("test", true);
|
||||
assertEquals(testParameter.hashCode(), jobParameter.hashCode());
|
||||
|
||||
@@ -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.
|
||||
@@ -22,16 +22,16 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
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.explore.JobExplorer;
|
||||
import org.springframework.batch.core.job.SimpleJob;
|
||||
import org.springframework.batch.core.launch.support.RunIdIncrementer;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
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.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -43,7 +43,7 @@ import static org.mockito.Mockito.when;
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
*/
|
||||
public class JobParametersBuilderTests {
|
||||
class JobParametersBuilderTests {
|
||||
|
||||
private JobParametersBuilder parametersBuilder;
|
||||
|
||||
@@ -55,10 +55,10 @@ public class JobParametersBuilderTests {
|
||||
|
||||
private List<JobExecution> jobExecutionList;
|
||||
|
||||
private Date date = new Date(System.currentTimeMillis());
|
||||
private final Date date = new Date(System.currentTimeMillis());
|
||||
|
||||
@Before
|
||||
public void initialize() {
|
||||
@BeforeEach
|
||||
void initialize() {
|
||||
this.job = new SimpleJob("simpleJob");
|
||||
this.jobExplorer = mock(JobExplorer.class);
|
||||
this.jobInstanceList = new ArrayList<>(1);
|
||||
@@ -67,7 +67,7 @@ public class JobParametersBuilderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddingExistingJobParameters() {
|
||||
void testAddingExistingJobParameters() {
|
||||
JobParameters params1 = new JobParametersBuilder().addString("foo", "bar").addString("bar", "baz")
|
||||
.toJobParameters();
|
||||
|
||||
@@ -82,7 +82,7 @@ public class JobParametersBuilderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNonIdentifyingParameters() {
|
||||
void testNonIdentifyingParameters() {
|
||||
this.parametersBuilder.addDate("SCHEDULE_DATE", date, false);
|
||||
this.parametersBuilder.addLong("LONG", 1L, false);
|
||||
this.parametersBuilder.addString("STRING", "string value", false);
|
||||
@@ -100,7 +100,7 @@ public class JobParametersBuilderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToJobRuntimeParameters() {
|
||||
void testToJobRuntimeParameters() {
|
||||
this.parametersBuilder.addDate("SCHEDULE_DATE", date);
|
||||
this.parametersBuilder.addLong("LONG", 1L);
|
||||
this.parametersBuilder.addString("STRING", "string value");
|
||||
@@ -113,7 +113,7 @@ public class JobParametersBuilderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCopy() {
|
||||
void testCopy() {
|
||||
this.parametersBuilder.addString("STRING", "string value");
|
||||
this.parametersBuilder = new JobParametersBuilder(this.parametersBuilder.toJobParameters());
|
||||
Iterator<String> parameters = this.parametersBuilder.toJobParameters().getParameters().keySet().iterator();
|
||||
@@ -121,7 +121,7 @@ public class JobParametersBuilderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOrderedTypes() {
|
||||
void testOrderedTypes() {
|
||||
this.parametersBuilder.addDate("SCHEDULE_DATE", date);
|
||||
this.parametersBuilder.addLong("LONG", 1L);
|
||||
this.parametersBuilder.addString("STRING", "string value");
|
||||
@@ -132,7 +132,7 @@ public class JobParametersBuilderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOrderedStrings() {
|
||||
void testOrderedStrings() {
|
||||
this.parametersBuilder.addString("foo", "value foo");
|
||||
this.parametersBuilder.addString("bar", "value bar");
|
||||
this.parametersBuilder.addString("spam", "value spam");
|
||||
@@ -143,7 +143,7 @@ public class JobParametersBuilderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddJobParameter() {
|
||||
void testAddJobParameter() {
|
||||
JobParameter jobParameter = new JobParameter("bar");
|
||||
this.parametersBuilder.addParameter("foo", jobParameter);
|
||||
Map<String, JobParameter> parameters = this.parametersBuilder.toJobParameters().getParameters();
|
||||
@@ -152,7 +152,7 @@ public class JobParametersBuilderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProperties() {
|
||||
void testProperties() {
|
||||
Properties props = new Properties();
|
||||
props.setProperty("SCHEDULE_DATE", "A DATE");
|
||||
props.setProperty("LONG", "1");
|
||||
@@ -168,7 +168,7 @@ public class JobParametersBuilderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNextJobParametersFirstRun() {
|
||||
void testGetNextJobParametersFirstRun() {
|
||||
job.setJobParametersIncrementer(new RunIdIncrementer());
|
||||
initializeForNextJobParameters();
|
||||
this.parametersBuilder.getNextJobParameters(this.job);
|
||||
@@ -176,7 +176,7 @@ public class JobParametersBuilderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNextJobParametersNoIncrementer() {
|
||||
void testGetNextJobParametersNoIncrementer() {
|
||||
initializeForNextJobParameters();
|
||||
final Exception expectedException = assertThrows(IllegalArgumentException.class,
|
||||
() -> this.parametersBuilder.getNextJobParameters(this.job));
|
||||
@@ -184,7 +184,7 @@ public class JobParametersBuilderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNextJobParameters() {
|
||||
void testGetNextJobParameters() {
|
||||
this.job.setJobParametersIncrementer(new RunIdIncrementer());
|
||||
this.jobInstanceList.add(new JobInstance(1L, "simpleJobInstance"));
|
||||
this.jobExecutionList.add(getJobExecution(this.jobInstanceList.get(0), null));
|
||||
@@ -196,7 +196,7 @@ public class JobParametersBuilderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNextJobParametersRestartable() {
|
||||
void testGetNextJobParametersRestartable() {
|
||||
this.job.setRestartable(true);
|
||||
this.job.setJobParametersIncrementer(new RunIdIncrementer());
|
||||
this.jobInstanceList.add(new JobInstance(1L, "simpleJobInstance"));
|
||||
@@ -210,7 +210,7 @@ public class JobParametersBuilderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNextJobParametersNoPreviousExecution() {
|
||||
void testGetNextJobParametersNoPreviousExecution() {
|
||||
this.job.setJobParametersIncrementer(new RunIdIncrementer());
|
||||
this.jobInstanceList.add(new JobInstance(1L, "simpleJobInstance"));
|
||||
when(this.jobExplorer.getJobInstances("simpleJob", 0, 1)).thenReturn(this.jobInstanceList);
|
||||
@@ -220,10 +220,10 @@ public class JobParametersBuilderTests {
|
||||
baseJobParametersVerify(this.parametersBuilder.toJobParameters(), 4);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testMissingJobExplorer() {
|
||||
@Test
|
||||
void testMissingJobExplorer() {
|
||||
this.parametersBuilder = new JobParametersBuilder();
|
||||
this.parametersBuilder.getNextJobParameters(this.job);
|
||||
assertThrows(IllegalStateException.class, () -> this.parametersBuilder.getNextJobParameters(this.job));
|
||||
}
|
||||
|
||||
private void initializeForNextJobParameters() {
|
||||
|
||||
@@ -15,18 +15,18 @@
|
||||
*/
|
||||
package org.springframework.batch.core;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNull;
|
||||
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.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.util.SerializationUtils;
|
||||
|
||||
/**
|
||||
@@ -37,7 +37,7 @@ import org.springframework.util.SerializationUtils;
|
||||
* @author Taeik Lim
|
||||
*
|
||||
*/
|
||||
public class JobParametersTests {
|
||||
class JobParametersTests {
|
||||
|
||||
JobParameters parameters;
|
||||
|
||||
@@ -45,8 +45,8 @@ public class JobParametersTests {
|
||||
|
||||
Date date2 = new Date(7809089900L);
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
@BeforeEach
|
||||
void setUp() throws Exception {
|
||||
parameters = getNewParameters();
|
||||
}
|
||||
|
||||
@@ -66,77 +66,77 @@ public class JobParametersTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetString() {
|
||||
void testGetString() {
|
||||
assertEquals("value1", parameters.getString("string.key1"));
|
||||
assertEquals("value2", parameters.getString("string.key2"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetLong() {
|
||||
void testGetLong() {
|
||||
assertEquals(1L, parameters.getLong("long.key1").longValue());
|
||||
assertEquals(2L, parameters.getLong("long.key2").longValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDouble() {
|
||||
void testGetDouble() {
|
||||
assertEquals(Double.valueOf(1.1d), parameters.getDouble("double.key1"));
|
||||
assertEquals(Double.valueOf(2.2d), parameters.getDouble("double.key2"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDate() {
|
||||
void testGetDate() {
|
||||
assertEquals(date1, parameters.getDate("date.key1"));
|
||||
assertEquals(date2, parameters.getDate("date.key2"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMissingLong() {
|
||||
void testGetMissingLong() {
|
||||
assertNull(parameters.getLong("missing.long1"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMissingDouble() {
|
||||
void testGetMissingDouble() {
|
||||
assertNull(parameters.getDouble("missing.double1"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsEmptyWhenEmpty() throws Exception {
|
||||
void testIsEmptyWhenEmpty() throws Exception {
|
||||
assertTrue(new JobParameters().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsEmptyWhenNotEmpty() throws Exception {
|
||||
void testIsEmptyWhenNotEmpty() throws Exception {
|
||||
assertFalse(parameters.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEquals() {
|
||||
void testEquals() {
|
||||
JobParameters testParameters = getNewParameters();
|
||||
assertTrue(testParameters.equals(parameters));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEqualsSelf() {
|
||||
void testEqualsSelf() {
|
||||
assertTrue(parameters.equals(parameters));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEqualsDifferent() {
|
||||
void testEqualsDifferent() {
|
||||
assertFalse(parameters.equals(new JobParameters()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEqualsWrongType() {
|
||||
void testEqualsWrongType() {
|
||||
assertFalse(parameters.equals("foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEqualsNull() {
|
||||
void testEqualsNull() {
|
||||
assertFalse(parameters.equals(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToStringOrder() {
|
||||
void testToStringOrder() {
|
||||
|
||||
Map<String, JobParameter> props = parameters.getParameters();
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
@@ -169,40 +169,40 @@ public class JobParametersTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHashCodeEqualWhenEmpty() throws Exception {
|
||||
void testHashCodeEqualWhenEmpty() throws Exception {
|
||||
int code = new JobParameters().hashCode();
|
||||
assertEquals(code, new JobParameters().hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHashCodeEqualWhenNotEmpty() throws Exception {
|
||||
void testHashCodeEqualWhenNotEmpty() throws Exception {
|
||||
int code = getNewParameters().hashCode();
|
||||
assertEquals(code, parameters.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSerialization() {
|
||||
void testSerialization() {
|
||||
JobParameters params = getNewParameters();
|
||||
assertEquals(params, SerializationUtils.clone(params));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLongReturnsNullWhenKeyDoesntExit() {
|
||||
void testLongReturnsNullWhenKeyDoesntExit() {
|
||||
assertNull(new JobParameters().getLong("keythatdoesntexist"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStringReturnsNullWhenKeyDoesntExit() {
|
||||
void testStringReturnsNullWhenKeyDoesntExit() {
|
||||
assertNull(new JobParameters().getString("keythatdoesntexist"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDoubleReturnsNullWhenKeyDoesntExit() {
|
||||
void testDoubleReturnsNullWhenKeyDoesntExit() {
|
||||
assertNull(new JobParameters().getDouble("keythatdoesntexist"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDateReturnsNullWhenKeyDoesntExit() {
|
||||
void testDateReturnsNullWhenKeyDoesntExit() {
|
||||
assertNull(new JobParameters().getDate("keythatdoesntexist"));
|
||||
}
|
||||
|
||||
|
||||
@@ -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,10 +16,10 @@
|
||||
|
||||
package org.springframework.batch.core;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.core.job.JobSupport;
|
||||
import org.springframework.beans.factory.config.ConstructorArgumentValues;
|
||||
import org.springframework.beans.factory.support.ChildBeanDefinition;
|
||||
@@ -27,10 +27,10 @@ import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
import org.springframework.context.support.GenericApplicationContext;
|
||||
import org.springframework.context.support.StaticApplicationContext;
|
||||
|
||||
public class SpringBeanJobTests {
|
||||
class SpringBeanJobTests {
|
||||
|
||||
@Test
|
||||
public void testBeanName() throws Exception {
|
||||
void testBeanName() {
|
||||
StaticApplicationContext context = new StaticApplicationContext();
|
||||
JobSupport configuration = new JobSupport();
|
||||
context.getAutowireCapableBeanFactory().initializeBean(configuration, "bean");
|
||||
@@ -43,7 +43,7 @@ public class SpringBeanJobTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBeanNameWithBeanDefinition() throws Exception {
|
||||
void testBeanNameWithBeanDefinition() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
ConstructorArgumentValues args = new ConstructorArgumentValues();
|
||||
args.addGenericArgumentValue("foo");
|
||||
@@ -59,7 +59,7 @@ public class SpringBeanJobTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBeanNameWithParentBeanDefinition() throws Exception {
|
||||
void testBeanNameWithParentBeanDefinition() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
ConstructorArgumentValues args = new ConstructorArgumentValues();
|
||||
args.addGenericArgumentValue("bar");
|
||||
|
||||
@@ -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,37 +15,35 @@
|
||||
*/
|
||||
package org.springframework.batch.core;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class StepContributionTests extends TestCase {
|
||||
class StepContributionTests {
|
||||
|
||||
private StepExecution execution = new StepExecution("step", null);
|
||||
private final StepExecution execution = new StepExecution("step", null);
|
||||
|
||||
private StepContribution contribution = new StepContribution(execution);
|
||||
private final StepContribution contribution = new StepContribution(execution);
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.StepContribution#incrementFilterCount(int)} .
|
||||
*/
|
||||
public void testIncrementFilterCount() {
|
||||
@Test
|
||||
void testIncrementFilterCount() {
|
||||
assertEquals(0, contribution.getFilterCount());
|
||||
contribution.incrementFilterCount(1);
|
||||
assertEquals(1, contribution.getFilterCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEqualsNull() throws Exception {
|
||||
assertFalse(contribution.equals(null));
|
||||
void testEqualsNull() {
|
||||
assertNotEquals(null, contribution);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEqualsAnother() throws Exception {
|
||||
void testEqualsAnother() {
|
||||
assertEquals(new StepExecution("foo", null).createStepContribution(), contribution);
|
||||
assertEquals(new StepExecution("foo", null).createStepContribution().hashCode(), contribution.hashCode());
|
||||
}
|
||||
|
||||
@@ -15,19 +15,20 @@
|
||||
*/
|
||||
package org.springframework.batch.core;
|
||||
|
||||
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.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.assertNotEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
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.step.StepSupport;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.util.SerializationUtils;
|
||||
@@ -37,26 +38,26 @@ import org.springframework.util.SerializationUtils;
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
*/
|
||||
public class StepExecutionTests {
|
||||
class StepExecutionTests {
|
||||
|
||||
private StepExecution execution = newStepExecution(new StepSupport("stepName"), 23L);
|
||||
|
||||
private StepExecution blankExecution = newStepExecution(new StepSupport("blank"), null);
|
||||
private final StepExecution blankExecution = newStepExecution(new StepSupport("blank"), null);
|
||||
|
||||
private ExecutionContext foobarEc = new ExecutionContext();
|
||||
private final ExecutionContext foobarEc = new ExecutionContext();
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
foobarEc.put("foo", "bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStepExecution() {
|
||||
void testStepExecution() {
|
||||
assertNull(new StepExecution("step", null).getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStepExecutionWithNullId() {
|
||||
void testStepExecutionWithNullId() {
|
||||
assertNull(new StepExecution("stepName", new JobExecution(new JobInstance(null, "foo"), null)).getId());
|
||||
}
|
||||
|
||||
@@ -64,7 +65,7 @@ public class StepExecutionTests {
|
||||
* Test method for {@link org.springframework.batch.core.JobExecution#getEndTime()}.
|
||||
*/
|
||||
@Test
|
||||
public void testGetEndTime() {
|
||||
void testGetEndTime() {
|
||||
assertNull(execution.getEndTime());
|
||||
execution.setEndTime(new Date(0L));
|
||||
assertEquals(0L, execution.getEndTime().getTime());
|
||||
@@ -74,7 +75,7 @@ public class StepExecutionTests {
|
||||
* Test method for {@link StepExecution#getCreateTime()}.
|
||||
*/
|
||||
@Test
|
||||
public void testGetCreateTime() {
|
||||
void testGetCreateTime() {
|
||||
assertNotNull(execution.getCreateTime());
|
||||
execution.setCreateTime(new Date(10L));
|
||||
assertEquals(10L, execution.getCreateTime().getTime());
|
||||
@@ -84,7 +85,7 @@ public class StepExecutionTests {
|
||||
* Test method for {@link org.springframework.batch.core.JobExecution#getStatus()}.
|
||||
*/
|
||||
@Test
|
||||
public void testGetStatus() {
|
||||
void testGetStatus() {
|
||||
assertEquals(BatchStatus.STARTING, execution.getStatus());
|
||||
execution.setStatus(BatchStatus.COMPLETED);
|
||||
assertEquals(BatchStatus.COMPLETED, execution.getStatus());
|
||||
@@ -94,7 +95,7 @@ public class StepExecutionTests {
|
||||
* Test method for {@link org.springframework.batch.core.JobExecution#getJobId()}.
|
||||
*/
|
||||
@Test
|
||||
public void testGetJobId() {
|
||||
void testGetJobId() {
|
||||
assertEquals(23, execution.getJobExecutionId().longValue());
|
||||
}
|
||||
|
||||
@@ -103,7 +104,7 @@ public class StepExecutionTests {
|
||||
* {@link org.springframework.batch.core.JobExecution#getExitStatus()}.
|
||||
*/
|
||||
@Test
|
||||
public void testGetExitCode() {
|
||||
void testGetExitCode() {
|
||||
assertEquals(ExitStatus.EXECUTING, execution.getExitStatus());
|
||||
execution.setExitStatus(ExitStatus.COMPLETED);
|
||||
assertEquals(ExitStatus.COMPLETED, execution.getExitStatus());
|
||||
@@ -114,24 +115,24 @@ public class StepExecutionTests {
|
||||
* {@link org.springframework.batch.core.StepExecution#getCommitCount()}.
|
||||
*/
|
||||
@Test
|
||||
public void testGetCommitCount() {
|
||||
void testGetCommitCount() {
|
||||
execution.setCommitCount(123);
|
||||
assertEquals(123, execution.getCommitCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetFilterCount() {
|
||||
void testGetFilterCount() {
|
||||
execution.setFilterCount(123);
|
||||
assertEquals(123, execution.getFilterCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetJobExecution() throws Exception {
|
||||
void testGetJobExecution() {
|
||||
assertNotNull(execution.getJobExecution());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testApplyContribution() throws Exception {
|
||||
void testApplyContribution() {
|
||||
StepContribution contribution = execution.createStepContribution();
|
||||
contribution.incrementReadSkipCount();
|
||||
contribution.incrementWriteSkipCount();
|
||||
@@ -147,35 +148,29 @@ public class StepExecutionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTerminateOnly() throws Exception {
|
||||
void testTerminateOnly() {
|
||||
assertFalse(execution.isTerminateOnly());
|
||||
execution.setTerminateOnly();
|
||||
assertTrue(execution.isTerminateOnly());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullNameIsIllegal() throws Exception {
|
||||
try {
|
||||
new StepExecution(null, new JobExecution(new JobInstance(null, "job"), null));
|
||||
fail();
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
// expected
|
||||
}
|
||||
void testNullNameIsIllegal() {
|
||||
assertThrows(IllegalArgumentException.class,
|
||||
() -> new StepExecution(null, new JobExecution(new JobInstance(null, "job"), null)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToString() throws Exception {
|
||||
assertTrue("Should contain read count: " + execution.toString(), execution.toString().indexOf("read") >= 0);
|
||||
assertTrue("Should contain write count: " + execution.toString(), execution.toString().indexOf("write") >= 0);
|
||||
assertTrue("Should contain filter count: " + execution.toString(), execution.toString().indexOf("filter") >= 0);
|
||||
assertTrue("Should contain commit count: " + execution.toString(), execution.toString().indexOf("commit") >= 0);
|
||||
assertTrue("Should contain rollback count: " + execution.toString(),
|
||||
execution.toString().indexOf("rollback") >= 0);
|
||||
void testToString() throws Exception {
|
||||
assertTrue(execution.toString().contains("read"), "Should contain read count: " + execution.toString());
|
||||
assertTrue(execution.toString().contains("write"), "Should contain write count: " + execution.toString());
|
||||
assertTrue(execution.toString().contains("filter"), "Should contain filter count: " + execution.toString());
|
||||
assertTrue(execution.toString().contains("commit"), "Should contain commit count: " + execution.toString());
|
||||
assertTrue(execution.toString().contains("rollback"), "Should contain rollback count: " + execution.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExecutionContext() throws Exception {
|
||||
void testExecutionContext() {
|
||||
assertNotNull(execution.getExecutionContext());
|
||||
ExecutionContext context = new ExecutionContext();
|
||||
context.putString("foo", "bar");
|
||||
@@ -184,15 +179,15 @@ public class StepExecutionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEqualsWithSameName() throws Exception {
|
||||
void testEqualsWithSameName() {
|
||||
Step step = new StepSupport("stepName");
|
||||
Entity stepExecution1 = newStepExecution(step, 11L, 4L);
|
||||
Entity stepExecution2 = newStepExecution(step, 11L, 5L);
|
||||
assertFalse(stepExecution1.equals(stepExecution2));
|
||||
assertNotEquals(stepExecution1, stepExecution2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEqualsWithSameIdentifier() throws Exception {
|
||||
void testEqualsWithSameIdentifier() {
|
||||
Step step = new StepSupport("stepName");
|
||||
Entity stepExecution1 = newStepExecution(step, 11L);
|
||||
Entity stepExecution2 = newStepExecution(step, 11L);
|
||||
@@ -200,57 +195,57 @@ public class StepExecutionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEqualsWithNull() throws Exception {
|
||||
void testEqualsWithNull() {
|
||||
Entity stepExecution = newStepExecution(new StepSupport("stepName"), 11L);
|
||||
assertFalse(stepExecution.equals(null));
|
||||
assertNotEquals(null, stepExecution);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEqualsWithNullIdentifiers() throws Exception {
|
||||
void testEqualsWithNullIdentifiers() {
|
||||
Entity stepExecution = newStepExecution(new StepSupport("stepName"), 11L);
|
||||
assertFalse(stepExecution.equals(blankExecution));
|
||||
assertNotEquals(stepExecution, blankExecution);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEqualsWithNullJob() throws Exception {
|
||||
void testEqualsWithNullJob() {
|
||||
Entity stepExecution = newStepExecution(new StepSupport("stepName"), 11L);
|
||||
assertFalse(stepExecution.equals(blankExecution));
|
||||
assertNotEquals(stepExecution, blankExecution);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEqualsWithSelf() throws Exception {
|
||||
assertTrue(execution.equals(execution));
|
||||
void testEqualsWithSelf() {
|
||||
assertEquals(execution, execution);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEqualsWithDifferent() throws Exception {
|
||||
void testEqualsWithDifferent() {
|
||||
Entity stepExecution = newStepExecution(new StepSupport("foo"), 13L);
|
||||
assertFalse(execution.equals(stepExecution));
|
||||
assertNotEquals(execution, stepExecution);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEqualsWithNullStepId() throws Exception {
|
||||
void testEqualsWithNullStepId() {
|
||||
Step step = new StepSupport("name");
|
||||
execution = newStepExecution(step, 31L);
|
||||
assertEquals("name", execution.getStepName());
|
||||
StepExecution stepExecution = newStepExecution(step, 31L);
|
||||
assertEquals(stepExecution.getJobExecutionId(), execution.getJobExecutionId());
|
||||
assertTrue(execution.equals(stepExecution));
|
||||
assertEquals(execution, stepExecution);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHashCode() throws Exception {
|
||||
assertTrue("Hash code same as parent", new Entity(execution.getId()).hashCode() != execution.hashCode());
|
||||
void testHashCode() {
|
||||
assertTrue(new Entity(execution.getId()).hashCode() != execution.hashCode(), "Hash code same as parent");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHashCodeWithNullIds() throws Exception {
|
||||
assertTrue("Hash code not same as parent",
|
||||
new Entity(execution.getId()).hashCode() != blankExecution.hashCode());
|
||||
void testHashCodeWithNullIds() {
|
||||
assertTrue(new Entity(execution.getId()).hashCode() != blankExecution.hashCode(),
|
||||
"Hash code not same as parent");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHashCodeViaHashSet() throws Exception {
|
||||
void testHashCodeViaHashSet() {
|
||||
Set<StepExecution> set = new HashSet<>();
|
||||
set.add(execution);
|
||||
assertTrue(set.contains(execution));
|
||||
@@ -259,7 +254,7 @@ public class StepExecutionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSerialization() {
|
||||
void testSerialization() {
|
||||
|
||||
ExitStatus status = ExitStatus.NOOP;
|
||||
execution.setExitStatus(status);
|
||||
@@ -273,7 +268,7 @@ public class StepExecutionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddException() throws Exception {
|
||||
void testAddException() {
|
||||
|
||||
RuntimeException exception = new RuntimeException();
|
||||
assertEquals(0, execution.getFailureExceptions().size());
|
||||
@@ -286,7 +281,7 @@ public class StepExecutionTests {
|
||||
* Test method for {@link org.springframework.batch.core.JobExecution#getStatus()}.
|
||||
*/
|
||||
@Test
|
||||
public void testDowngradeStatus() {
|
||||
void testDowngradeStatus() {
|
||||
execution.setStatus(BatchStatus.FAILED);
|
||||
execution.upgradeStatus(BatchStatus.COMPLETED);
|
||||
assertEquals(BatchStatus.FAILED, execution.getStatus());
|
||||
|
||||
@@ -17,43 +17,36 @@ package org.springframework.batch.core.configuration.annotation;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.Job;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.JobParametersInvalidException;
|
||||
import org.springframework.batch.core.launch.JobLauncher;
|
||||
import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
|
||||
import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException;
|
||||
import org.springframework.batch.core.repository.JobRestartException;
|
||||
import org.springframework.batch.repeat.RepeatStatus;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
|
||||
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration
|
||||
@Ignore // FIXME review this as part of issue 3942
|
||||
public class InlineDataSourceDefinitionTests {
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
@SpringJUnitConfig
|
||||
@Disabled // FIXME review this as part of issue 3942
|
||||
class InlineDataSourceDefinitionTests {
|
||||
|
||||
@Test
|
||||
public void testInlineDataSourceDefinition() throws Exception {
|
||||
void testInlineDataSourceDefinition() throws Exception {
|
||||
ApplicationContext applicationContext = new AnnotationConfigApplicationContext(MyJobConfiguration.class);
|
||||
Job job = applicationContext.getBean(Job.class);
|
||||
JobLauncher jobLauncher = applicationContext.getBean(JobLauncher.class);
|
||||
JobExecution jobExecution = jobLauncher.run(job, new JobParameters());
|
||||
Assert.assertEquals(ExitStatus.COMPLETED, jobExecution.getExitStatus());
|
||||
assertEquals(ExitStatus.COMPLETED, jobExecution.getExitStatus());
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
||||
@@ -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,11 +16,11 @@
|
||||
|
||||
package org.springframework.batch.core.configuration.annotation;
|
||||
|
||||
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.jupiter.api.Test;
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.Job;
|
||||
@@ -52,35 +52,33 @@ public class JobBuilderConfigurationTests {
|
||||
|
||||
public static boolean fail = false;
|
||||
|
||||
private JobExecution execution;
|
||||
|
||||
@Test
|
||||
public void testVanillaBatchConfiguration() throws Exception {
|
||||
void testVanillaBatchConfiguration() throws Exception {
|
||||
testJob(BatchStatus.COMPLETED, 2, TestConfiguration.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConfigurerAsConfiguration() throws Exception {
|
||||
void testConfigurerAsConfiguration() throws Exception {
|
||||
testJob(BatchStatus.COMPLETED, 1, TestConfigurer.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConfigurerAsBean() throws Exception {
|
||||
void testConfigurerAsBean() throws Exception {
|
||||
testJob(BatchStatus.COMPLETED, 1, BeansConfigurer.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTwoConfigurations() throws Exception {
|
||||
void testTwoConfigurations() throws Exception {
|
||||
testJob("testJob", BatchStatus.COMPLETED, 2, TestConfiguration.class, AnotherConfiguration.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTwoConfigurationsAndConfigurer() throws Exception {
|
||||
void testTwoConfigurationsAndConfigurer() throws Exception {
|
||||
testJob("testJob", BatchStatus.COMPLETED, 2, TestConfiguration.class, TestConfigurer.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTwoConfigurationsAndBeansConfigurer() throws Exception {
|
||||
void testTwoConfigurationsAndBeansConfigurer() throws Exception {
|
||||
testJob("testJob", BatchStatus.COMPLETED, 2, TestConfiguration.class, BeansConfigurer.class);
|
||||
}
|
||||
|
||||
@@ -97,7 +95,7 @@ public class JobBuilderConfigurationTests {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(configs);
|
||||
Job job = jobName == null ? context.getBean(Job.class) : context.getBean(jobName, Job.class);
|
||||
JobLauncher jobLauncher = context.getBean(JobLauncher.class);
|
||||
execution = jobLauncher.run(job, new JobParametersBuilder()
|
||||
JobExecution execution = jobLauncher.run(job, new JobParametersBuilder()
|
||||
.addLong("run.id", (long) (Math.random() * Long.MAX_VALUE)).toJobParameters());
|
||||
assertEquals(status, execution.getStatus());
|
||||
assertEquals(stepExecutionCount, execution.getStepExecutions().size());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 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,11 +15,11 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.annotation;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import jakarta.annotation.PostConstruct;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.Job;
|
||||
@@ -49,17 +49,15 @@ import org.springframework.lang.Nullable;
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
*/
|
||||
public class JobLoaderConfigurationTests {
|
||||
|
||||
private JobExecution execution;
|
||||
class JobLoaderConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void testJobLoader() throws Exception {
|
||||
void testJobLoader() throws Exception {
|
||||
testJob("test", BatchStatus.COMPLETED, 2, LoaderFactoryConfiguration.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJobLoaderWithArray() throws Exception {
|
||||
void testJobLoaderWithArray() throws Exception {
|
||||
testJob("test", BatchStatus.COMPLETED, 2, LoaderRegistrarConfiguration.class);
|
||||
}
|
||||
|
||||
@@ -72,7 +70,7 @@ public class JobLoaderConfigurationTests {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(configs);
|
||||
Job job = jobName == null ? context.getBean(Job.class) : context.getBean(JobLocator.class).getJob(jobName);
|
||||
JobLauncher jobLauncher = context.getBean(JobLauncher.class);
|
||||
execution = jobLauncher.run(job, new JobParametersBuilder()
|
||||
JobExecution execution = jobLauncher.run(job, new JobParametersBuilder()
|
||||
.addLong("run.id", (long) (Math.random() * Long.MAX_VALUE)).toJobParameters());
|
||||
assertEquals(status, execution.getStatus());
|
||||
assertEquals(stepExecutionCount, execution.getStepExecutions().size());
|
||||
|
||||
@@ -16,15 +16,15 @@
|
||||
|
||||
package org.springframework.batch.core.configuration.annotation;
|
||||
|
||||
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.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
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.core.JobInstance;
|
||||
@@ -59,7 +59,7 @@ public class JobScopeConfigurationTests {
|
||||
private JobExecution jobExecution;
|
||||
|
||||
@Test
|
||||
public void testXmlJobScopeWithProxyTargetClass() throws Exception {
|
||||
void testXmlJobScopeWithProxyTargetClass() throws Exception {
|
||||
context = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/annotation/JobScopeConfigurationTestsProxyTargetClass-context.xml");
|
||||
JobSynchronizationManager.register(jobExecution);
|
||||
@@ -68,7 +68,7 @@ public class JobScopeConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testXmlJobScopeWithInterface() throws Exception {
|
||||
void testXmlJobScopeWithInterface() throws Exception {
|
||||
context = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/annotation/JobScopeConfigurationTestsInterface-context.xml");
|
||||
JobSynchronizationManager.register(jobExecution);
|
||||
@@ -78,7 +78,7 @@ public class JobScopeConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testXmlJobScopeWithInheritance() throws Exception {
|
||||
void testXmlJobScopeWithInheritance() throws Exception {
|
||||
context = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/annotation/JobScopeConfigurationTestsInheritance-context.xml");
|
||||
JobSynchronizationManager.register(jobExecution);
|
||||
@@ -87,14 +87,14 @@ public class JobScopeConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJobScopeWithProxyTargetClass() throws Exception {
|
||||
void testJobScopeWithProxyTargetClass() throws Exception {
|
||||
init(JobScopeConfigurationRequiringProxyTargetClass.class);
|
||||
SimpleHolder value = context.getBean(SimpleHolder.class);
|
||||
assertEquals("JOB", value.call());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStepScopeXmlImportUsingNamespace() throws Exception {
|
||||
void testStepScopeXmlImportUsingNamespace() throws Exception {
|
||||
init(JobScopeConfigurationXmlImportUsingNamespace.class);
|
||||
|
||||
SimpleHolder value = (SimpleHolder) context.getBean("xmlValue");
|
||||
@@ -104,17 +104,17 @@ public class JobScopeConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJobScopeWithProxyTargetClassInjected() throws Exception {
|
||||
void testJobScopeWithProxyTargetClassInjected() throws Exception {
|
||||
init(JobScopeConfigurationInjectingProxy.class);
|
||||
SimpleHolder value = context.getBean(Wrapper.class).getValue();
|
||||
assertEquals("JOB", value.call());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIntentionallyBlowUpOnMissingContextWithProxyTargetClass() throws Exception {
|
||||
void testIntentionallyBlowUpOnMissingContextWithProxyTargetClass() throws Exception {
|
||||
init(JobScopeConfigurationRequiringProxyTargetClass.class);
|
||||
JobSynchronizationManager.release();
|
||||
final Exception expectedException = Assert.assertThrows(BeanCreationException.class, () -> {
|
||||
final Exception expectedException = assertThrows(BeanCreationException.class, () -> {
|
||||
SimpleHolder value = context.getBean(SimpleHolder.class);
|
||||
assertEquals("JOB", value.call());
|
||||
});
|
||||
@@ -124,10 +124,10 @@ public class JobScopeConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIntentionallyBlowupWithForcedInterface() throws Exception {
|
||||
void testIntentionallyBlowupWithForcedInterface() throws Exception {
|
||||
init(JobScopeConfigurationForcingInterfaceProxy.class);
|
||||
JobSynchronizationManager.release();
|
||||
final Exception expectedException = Assert.assertThrows(BeanCreationException.class, () -> {
|
||||
final Exception expectedException = assertThrows(BeanCreationException.class, () -> {
|
||||
SimpleHolder value = context.getBean(SimpleHolder.class);
|
||||
assertEquals("JOB", value.call());
|
||||
});
|
||||
@@ -137,7 +137,7 @@ public class JobScopeConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJobScopeWithDefaults() throws Exception {
|
||||
void testJobScopeWithDefaults() throws Exception {
|
||||
init(JobScopeConfigurationWithDefaults.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
Callable<String> value = context.getBean(Callable.class);
|
||||
@@ -145,10 +145,10 @@ public class JobScopeConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIntentionallyBlowUpOnMissingContextWithInterface() throws Exception {
|
||||
void testIntentionallyBlowUpOnMissingContextWithInterface() throws Exception {
|
||||
init(JobScopeConfigurationWithDefaults.class);
|
||||
JobSynchronizationManager.release();
|
||||
final Exception expectedException = Assert.assertThrows(BeanCreationException.class, () -> {
|
||||
final Exception expectedException = assertThrows(BeanCreationException.class, () -> {
|
||||
@SuppressWarnings("unchecked")
|
||||
Callable<String> value = context.getBean(Callable.class);
|
||||
assertEquals("JOB", value.call());
|
||||
@@ -169,14 +169,14 @@ public class JobScopeConfigurationTests {
|
||||
JobSynchronizationManager.register(jobExecution);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
@BeforeEach
|
||||
void setup() {
|
||||
JobSynchronizationManager.release();
|
||||
jobExecution = new JobExecution(new JobInstance(5l, "JOB"), null, null);
|
||||
}
|
||||
|
||||
@After
|
||||
public void close() {
|
||||
@AfterEach
|
||||
void close() {
|
||||
JobSynchronizationManager.release();
|
||||
if (context != null) {
|
||||
context.close();
|
||||
|
||||
@@ -16,10 +16,9 @@
|
||||
|
||||
package org.springframework.batch.core.configuration.annotation;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.core.StepContribution;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.scope.context.ChunkContext;
|
||||
@@ -41,8 +40,9 @@ import org.springframework.lang.Nullable;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
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.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
@@ -57,7 +57,7 @@ public class StepScopeConfigurationTests {
|
||||
private StepExecution stepExecution;
|
||||
|
||||
@Test
|
||||
public void testXmlStepScopeWithProxyTargetClass() throws Exception {
|
||||
void testXmlStepScopeWithProxyTargetClass() throws Exception {
|
||||
context = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/annotation/StepScopeConfigurationTestsProxyTargetClass-context.xml");
|
||||
StepSynchronizationManager.register(stepExecution);
|
||||
@@ -66,7 +66,7 @@ public class StepScopeConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testXmlStepScopeWithInterface() throws Exception {
|
||||
void testXmlStepScopeWithInterface() throws Exception {
|
||||
context = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/annotation/StepScopeConfigurationTestsInterface-context.xml");
|
||||
StepSynchronizationManager.register(stepExecution);
|
||||
@@ -76,7 +76,7 @@ public class StepScopeConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testXmlStepScopeWithInheritance() throws Exception {
|
||||
void testXmlStepScopeWithInheritance() throws Exception {
|
||||
context = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/annotation/StepScopeConfigurationTestsInheritance-context.xml");
|
||||
StepSynchronizationManager.register(stepExecution);
|
||||
@@ -85,14 +85,14 @@ public class StepScopeConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStepScopeWithProxyTargetClass() throws Exception {
|
||||
void testStepScopeWithProxyTargetClass() throws Exception {
|
||||
init(StepScopeConfigurationRequiringProxyTargetClass.class);
|
||||
SimpleHolder value = context.getBean(SimpleHolder.class);
|
||||
assertEquals("STEP", value.call());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStepScopeXmlImportUsingNamespace() throws Exception {
|
||||
void testStepScopeXmlImportUsingNamespace() throws Exception {
|
||||
init(StepScopeConfigurationXmlImportUsingNamespace.class);
|
||||
|
||||
SimpleHolder value = (SimpleHolder) context.getBean("xmlValue");
|
||||
@@ -102,18 +102,18 @@ public class StepScopeConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStepScopeWithProxyTargetClassInjected() throws Exception {
|
||||
void testStepScopeWithProxyTargetClassInjected() throws Exception {
|
||||
init(StepScopeConfigurationInjectingProxy.class);
|
||||
SimpleHolder value = context.getBean(Wrapper.class).getValue();
|
||||
assertEquals("STEP", value.call());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIntentionallyBlowUpOnMissingContextWithProxyTargetClass() throws Exception {
|
||||
void testIntentionallyBlowUpOnMissingContextWithProxyTargetClass() throws Exception {
|
||||
init(StepScopeConfigurationRequiringProxyTargetClass.class);
|
||||
StepSynchronizationManager.release();
|
||||
|
||||
final Exception expectedException = Assert.assertThrows(BeanCreationException.class, () -> {
|
||||
final Exception expectedException = assertThrows(BeanCreationException.class, () -> {
|
||||
SimpleHolder value = context.getBean(SimpleHolder.class);
|
||||
assertEquals("STEP", value.call());
|
||||
});
|
||||
@@ -123,10 +123,10 @@ public class StepScopeConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIntentionallyBlowupWithForcedInterface() throws Exception {
|
||||
void testIntentionallyBlowupWithForcedInterface() throws Exception {
|
||||
init(StepScopeConfigurationForcingInterfaceProxy.class);
|
||||
StepSynchronizationManager.release();
|
||||
final Exception expectedException = Assert.assertThrows(BeanCreationException.class, () -> {
|
||||
final Exception expectedException = assertThrows(BeanCreationException.class, () -> {
|
||||
SimpleHolder value = context.getBean(SimpleHolder.class);
|
||||
assertEquals("STEP", value.call());
|
||||
});
|
||||
@@ -136,7 +136,7 @@ public class StepScopeConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStepScopeWithDefaults() throws Exception {
|
||||
void testStepScopeWithDefaults() throws Exception {
|
||||
init(StepScopeConfigurationWithDefaults.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
Callable<String> value = context.getBean(Callable.class);
|
||||
@@ -144,11 +144,11 @@ public class StepScopeConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIntentionallyBlowUpOnMissingContextWithInterface() throws Exception {
|
||||
void testIntentionallyBlowUpOnMissingContextWithInterface() throws Exception {
|
||||
init(StepScopeConfigurationWithDefaults.class);
|
||||
StepSynchronizationManager.release();
|
||||
|
||||
final Exception expectedException = Assert.assertThrows(BeanCreationException.class, () -> {
|
||||
final Exception expectedException = assertThrows(BeanCreationException.class, () -> {
|
||||
@SuppressWarnings("unchecked")
|
||||
Callable<String> value = context.getBean(Callable.class);
|
||||
assertEquals("STEP", value.call());
|
||||
@@ -169,14 +169,14 @@ public class StepScopeConfigurationTests {
|
||||
StepSynchronizationManager.register(stepExecution);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
@BeforeEach
|
||||
void setup() {
|
||||
StepSynchronizationManager.release();
|
||||
stepExecution = new StepExecution("STEP", null);
|
||||
}
|
||||
|
||||
@After
|
||||
public void close() {
|
||||
@AfterEach
|
||||
void close() {
|
||||
StepSynchronizationManager.release();
|
||||
if (context != null) {
|
||||
context.close();
|
||||
|
||||
@@ -18,12 +18,11 @@ package org.springframework.batch.core.configuration.annotation;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import org.springframework.aop.Advisor;
|
||||
import org.springframework.aop.TargetSource;
|
||||
import org.springframework.aop.framework.Advised;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
|
||||
@@ -33,8 +32,8 @@ import org.springframework.transaction.interceptor.TransactionInterceptor;
|
||||
/**
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public abstract class TransactionManagerConfigurationTests {
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
abstract class TransactionManagerConfigurationTests {
|
||||
|
||||
@Mock
|
||||
protected static PlatformTransactionManager transactionManager;
|
||||
@@ -53,8 +52,7 @@ public abstract class TransactionManagerConfigurationTests {
|
||||
// AbstractJobRepositoryFactoryBean.initializeProxy
|
||||
Advisor[] advisors = target.getAdvisors();
|
||||
for (Advisor advisor : advisors) {
|
||||
if (advisor.getAdvice() instanceof TransactionInterceptor) {
|
||||
TransactionInterceptor transactionInterceptor = (TransactionInterceptor) advisor.getAdvice();
|
||||
if (advisor.getAdvice() instanceof TransactionInterceptor transactionInterceptor) {
|
||||
return (PlatformTransactionManager) transactionInterceptor.getTransactionManager();
|
||||
}
|
||||
}
|
||||
@@ -62,10 +60,9 @@ public abstract class TransactionManagerConfigurationTests {
|
||||
}
|
||||
|
||||
static DataSource createDataSource() {
|
||||
return new EmbeddedDatabaseBuilder()
|
||||
return new EmbeddedDatabaseBuilder().generateUniqueName(true)
|
||||
.addScript("classpath:org/springframework/batch/core/schema-drop-hsqldb.sql")
|
||||
.addScript("classpath:org/springframework/batch/core/schema-hsqldb.sql").generateUniqueName(true)
|
||||
.build();
|
||||
.addScript("classpath:org/springframework/batch/core/schema-hsqldb.sql").build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,13 +18,9 @@ package org.springframework.batch.core.configuration.annotation;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.core.Job;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.repeat.RepeatStatus;
|
||||
import org.springframework.beans.factory.UnsatisfiedDependencyException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -33,34 +29,38 @@ import org.springframework.jdbc.support.JdbcTransactionManager;
|
||||
import org.springframework.test.util.AopTestUtils;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
public class TransactionManagerConfigurationWithBatchConfigurerTests extends TransactionManagerConfigurationTests {
|
||||
class TransactionManagerConfigurationWithBatchConfigurerTests extends TransactionManagerConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void testConfigurationWithDataSourceAndNoTransactionManager() throws Exception {
|
||||
void testConfigurationWithDataSourceAndNoTransactionManager() throws Exception {
|
||||
ApplicationContext applicationContext = new AnnotationConfigApplicationContext(
|
||||
BatchConfigurationWithDataSourceAndNoTransactionManager.class);
|
||||
BatchConfigurer batchConfigurer = applicationContext.getBean(BatchConfigurer.class);
|
||||
|
||||
PlatformTransactionManager platformTransactionManager = batchConfigurer.getTransactionManager();
|
||||
Assert.assertTrue(platformTransactionManager instanceof JdbcTransactionManager);
|
||||
assertTrue(platformTransactionManager instanceof JdbcTransactionManager);
|
||||
JdbcTransactionManager JdbcTransactionManager = AopTestUtils.getTargetObject(platformTransactionManager);
|
||||
Assert.assertEquals(applicationContext.getBean(DataSource.class), JdbcTransactionManager.getDataSource());
|
||||
Assert.assertSame(getTransactionManagerSetOnJobRepository(applicationContext.getBean(JobRepository.class)),
|
||||
assertEquals(applicationContext.getBean(DataSource.class), JdbcTransactionManager.getDataSource());
|
||||
assertSame(getTransactionManagerSetOnJobRepository(applicationContext.getBean(JobRepository.class)),
|
||||
platformTransactionManager);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConfigurationWithDataSourceAndTransactionManager() throws Exception {
|
||||
void testConfigurationWithDataSourceAndTransactionManager() throws Exception {
|
||||
ApplicationContext applicationContext = new AnnotationConfigApplicationContext(
|
||||
BatchConfigurationWithDataSourceAndTransactionManager.class);
|
||||
BatchConfigurer batchConfigurer = applicationContext.getBean(BatchConfigurer.class);
|
||||
|
||||
PlatformTransactionManager platformTransactionManager = batchConfigurer.getTransactionManager();
|
||||
Assert.assertSame(transactionManager, platformTransactionManager);
|
||||
Assert.assertSame(getTransactionManagerSetOnJobRepository(applicationContext.getBean(JobRepository.class)),
|
||||
assertSame(transactionManager, platformTransactionManager);
|
||||
assertSame(getTransactionManagerSetOnJobRepository(applicationContext.getBean(JobRepository.class)),
|
||||
transactionManager);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,86 +18,76 @@ package org.springframework.batch.core.configuration.annotation;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.launch.JobLauncher;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.beans.factory.UnsatisfiedDependencyException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.jdbc.support.JdbcTransactionManager;
|
||||
import org.springframework.test.util.AopTestUtils;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
public class TransactionManagerConfigurationWithoutBatchConfigurerTests extends TransactionManagerConfigurationTests {
|
||||
class TransactionManagerConfigurationWithoutBatchConfigurerTests extends TransactionManagerConfigurationTests {
|
||||
|
||||
@Test(expected = BeanCreationException.class)
|
||||
public void testConfigurationWithNoDataSourceAndNoTransactionManager() {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
|
||||
BatchConfigurationWithNoDataSourceAndNoTransactionManager.class);
|
||||
// beans created by `@EnableBatchProcessing` are lazy proxies,
|
||||
// SimpleBatchConfiguration.initialize is only triggered
|
||||
// when a method is called on one of these proxies
|
||||
JobRepository jobRepository = context.getBean(JobRepository.class);
|
||||
Assert.assertFalse(jobRepository.isJobInstanceExists("myJob", new JobParameters()));
|
||||
}
|
||||
|
||||
@Test(expected = BeanCreationException.class)
|
||||
public void testConfigurationWithNoDataSourceAndTransactionManager() {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
|
||||
BatchConfigurationWithNoDataSourceAndTransactionManager.class);
|
||||
// beans created by `@EnableBatchProcessing` are lazy proxies,
|
||||
// SimpleBatchConfiguration.initialize is only triggered
|
||||
// when a method is called on one of these proxies
|
||||
JobRepository jobRepository = context.getBean(JobRepository.class);
|
||||
Assert.assertFalse(jobRepository.isJobInstanceExists("myJob", new JobParameters()));
|
||||
@Test
|
||||
void testConfigurationWithNoDataSourceAndNoTransactionManager() {
|
||||
assertThrows(BeanCreationException.class, () -> new AnnotationConfigApplicationContext(
|
||||
BatchConfigurationWithNoDataSourceAndNoTransactionManager.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConfigurationWithDataSourceAndNoTransactionManager() throws Exception {
|
||||
void testConfigurationWithNoDataSourceAndTransactionManager() {
|
||||
assertThrows(BeanCreationException.class, () -> new AnnotationConfigApplicationContext(
|
||||
BatchConfigurationWithNoDataSourceAndTransactionManager.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testConfigurationWithDataSourceAndNoTransactionManager() throws Exception {
|
||||
ApplicationContext applicationContext = new AnnotationConfigApplicationContext(
|
||||
BatchConfigurationWithDataSourceAndNoTransactionManager.class);
|
||||
PlatformTransactionManager platformTransactionManager = getTransactionManagerSetOnJobRepository(
|
||||
applicationContext.getBean(JobRepository.class));
|
||||
Assert.assertTrue(platformTransactionManager instanceof JdbcTransactionManager);
|
||||
assertTrue(platformTransactionManager instanceof JdbcTransactionManager);
|
||||
JdbcTransactionManager JdbcTransactionManager = (JdbcTransactionManager) platformTransactionManager;
|
||||
Assert.assertEquals(applicationContext.getBean(DataSource.class), JdbcTransactionManager.getDataSource());
|
||||
assertEquals(applicationContext.getBean(DataSource.class), JdbcTransactionManager.getDataSource());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConfigurationWithDataSourceAndOneTransactionManager() throws Exception {
|
||||
void testConfigurationWithDataSourceAndOneTransactionManager() throws Exception {
|
||||
ApplicationContext applicationContext = new AnnotationConfigApplicationContext(
|
||||
BatchConfigurationWithDataSourceAndOneTransactionManager.class);
|
||||
PlatformTransactionManager platformTransactionManager = applicationContext
|
||||
.getBean(PlatformTransactionManager.class);
|
||||
Assert.assertSame(transactionManager, platformTransactionManager);
|
||||
assertSame(transactionManager, platformTransactionManager);
|
||||
// In this case, the supplied transaction manager won't be used by batch and a
|
||||
// JdbcTransactionManager will be used instead.
|
||||
// The user has to provide a custom BatchConfigurer.
|
||||
Assert.assertTrue(getTransactionManagerSetOnJobRepository(
|
||||
assertTrue(getTransactionManagerSetOnJobRepository(
|
||||
applicationContext.getBean(JobRepository.class)) instanceof JdbcTransactionManager);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConfigurationWithDataSourceAndMultipleTransactionManagers() throws Exception {
|
||||
void testConfigurationWithDataSourceAndMultipleTransactionManagers() throws Exception {
|
||||
ApplicationContext applicationContext = new AnnotationConfigApplicationContext(
|
||||
BatchConfigurationWithDataSourceAndMultipleTransactionManagers.class);
|
||||
PlatformTransactionManager platformTransactionManager = applicationContext
|
||||
.getBean(PlatformTransactionManager.class);
|
||||
Assert.assertSame(transactionManager2, platformTransactionManager);
|
||||
assertSame(transactionManager2, platformTransactionManager);
|
||||
// In this case, the supplied primary transaction manager won't be used by batch
|
||||
// and a JdbcTransactionManager will be used instead.
|
||||
// The user has to provide a custom BatchConfigurer.
|
||||
Assert.assertTrue(getTransactionManagerSetOnJobRepository(
|
||||
assertTrue(getTransactionManagerSetOnJobRepository(
|
||||
applicationContext.getBean(JobRepository.class)) instanceof JdbcTransactionManager);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2012 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,27 +15,27 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.support;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.core.job.JobSupport;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.support.StaticApplicationContext;
|
||||
|
||||
public class ApplicationContextJobFactoryTests {
|
||||
class ApplicationContextJobFactoryTests {
|
||||
|
||||
@Test
|
||||
public void testFactoryContext() throws Exception {
|
||||
void testFactoryContext() {
|
||||
ApplicationContextJobFactory factory = new ApplicationContextJobFactory("job",
|
||||
new StubApplicationContextFactory());
|
||||
assertNotNull(factory.createJob());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPostProcessing() throws Exception {
|
||||
void testPostProcessing() {
|
||||
ApplicationContextJobFactory factory = new ApplicationContextJobFactory("job",
|
||||
new PostProcessingApplicationContextFactory());
|
||||
assertEquals("bar", factory.getJobName());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010 the original author or authors.
|
||||
* Copyright 2010-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,32 +15,29 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.support;
|
||||
|
||||
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.Collection;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.core.Job;
|
||||
import org.springframework.batch.core.configuration.JobRegistry;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration
|
||||
public class AutomaticJobRegistrarContextTests {
|
||||
@SpringJUnitConfig
|
||||
class AutomaticJobRegistrarContextTests {
|
||||
|
||||
@Autowired
|
||||
private JobRegistry registry;
|
||||
|
||||
@Test
|
||||
public void testLocateJob() throws Exception {
|
||||
void testLocateJob() throws Exception {
|
||||
|
||||
Collection<String> names = registry.getJobNames();
|
||||
assertEquals(2, names.size());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 the original author or authors.
|
||||
* Copyright 2010-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,16 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.support;
|
||||
|
||||
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 java.util.ArrayList;
|
||||
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.mockito.Mockito;
|
||||
import org.springframework.batch.core.Job;
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
@@ -41,14 +41,14 @@ import org.springframework.core.io.Resource;
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
*/
|
||||
public class AutomaticJobRegistrarTests {
|
||||
class AutomaticJobRegistrarTests {
|
||||
|
||||
private AutomaticJobRegistrar registrar = new AutomaticJobRegistrar();
|
||||
private final AutomaticJobRegistrar registrar = new AutomaticJobRegistrar();
|
||||
|
||||
private MapJobRegistry registry = new MapJobRegistry();
|
||||
private final MapJobRegistry registry = new MapJobRegistry();
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
DefaultJobLoader jobLoader = new DefaultJobLoader();
|
||||
jobLoader.setJobRegistry(registry);
|
||||
registrar.setJobLoader(jobLoader);
|
||||
@@ -56,7 +56,7 @@ public class AutomaticJobRegistrarTests {
|
||||
|
||||
@SuppressWarnings("cast")
|
||||
@Test
|
||||
public void testOrderedImplemented() throws Exception {
|
||||
void testOrderedImplemented() {
|
||||
|
||||
assertTrue(registrar instanceof Ordered);
|
||||
assertEquals(Ordered.LOWEST_PRECEDENCE, registrar.getOrder());
|
||||
@@ -66,27 +66,26 @@ public class AutomaticJobRegistrarTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultAutoStartup() throws Exception {
|
||||
void testDefaultAutoStartup() {
|
||||
|
||||
assertTrue(registrar.isAutoStartup());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultPhase() throws Exception {
|
||||
void testDefaultPhase() {
|
||||
|
||||
assertEquals(Integer.MIN_VALUE + 1000, registrar.getPhase());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLocateJob() throws Exception {
|
||||
void testLocateJob() throws Exception {
|
||||
|
||||
Resource[] jobPaths = new Resource[] {
|
||||
new ClassPathResource("org/springframework/batch/core/launch/support/job.xml"),
|
||||
new ClassPathResource("org/springframework/batch/core/launch/support/job2.xml") };
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
GenericApplicationContext applicationContext = new GenericApplicationContext();
|
||||
applicationContext.refresh();
|
||||
setUpApplicationContextFactories(jobPaths, applicationContext);
|
||||
@@ -105,11 +104,10 @@ public class AutomaticJobRegistrarTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoJobFound() throws Exception {
|
||||
void testNoJobFound() {
|
||||
|
||||
Resource[] jobPaths = new Resource[] {
|
||||
new ClassPathResource("org/springframework/batch/core/launch/support/test-environment.xml") };
|
||||
@SuppressWarnings("resource")
|
||||
GenericApplicationContext applicationContext = new GenericApplicationContext();
|
||||
applicationContext.refresh();
|
||||
setUpApplicationContextFactories(jobPaths, applicationContext);
|
||||
@@ -118,11 +116,10 @@ public class AutomaticJobRegistrarTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDuplicateJobsInFile() throws Exception {
|
||||
void testDuplicateJobsInFile() {
|
||||
|
||||
Resource[] jobPaths = new Resource[] {
|
||||
new ClassPathResource("org/springframework/batch/core/launch/support/2jobs.xml") };
|
||||
@SuppressWarnings("resource")
|
||||
GenericApplicationContext applicationContext = new GenericApplicationContext();
|
||||
applicationContext.refresh();
|
||||
setUpApplicationContextFactories(jobPaths, applicationContext);
|
||||
@@ -132,11 +129,10 @@ public class AutomaticJobRegistrarTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChildContextOverridesBeanPostProcessor() throws Exception {
|
||||
void testChildContextOverridesBeanPostProcessor() {
|
||||
|
||||
Resource[] jobPaths = new Resource[] {
|
||||
new ClassPathResource("org/springframework/batch/core/launch/support/2jobs.xml") };
|
||||
@SuppressWarnings("resource")
|
||||
ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(
|
||||
"/org/springframework/batch/core/launch/support/test-environment-with-registry-and-auto-register.xml");
|
||||
registrar.setApplicationContext(applicationContext);
|
||||
@@ -146,23 +142,18 @@ public class AutomaticJobRegistrarTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testErrorInContext() throws Exception {
|
||||
void testErrorInContext() {
|
||||
|
||||
Resource[] jobPaths = new Resource[] {
|
||||
new ClassPathResource("org/springframework/batch/core/launch/support/2jobs.xml"),
|
||||
new ClassPathResource("org/springframework/batch/core/launch/support/error.xml") };
|
||||
setUpApplicationContextFactories(jobPaths, null);
|
||||
try {
|
||||
registrar.start();
|
||||
fail("Expected BeanCreationException");
|
||||
}
|
||||
catch (BeanCreationException e) {
|
||||
}
|
||||
assertThrows(BeanCreationException.class, registrar::start);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClear() throws Exception {
|
||||
void testClear() {
|
||||
|
||||
Resource[] jobPaths = new Resource[] {
|
||||
new ClassPathResource("org/springframework/batch/core/launch/support/2jobs.xml") };
|
||||
@@ -175,7 +166,7 @@ public class AutomaticJobRegistrarTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStartStopRunning() throws Exception {
|
||||
void testStartStopRunning() {
|
||||
|
||||
Resource[] jobPaths = new Resource[] {
|
||||
new ClassPathResource("org/springframework/batch/core/launch/support/2jobs.xml") };
|
||||
@@ -190,7 +181,7 @@ public class AutomaticJobRegistrarTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStartStopRunningWithCallback() throws Exception {
|
||||
void testStartStopRunningWithCallback() {
|
||||
|
||||
Runnable callback = Mockito.mock(Runnable.class);
|
||||
Resource[] jobPaths = new Resource[] {
|
||||
|
||||
@@ -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,14 +15,15 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.support;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.core.Job;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobParametersIncrementer;
|
||||
@@ -31,7 +32,6 @@ import org.springframework.batch.core.Step;
|
||||
import org.springframework.batch.core.configuration.DuplicateJobException;
|
||||
import org.springframework.batch.core.configuration.JobRegistry;
|
||||
import org.springframework.batch.core.configuration.StepRegistry;
|
||||
import org.springframework.batch.core.launch.NoSuchJobException;
|
||||
import org.springframework.batch.core.step.NoSuchStepException;
|
||||
import org.springframework.batch.core.step.StepLocator;
|
||||
import org.springframework.core.io.ByteArrayResource;
|
||||
@@ -44,7 +44,7 @@ import org.springframework.test.util.ReflectionTestUtils;
|
||||
* @author Stephane Nicoll
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
public class DefaultJobLoaderTests {
|
||||
class DefaultJobLoaderTests {
|
||||
|
||||
/**
|
||||
* The name of the job as defined in the test context used in this test.
|
||||
@@ -56,14 +56,14 @@ public class DefaultJobLoaderTests {
|
||||
*/
|
||||
private static final String TEST_STEP_NAME = "test-step";
|
||||
|
||||
private JobRegistry jobRegistry = new MapJobRegistry();
|
||||
private final JobRegistry jobRegistry = new MapJobRegistry();
|
||||
|
||||
private StepRegistry stepRegistry = new MapStepRegistry();
|
||||
private final StepRegistry stepRegistry = new MapStepRegistry();
|
||||
|
||||
private DefaultJobLoader jobLoader = new DefaultJobLoader(jobRegistry, stepRegistry);
|
||||
private final DefaultJobLoader jobLoader = new DefaultJobLoader(jobRegistry, stepRegistry);
|
||||
|
||||
@Test
|
||||
public void testClear() throws Exception {
|
||||
void testClear() throws Exception {
|
||||
GenericApplicationContextFactory factory = new GenericApplicationContextFactory(
|
||||
new ByteArrayResource(JOB_XML.getBytes()));
|
||||
jobLoader.load(factory);
|
||||
@@ -75,7 +75,7 @@ public class DefaultJobLoaderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLoadWithExplicitName() throws Exception {
|
||||
void testLoadWithExplicitName() throws Exception {
|
||||
GenericApplicationContextFactory factory = new GenericApplicationContextFactory(
|
||||
new ByteArrayResource(JOB_XML.getBytes()));
|
||||
jobLoader.load(factory);
|
||||
@@ -85,7 +85,7 @@ public class DefaultJobLoaderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createWithBothRegistries() {
|
||||
void createWithBothRegistries() {
|
||||
final DefaultJobLoader loader = new DefaultJobLoader();
|
||||
loader.setJobRegistry(jobRegistry);
|
||||
loader.setStepRegistry(stepRegistry);
|
||||
@@ -94,7 +94,7 @@ public class DefaultJobLoaderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createWithOnlyJobRegistry() {
|
||||
void createWithOnlyJobRegistry() {
|
||||
final DefaultJobLoader loader = new DefaultJobLoader();
|
||||
loader.setJobRegistry(jobRegistry);
|
||||
|
||||
@@ -102,7 +102,7 @@ public class DefaultJobLoaderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRegistryUpdated() throws DuplicateJobException {
|
||||
void testRegistryUpdated() throws DuplicateJobException {
|
||||
GenericApplicationContextFactory factory = new GenericApplicationContextFactory(
|
||||
new ClassPathResource("trivial-context.xml", getClass()));
|
||||
jobLoader.load(factory);
|
||||
@@ -111,7 +111,7 @@ public class DefaultJobLoaderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultipleJobsInTheSameContext() throws DuplicateJobException {
|
||||
void testMultipleJobsInTheSameContext() throws DuplicateJobException {
|
||||
GenericApplicationContextFactory factory = new GenericApplicationContextFactory(
|
||||
new ClassPathResource("job-context-with-steps.xml", getClass()));
|
||||
jobLoader.load(factory);
|
||||
@@ -123,7 +123,7 @@ public class DefaultJobLoaderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultipleJobsInTheSameContextWithSeparateSteps() throws DuplicateJobException {
|
||||
void testMultipleJobsInTheSameContextWithSeparateSteps() throws DuplicateJobException {
|
||||
GenericApplicationContextFactory factory = new GenericApplicationContextFactory(
|
||||
new ClassPathResource("job-context-with-separate-steps.xml", getClass()));
|
||||
jobLoader.load(factory);
|
||||
@@ -135,7 +135,7 @@ public class DefaultJobLoaderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoStepRegistryAvailable() throws DuplicateJobException {
|
||||
void testNoStepRegistryAvailable() throws DuplicateJobException {
|
||||
final JobLoader loader = new DefaultJobLoader(jobRegistry);
|
||||
GenericApplicationContextFactory factory = new GenericApplicationContextFactory(
|
||||
new ClassPathResource("job-context-with-steps.xml", getClass()));
|
||||
@@ -145,36 +145,22 @@ public class DefaultJobLoaderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLoadWithJobThatIsNotAStepLocator() throws DuplicateJobException {
|
||||
void testLoadWithJobThatIsNotAStepLocator() {
|
||||
GenericApplicationContextFactory factory = new GenericApplicationContextFactory(
|
||||
new ByteArrayResource(BASIC_JOB_XML.getBytes()));
|
||||
try {
|
||||
jobLoader.load(factory);
|
||||
fail("Should have failed with a [" + UnsupportedOperationException.class.getName() + "] as job does not"
|
||||
+ "implement StepLocator.");
|
||||
}
|
||||
catch (UnsupportedOperationException e) {
|
||||
// Job is not a step locator, can't register steps
|
||||
}
|
||||
|
||||
assertThrows(UnsupportedOperationException.class, () -> jobLoader.load(factory));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLoadWithJobThatIsNotAStepLocatorNoStepRegistry() throws DuplicateJobException {
|
||||
void testLoadWithJobThatIsNotAStepLocatorNoStepRegistry() {
|
||||
final JobLoader loader = new DefaultJobLoader(jobRegistry);
|
||||
GenericApplicationContextFactory factory = new GenericApplicationContextFactory(
|
||||
new ByteArrayResource(BASIC_JOB_XML.getBytes()));
|
||||
try {
|
||||
loader.load(factory);
|
||||
}
|
||||
catch (UnsupportedOperationException e) {
|
||||
fail("Should not have failed with a [" + UnsupportedOperationException.class.getName() + "] as "
|
||||
+ "stepRegistry is not available for this JobLoader instance.");
|
||||
}
|
||||
assertDoesNotThrow(() -> loader.load(factory));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReload() throws Exception {
|
||||
void testReload() throws Exception {
|
||||
GenericApplicationContextFactory factory = new GenericApplicationContextFactory(
|
||||
new ClassPathResource("trivial-context.xml", getClass()));
|
||||
jobLoader.load(factory);
|
||||
@@ -186,7 +172,7 @@ public class DefaultJobLoaderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReloadWithAutoRegister() throws Exception {
|
||||
void testReloadWithAutoRegister() throws Exception {
|
||||
GenericApplicationContextFactory factory = new GenericApplicationContextFactory(
|
||||
new ClassPathResource("trivial-context-autoregister.xml", getClass()));
|
||||
jobLoader.load(factory);
|
||||
@@ -199,31 +185,13 @@ public class DefaultJobLoaderTests {
|
||||
|
||||
protected void assertStepExist(String jobName, String... stepNames) {
|
||||
for (String stepName : stepNames) {
|
||||
try {
|
||||
stepRegistry.getStep(jobName, stepName);
|
||||
}
|
||||
catch (NoSuchJobException e) {
|
||||
fail("Job with name [" + jobName + "] should have been found.");
|
||||
}
|
||||
catch (NoSuchStepException e) {
|
||||
fail("Step with name [" + stepName + "] for job [" + jobName + "] should have been found.");
|
||||
}
|
||||
assertDoesNotThrow(() -> stepRegistry.getStep(jobName, stepName));
|
||||
}
|
||||
}
|
||||
|
||||
protected void assertStepDoNotExist(String jobName, String... stepNames) {
|
||||
for (String stepName : stepNames) {
|
||||
try {
|
||||
final Step step = stepRegistry.getStep(jobName, stepName);
|
||||
fail("Step with name [" + stepName + "] for job [" + jobName + "] should "
|
||||
+ "not have been found but got [" + step + "]");
|
||||
}
|
||||
catch (NoSuchJobException e) {
|
||||
fail("Job with name [" + jobName + "] should have been found.");
|
||||
}
|
||||
catch (NoSuchStepException e) {
|
||||
// OK
|
||||
}
|
||||
assertThrows(NoSuchStepException.class, () -> stepRegistry.getStep(jobName, stepName));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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,12 +15,13 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.support;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
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.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.core.Job;
|
||||
import org.springframework.batch.core.job.JobSupport;
|
||||
@@ -47,28 +48,26 @@ import org.springframework.util.ClassUtils;
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
*/
|
||||
public class GenericApplicationContextFactoryTests {
|
||||
class GenericApplicationContextFactoryTests {
|
||||
|
||||
@Test
|
||||
public void testCreateJob() {
|
||||
void testCreateJob() {
|
||||
GenericApplicationContextFactory factory = new GenericApplicationContextFactory(
|
||||
new ClassPathResource(ClassUtils.addResourcePathToPackagePath(getClass(), "trivial-context.xml")));
|
||||
@SuppressWarnings("resource")
|
||||
ConfigurableApplicationContext context = factory.createApplicationContext();
|
||||
assertNotNull(context);
|
||||
assertTrue("Wrong id: " + context, context.getId().contains("trivial-context.xml"));
|
||||
assertTrue(context.getId().contains("trivial-context.xml"), "Wrong id: " + context);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetJobName() {
|
||||
void testGetJobName() {
|
||||
GenericApplicationContextFactory factory = new GenericApplicationContextFactory(
|
||||
new ClassPathResource(ClassUtils.addResourcePathToPackagePath(getClass(), "trivial-context.xml")));
|
||||
assertEquals("test-job", factory.createApplicationContext().getBeanNamesForType(Job.class)[0]);
|
||||
}
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
@Test
|
||||
public void testParentConfigurationInherited() {
|
||||
void testParentConfigurationInherited() {
|
||||
GenericApplicationContextFactory factory = new GenericApplicationContextFactory(
|
||||
new ClassPathResource(ClassUtils.addResourcePathToPackagePath(getClass(), "child-context.xml")));
|
||||
factory.setApplicationContext(new ClassPathXmlApplicationContext(
|
||||
@@ -79,9 +78,8 @@ public class GenericApplicationContextFactoryTests {
|
||||
assertEquals(4, context.getBean("foo", Foo.class).values[1], 0.01);
|
||||
}
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
@Test
|
||||
public void testBeanFactoryPostProcessorOrderRespected() {
|
||||
void testBeanFactoryPostProcessorOrderRespected() {
|
||||
GenericApplicationContextFactory factory = new GenericApplicationContextFactory(
|
||||
new ClassPathResource(ClassUtils.addResourcePathToPackagePath(getClass(), "placeholder-context.xml")));
|
||||
factory.setApplicationContext(new ClassPathXmlApplicationContext(
|
||||
@@ -91,26 +89,24 @@ public class GenericApplicationContextFactoryTests {
|
||||
assertEquals("spam", context.getBean("test-job", Job.class).getName());
|
||||
}
|
||||
|
||||
// FIXME replacing PropertyPlaceholderConfigurer with
|
||||
// PropertySourcesPlaceholderConfigurer does not seem to inherit profiles
|
||||
@Test
|
||||
@Ignore // FIXME replacing PropertyPlaceholderConfigurer with
|
||||
// PropertySourcesPlaceholderConfigurer does not seem to inherit profiles
|
||||
public void testBeanFactoryProfileRespected() {
|
||||
@Disabled
|
||||
void testBeanFactoryProfileRespected() {
|
||||
GenericApplicationContextFactory factory = new GenericApplicationContextFactory(
|
||||
new ClassPathResource(ClassUtils.addResourcePathToPackagePath(getClass(), "profiles.xml")));
|
||||
@SuppressWarnings("resource")
|
||||
ClassPathXmlApplicationContext parentContext = new ClassPathXmlApplicationContext(
|
||||
ClassUtils.addResourcePathToPackagePath(getClass(), "parent-context.xml"));
|
||||
parentContext.getEnvironment().setActiveProfiles("preferred");
|
||||
factory.setApplicationContext(parentContext);
|
||||
@SuppressWarnings("resource")
|
||||
ConfigurableApplicationContext context = factory.createApplicationContext();
|
||||
assertEquals("test-job", context.getBeanNamesForType(Job.class)[0]);
|
||||
assertEquals("spam", context.getBean("test-job", Job.class).getName());
|
||||
}
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
@Test
|
||||
public void testBeanFactoryPostProcessorsNotCopied() {
|
||||
void testBeanFactoryPostProcessorsNotCopied() {
|
||||
GenericApplicationContextFactory factory = new GenericApplicationContextFactory(
|
||||
new ClassPathResource(ClassUtils.addResourcePathToPackagePath(getClass(), "child-context.xml")));
|
||||
factory.setApplicationContext(new ClassPathXmlApplicationContext(
|
||||
@@ -124,9 +120,8 @@ public class GenericApplicationContextFactoryTests {
|
||||
assertEquals(4, context.getBean("foo", Foo.class).values[1], 0.01);
|
||||
}
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
@Test
|
||||
public void testBeanFactoryConfigurationNotCopied() {
|
||||
void testBeanFactoryConfigurationNotCopied() {
|
||||
GenericApplicationContextFactory factory = new GenericApplicationContextFactory(
|
||||
new ClassPathResource(ClassUtils.addResourcePathToPackagePath(getClass(), "child-context.xml")));
|
||||
factory.setApplicationContext(new ClassPathXmlApplicationContext(
|
||||
@@ -141,7 +136,7 @@ public class GenericApplicationContextFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEquals() throws Exception {
|
||||
void testEquals() {
|
||||
Resource resource = new ClassPathResource(
|
||||
ClassUtils.addResourcePathToPackagePath(getClass(), "child-context.xml"));
|
||||
GenericApplicationContextFactory factory = new GenericApplicationContextFactory(resource);
|
||||
@@ -151,7 +146,7 @@ public class GenericApplicationContextFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEqualsMultipleConfigs() throws Exception {
|
||||
void testEqualsMultipleConfigs() {
|
||||
Resource resource1 = new ClassPathResource(
|
||||
ClassUtils.addResourcePathToPackagePath(getClass(), "abstract-context.xml"));
|
||||
Resource resource2 = new ClassPathResource(
|
||||
@@ -163,7 +158,7 @@ public class GenericApplicationContextFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParentConfigurationInheritedMultipleConfigs() {
|
||||
void testParentConfigurationInheritedMultipleConfigs() {
|
||||
Resource resource1 = new ClassPathResource(
|
||||
ClassUtils.addResourcePathToPackagePath(getClass(), "abstract-context.xml"));
|
||||
Resource resource2 = new ClassPathResource(
|
||||
@@ -185,17 +180,17 @@ public class GenericApplicationContextFactoryTests {
|
||||
assertTrue(autowiredFound);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testDifferentResourceTypes() throws Exception {
|
||||
@Test
|
||||
void testDifferentResourceTypes() {
|
||||
Resource resource1 = new ClassPathResource(
|
||||
ClassUtils.addResourcePathToPackagePath(getClass(), "abstract-context.xml"));
|
||||
GenericApplicationContextFactory factory = new GenericApplicationContextFactory(resource1,
|
||||
Configuration1.class);
|
||||
factory.createApplicationContext();
|
||||
assertThrows(IllegalArgumentException.class, factory::createApplicationContext);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPackageScanning() throws Exception {
|
||||
void testPackageScanning() {
|
||||
GenericApplicationContextFactory factory = new GenericApplicationContextFactory(
|
||||
"org.springframework.batch.core.configuration.support");
|
||||
ConfigurableApplicationContext context = factory.createApplicationContext();
|
||||
@@ -207,7 +202,7 @@ public class GenericApplicationContextFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultipleConfigurationClasses() throws Exception {
|
||||
void testMultipleConfigurationClasses() {
|
||||
GenericApplicationContextFactory factory = new GenericApplicationContextFactory(Configuration1.class,
|
||||
Configuration2.class);
|
||||
ConfigurableApplicationContext context = factory.createApplicationContext();
|
||||
@@ -219,7 +214,7 @@ public class GenericApplicationContextFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParentChildLifecycleEvents() throws InterruptedException {
|
||||
void testParentChildLifecycleEvents() {
|
||||
AnnotationConfigApplicationContext parent = new AnnotationConfigApplicationContext(ParentContext.class);
|
||||
GenericApplicationContextFactory child = new GenericApplicationContextFactory(ChildContextConfiguration.class);
|
||||
child.setApplicationContext(parent);
|
||||
|
||||
@@ -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,9 +15,9 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.support;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.core.Job;
|
||||
import org.springframework.batch.core.job.JobSupport;
|
||||
|
||||
@@ -25,24 +25,24 @@ import org.springframework.batch.core.job.JobSupport;
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class GroupAwareJobTests {
|
||||
class GroupAwareJobTests {
|
||||
|
||||
private Job job = new JobSupport("foo");
|
||||
private final Job job = new JobSupport("foo");
|
||||
|
||||
@Test
|
||||
public void testCreateJob() {
|
||||
void testCreateJob() {
|
||||
GroupAwareJob result = new GroupAwareJob(job);
|
||||
assertEquals("foo", result.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetJobName() {
|
||||
void testGetJobName() {
|
||||
GroupAwareJob result = new GroupAwareJob("jobs", job);
|
||||
assertEquals("jobs.foo", result.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToString() {
|
||||
void testToString() {
|
||||
GroupAwareJob result = new GroupAwareJob("jobs", job);
|
||||
assertEquals("JobSupport: [name=jobs.foo]", result.toString());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2013 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,9 +15,9 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.support;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.core.Job;
|
||||
import org.springframework.batch.core.configuration.JobFactory;
|
||||
|
||||
@@ -25,19 +25,14 @@ import org.springframework.batch.core.configuration.JobFactory;
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class JobFactoryRegistrationListenerTests {
|
||||
class JobFactoryRegistrationListenerTests {
|
||||
|
||||
private JobFactoryRegistrationListener listener = new JobFactoryRegistrationListener();
|
||||
private final JobFactoryRegistrationListener listener = new JobFactoryRegistrationListener();
|
||||
|
||||
private MapJobRegistry registry = new MapJobRegistry();
|
||||
private final MapJobRegistry registry = new MapJobRegistry();
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.configuration.support.JobFactoryRegistrationListener#bind(org.springframework.batch.core.configuration.JobFactory, java.util.Map)}.
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testBind() throws Exception {
|
||||
void testBind() throws Exception {
|
||||
listener.setJobRegistry(registry);
|
||||
listener.bind(new JobFactory() {
|
||||
@Override
|
||||
@@ -53,13 +48,8 @@ public class JobFactoryRegistrationListenerTests {
|
||||
assertEquals(1, registry.getJobNames().size());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.configuration.support.JobFactoryRegistrationListener#unbind(org.springframework.batch.core.configuration.JobFactory, java.util.Map)}.
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testUnbind() throws Exception {
|
||||
void testUnbind() throws Exception {
|
||||
testBind();
|
||||
listener.unbind(new JobFactory() {
|
||||
@Override
|
||||
|
||||
@@ -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,14 +15,14 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.support;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
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.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.core.configuration.DuplicateJobException;
|
||||
import org.springframework.batch.core.job.JobSupport;
|
||||
import org.springframework.beans.FatalBeanException;
|
||||
@@ -30,38 +30,32 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class JobRegistryBeanPostProcessorTests {
|
||||
class JobRegistryBeanPostProcessorTests {
|
||||
|
||||
private JobRegistryBeanPostProcessor processor = new JobRegistryBeanPostProcessor();
|
||||
private final JobRegistryBeanPostProcessor processor = new JobRegistryBeanPostProcessor();
|
||||
|
||||
@Test
|
||||
public void testInitializationFails() throws Exception {
|
||||
try {
|
||||
processor.afterPropertiesSet();
|
||||
fail("Expected IllegalArgumentException");
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
// expected
|
||||
assertTrue(e.getMessage().contains("JobRegistry"));
|
||||
}
|
||||
void testInitializationFails() {
|
||||
Exception exception = assertThrows(IllegalArgumentException.class, processor::afterPropertiesSet);
|
||||
assertTrue(exception.getMessage().contains("JobRegistry"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBeforeInitialization() throws Exception {
|
||||
void testBeforeInitialization() {
|
||||
// should be a no-op
|
||||
assertEquals("foo", processor.postProcessBeforeInitialization("foo", "bar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAfterInitializationWithWrongType() throws Exception {
|
||||
void testAfterInitializationWithWrongType() {
|
||||
// should be a no-op
|
||||
assertEquals("foo", processor.postProcessAfterInitialization("foo", "bar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAfterInitializationWithCorrectType() throws Exception {
|
||||
void testAfterInitializationWithCorrectType() {
|
||||
MapJobRegistry registry = new MapJobRegistry();
|
||||
processor.setJobRegistry(registry);
|
||||
JobSupport job = new JobSupport();
|
||||
@@ -71,7 +65,7 @@ public class JobRegistryBeanPostProcessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAfterInitializationWithGroupName() throws Exception {
|
||||
void testAfterInitializationWithGroupName() {
|
||||
MapJobRegistry registry = new MapJobRegistry();
|
||||
processor.setJobRegistry(registry);
|
||||
processor.setGroupName("jobs");
|
||||
@@ -82,24 +76,19 @@ public class JobRegistryBeanPostProcessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAfterInitializationWithDuplicate() throws Exception {
|
||||
void testAfterInitializationWithDuplicate() {
|
||||
MapJobRegistry registry = new MapJobRegistry();
|
||||
processor.setJobRegistry(registry);
|
||||
JobSupport job = new JobSupport();
|
||||
job.setBeanName("foo");
|
||||
processor.postProcessAfterInitialization(job, "bar");
|
||||
try {
|
||||
processor.postProcessAfterInitialization(job, "spam");
|
||||
fail("Expected FatalBeanException");
|
||||
}
|
||||
catch (FatalBeanException e) {
|
||||
// Expected
|
||||
assertTrue(e.getCause() instanceof DuplicateJobException);
|
||||
}
|
||||
Exception exception = assertThrows(FatalBeanException.class,
|
||||
() -> processor.postProcessAfterInitialization(job, "spam"));
|
||||
assertTrue(exception.getCause() instanceof DuplicateJobException);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnregisterOnDestroy() throws Exception {
|
||||
void testUnregisterOnDestroy() throws Exception {
|
||||
MapJobRegistry registry = new MapJobRegistry();
|
||||
processor.setJobRegistry(registry);
|
||||
JobSupport job = new JobSupport();
|
||||
@@ -110,8 +99,7 @@ public class JobRegistryBeanPostProcessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void testExecutionWithApplicationContext() throws Exception {
|
||||
void testExecutionWithApplicationContext() throws Exception {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("test-context.xml", getClass());
|
||||
MapJobRegistry registry = (MapJobRegistry) context.getBean("registry");
|
||||
Collection<String> configurations = registry.getJobNames();
|
||||
|
||||
@@ -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,23 +15,20 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.support;
|
||||
|
||||
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.Job;
|
||||
import org.springframework.batch.core.configuration.JobRegistry;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class JobRegistryIntegrationTests {
|
||||
@SpringJUnitConfig
|
||||
class JobRegistryIntegrationTests {
|
||||
|
||||
@Autowired
|
||||
private JobRegistry jobRegistry;
|
||||
@@ -40,7 +37,7 @@ public class JobRegistryIntegrationTests {
|
||||
private Job job;
|
||||
|
||||
@Test
|
||||
public void testRegistry() throws Exception {
|
||||
void testRegistry() {
|
||||
assertEquals(1, jobRegistry.getJobNames().size());
|
||||
assertEquals(job.getName(), jobRegistry.getJobNames().iterator().next());
|
||||
}
|
||||
|
||||
@@ -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,79 +17,52 @@ package org.springframework.batch.core.configuration.support;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.core.configuration.DuplicateJobException;
|
||||
import org.springframework.batch.core.configuration.JobFactory;
|
||||
import org.springframework.batch.core.job.JobSupport;
|
||||
import org.springframework.batch.core.launch.NoSuchJobException;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class MapJobRegistryTests extends TestCase {
|
||||
class MapJobRegistryTests {
|
||||
|
||||
private MapJobRegistry registry = new MapJobRegistry();
|
||||
private final MapJobRegistry registry = new MapJobRegistry();
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.configuration.support.MapJobRegistry#unregister(String)}.
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testUnregister() throws Exception {
|
||||
@Test
|
||||
void testUnregister() throws Exception {
|
||||
registry.register(new ReferenceJobFactory(new JobSupport("foo")));
|
||||
assertNotNull(registry.getJob("foo"));
|
||||
registry.unregister("foo");
|
||||
try {
|
||||
assertNull(registry.getJob("foo"));
|
||||
fail("Expected NoSuchJobConfigurationException");
|
||||
}
|
||||
catch (NoSuchJobException e) {
|
||||
// expected
|
||||
assertTrue(e.getMessage().indexOf("foo") >= 0);
|
||||
}
|
||||
Exception exception = assertThrows(NoSuchJobException.class, () -> registry.getJob("foo"));
|
||||
assertTrue(exception.getMessage().contains("foo"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.configuration.support.MapJobRegistry#getJob(java.lang.String)}.
|
||||
*/
|
||||
public void testReplaceDuplicateConfiguration() throws Exception {
|
||||
@Test
|
||||
void testReplaceDuplicateConfiguration() throws Exception {
|
||||
registry.register(new ReferenceJobFactory(new JobSupport("foo")));
|
||||
try {
|
||||
registry.register(new ReferenceJobFactory(new JobSupport("foo")));
|
||||
fail("Expected DuplicateJobConfigurationException");
|
||||
}
|
||||
catch (DuplicateJobException e) {
|
||||
// unexpected: even if the job is different we want a DuplicateJobException
|
||||
assertTrue(e.getMessage().indexOf("foo") >= 0);
|
||||
}
|
||||
JobFactory jobFactory = new ReferenceJobFactory(new JobSupport("foo"));
|
||||
Exception exception = assertThrows(DuplicateJobException.class, () -> registry.register(jobFactory));
|
||||
assertTrue(exception.getMessage().contains("foo"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.configuration.support.MapJobRegistry#getJob(java.lang.String)}.
|
||||
*/
|
||||
public void testRealDuplicateConfiguration() throws Exception {
|
||||
@Test
|
||||
void testRealDuplicateConfiguration() throws Exception {
|
||||
JobFactory jobFactory = new ReferenceJobFactory(new JobSupport("foo"));
|
||||
registry.register(jobFactory);
|
||||
try {
|
||||
registry.register(jobFactory);
|
||||
fail("Unexpected DuplicateJobConfigurationException");
|
||||
}
|
||||
catch (DuplicateJobException e) {
|
||||
// expected
|
||||
assertTrue(e.getMessage().indexOf("foo") >= 0);
|
||||
}
|
||||
Exception exception = assertThrows(DuplicateJobException.class, () -> registry.register(jobFactory));
|
||||
assertTrue(exception.getMessage().contains("foo"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.configuration.support.MapJobRegistry#getJobNames()}.
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testGetJobConfigurations() throws Exception {
|
||||
@Test
|
||||
void testGetJobConfigurations() throws Exception {
|
||||
JobFactory jobFactory = new ReferenceJobFactory(new JobSupport("foo"));
|
||||
registry.register(jobFactory);
|
||||
registry.register(new ReferenceJobFactory(new JobSupport("bar")));
|
||||
|
||||
@@ -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,14 +15,14 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.support;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.core.Step;
|
||||
import org.springframework.batch.core.configuration.DuplicateJobException;
|
||||
import org.springframework.batch.core.configuration.StepRegistry;
|
||||
@@ -33,43 +33,29 @@ import org.springframework.batch.core.step.tasklet.TaskletStep;
|
||||
/**
|
||||
* @author Sebastien Gerard
|
||||
*/
|
||||
public class MapStepRegistryTests {
|
||||
|
||||
private static final String EXCEPTION_NOT_THROWN_MSG = "An exception should have been thrown";
|
||||
class MapStepRegistryTests {
|
||||
|
||||
@Test
|
||||
public void registerStepEmptyCollection() throws DuplicateJobException {
|
||||
void registerStepEmptyCollection() throws DuplicateJobException {
|
||||
final StepRegistry stepRegistry = createRegistry();
|
||||
|
||||
launchRegisterGetRegistered(stepRegistry, "myJob", getStepCollection());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void registerStepNullJobName() throws DuplicateJobException {
|
||||
final StepRegistry stepRegistry = createRegistry();
|
||||
|
||||
try {
|
||||
stepRegistry.register(null, new HashSet<>());
|
||||
Assert.fail(EXCEPTION_NOT_THROWN_MSG);
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
}
|
||||
void registerStepNullJobName() {
|
||||
StepRegistry stepRegistry = createRegistry();
|
||||
assertThrows(IllegalArgumentException.class, () -> stepRegistry.register(null, new HashSet<>()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void registerStepNullSteps() throws DuplicateJobException {
|
||||
final StepRegistry stepRegistry = createRegistry();
|
||||
|
||||
try {
|
||||
stepRegistry.register("fdsfsd", null);
|
||||
Assert.fail(EXCEPTION_NOT_THROWN_MSG);
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
}
|
||||
void registerStepNullSteps() {
|
||||
StepRegistry stepRegistry = createRegistry();
|
||||
assertThrows(IllegalArgumentException.class, () -> stepRegistry.register("fdsfsd", null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void registerStepGetStep() throws DuplicateJobException {
|
||||
void registerStepGetStep() throws DuplicateJobException {
|
||||
final StepRegistry stepRegistry = createRegistry();
|
||||
|
||||
launchRegisterGetRegistered(stepRegistry, "myJob",
|
||||
@@ -77,7 +63,7 @@ public class MapStepRegistryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getJobNotRegistered() throws DuplicateJobException {
|
||||
void getJobNotRegistered() throws DuplicateJobException {
|
||||
final StepRegistry stepRegistry = createRegistry();
|
||||
|
||||
final String aStepName = "myStep";
|
||||
@@ -88,14 +74,14 @@ public class MapStepRegistryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getJobNotRegisteredNoRegistration() {
|
||||
void getJobNotRegisteredNoRegistration() {
|
||||
final StepRegistry stepRegistry = createRegistry();
|
||||
|
||||
assertJobNotRegistered(stepRegistry, "a ghost");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getStepNotRegistered() throws DuplicateJobException {
|
||||
void getStepNotRegistered() throws DuplicateJobException {
|
||||
final StepRegistry stepRegistry = createRegistry();
|
||||
|
||||
final String jobName = "myJob";
|
||||
@@ -106,7 +92,7 @@ public class MapStepRegistryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void registerTwice() throws DuplicateJobException {
|
||||
void registerTwice() throws DuplicateJobException {
|
||||
final StepRegistry stepRegistry = createRegistry();
|
||||
|
||||
final String jobName = "myJob";
|
||||
@@ -117,44 +103,27 @@ public class MapStepRegistryTests {
|
||||
launchRegisterGetRegistered(stepRegistry, jobName, stepsFirstRegistration);
|
||||
|
||||
// Second registration with same name should fail
|
||||
try {
|
||||
stepRegistry.register(jobName, getStepCollection(createStep("myFourthStep"), createStep("lastOne")));
|
||||
fail("Should have failed with a " + DuplicateJobException.class.getSimpleName());
|
||||
}
|
||||
catch (DuplicateJobException e) {
|
||||
// OK
|
||||
}
|
||||
assertThrows(DuplicateJobException.class, () -> stepRegistry.register(jobName,
|
||||
getStepCollection(createStep("myFourthStep"), createStep("lastOne"))));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getStepNullJobName() throws NoSuchJobException {
|
||||
final StepRegistry stepRegistry = createRegistry();
|
||||
|
||||
try {
|
||||
stepRegistry.getStep(null, "a step");
|
||||
Assert.fail(EXCEPTION_NOT_THROWN_MSG);
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
}
|
||||
void getStepNullJobName() {
|
||||
StepRegistry stepRegistry = createRegistry();
|
||||
assertThrows(IllegalArgumentException.class, () -> stepRegistry.getStep(null, "a step"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getStepNullStepName() throws NoSuchJobException, DuplicateJobException {
|
||||
void getStepNullStepName() throws DuplicateJobException {
|
||||
final StepRegistry stepRegistry = createRegistry();
|
||||
|
||||
final String stepName = "myStep";
|
||||
launchRegisterGetRegistered(stepRegistry, "myJob", getStepCollection(createStep(stepName)));
|
||||
|
||||
try {
|
||||
stepRegistry.getStep(null, stepName);
|
||||
Assert.fail(EXCEPTION_NOT_THROWN_MSG);
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
}
|
||||
assertThrows(IllegalArgumentException.class, () -> stepRegistry.getStep(null, stepName));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void registerStepUnregisterJob() throws DuplicateJobException {
|
||||
void registerStepUnregisterJob() throws DuplicateJobException {
|
||||
final StepRegistry stepRegistry = createRegistry();
|
||||
|
||||
final Collection<Step> steps = getStepCollection(createStep("myStep"), createStep("myOtherStep"),
|
||||
@@ -168,19 +137,13 @@ public class MapStepRegistryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unregisterJobNameNull() {
|
||||
final StepRegistry stepRegistry = createRegistry();
|
||||
|
||||
try {
|
||||
stepRegistry.unregisterStepsFromJob(null);
|
||||
Assert.fail(EXCEPTION_NOT_THROWN_MSG);
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
}
|
||||
void unregisterJobNameNull() {
|
||||
StepRegistry stepRegistry = createRegistry();
|
||||
assertThrows(IllegalArgumentException.class, () -> stepRegistry.unregisterStepsFromJob(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unregisterNoRegistration() {
|
||||
void unregisterNoRegistration() {
|
||||
final StepRegistry stepRegistry = createRegistry();
|
||||
|
||||
assertJobNotRegistered(stepRegistry, "a job");
|
||||
@@ -205,22 +168,12 @@ public class MapStepRegistryTests {
|
||||
}
|
||||
|
||||
protected void assertJobNotRegistered(StepRegistry stepRegistry, String jobName) {
|
||||
try {
|
||||
stepRegistry.getStep(jobName, "a step");
|
||||
Assert.fail(EXCEPTION_NOT_THROWN_MSG);
|
||||
}
|
||||
catch (NoSuchJobException e) {
|
||||
}
|
||||
assertThrows(NoSuchJobException.class, () -> stepRegistry.getStep(jobName, "a step"));
|
||||
}
|
||||
|
||||
protected void assertStepsRegistered(StepRegistry stepRegistry, String jobName, Collection<Step> steps) {
|
||||
for (Step step : steps) {
|
||||
try {
|
||||
stepRegistry.getStep(jobName, step.getName());
|
||||
}
|
||||
catch (NoSuchJobException e) {
|
||||
Assert.fail("Unexpected exception " + e);
|
||||
}
|
||||
assertDoesNotThrow(() -> stepRegistry.getStep(jobName, step.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,15 +184,7 @@ public class MapStepRegistryTests {
|
||||
}
|
||||
|
||||
protected void assertStepNameNotRegistered(StepRegistry stepRegistry, String jobName, String stepName) {
|
||||
try {
|
||||
stepRegistry.getStep(jobName, stepName);
|
||||
Assert.fail(EXCEPTION_NOT_THROWN_MSG);
|
||||
}
|
||||
catch (NoSuchJobException e) {
|
||||
Assert.fail("Unexpected exception");
|
||||
}
|
||||
catch (NoSuchStepException e) {
|
||||
}
|
||||
assertThrows(NoSuchStepException.class, () -> stepRegistry.getStep(jobName, stepName));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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,19 +15,19 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.support;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.core.job.JobSupport;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class ReferenceJobFactoryTests {
|
||||
class ReferenceJobFactoryTests {
|
||||
|
||||
@Test
|
||||
public void testGroupName() throws Exception {
|
||||
void testGroupName() {
|
||||
ReferenceJobFactory factory = new ReferenceJobFactory(new JobSupport("foo"));
|
||||
assertEquals("foo", factory.getJobName());
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -17,7 +17,7 @@ package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
||||
import org.springframework.batch.core.Job;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
@@ -29,8 +29,6 @@ import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.core.repository.JobRestartException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
* @author Dan Garrette
|
||||
* @author Mahmoud Ben Hassine
|
||||
@@ -47,8 +45,8 @@ public abstract class AbstractJobParserTests {
|
||||
@Autowired
|
||||
protected ArrayList<String> stepNamesList = new ArrayList<>();
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
stepNamesList.clear();
|
||||
}
|
||||
|
||||
@@ -67,8 +65,7 @@ public abstract class AbstractJobParserTests {
|
||||
return stepExecution;
|
||||
}
|
||||
}
|
||||
fail("No stepExecution found with name: [" + stepName + "]");
|
||||
return null;
|
||||
throw new AssertionError("No stepExecution found with name: [" + stepName + "]");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013 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,11 +15,11 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.core.scope.JobScope;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
@@ -28,24 +28,22 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
* @author Thomas Risberg
|
||||
* @author Jimmy Praet
|
||||
*/
|
||||
public class AutoRegisteringJobScopeTests {
|
||||
class AutoRegisteringJobScopeTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void testJobElement() throws Exception {
|
||||
void testJobElement() {
|
||||
ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/AutoRegisteringJobScopeForJobElementTests-context.xml");
|
||||
Map<String, JobScope> beans = ctx.getBeansOfType(JobScope.class);
|
||||
assertTrue("JobScope not defined properly", beans.size() == 1);
|
||||
assertEquals(1, beans.size(), "JobScope not defined properly");
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void testStepElement() throws Exception {
|
||||
void testStepElement() {
|
||||
ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/AutoRegisteringJobScopeForStepElementTests-context.xml");
|
||||
Map<String, JobScope> beans = ctx.getBeansOfType(JobScope.class);
|
||||
assertTrue("JobScope not defined properly", beans.size() == 1);
|
||||
assertEquals(1, beans.size(), "JobScope not defined properly");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2009 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,36 +15,34 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.core.scope.StepScope;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* @author Thomas Risberg
|
||||
*/
|
||||
public class AutoRegisteringStepScopeTests {
|
||||
class AutoRegisteringStepScopeTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void testJobElement() throws Exception {
|
||||
void testJobElement() {
|
||||
ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/AutoRegisteringStepScopeForJobElementTests-context.xml");
|
||||
Map<String, StepScope> beans = ctx.getBeansOfType(StepScope.class);
|
||||
assertTrue("StepScope not defined properly", beans.size() == 1);
|
||||
assertEquals(1, beans.size(), "StepScope not defined properly");
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void testStepElement() throws Exception {
|
||||
void testStepElement() {
|
||||
ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/AutoRegisteringStepScopeForStepElementTests-context.xml");
|
||||
Map<String, StepScope> beans = ctx.getBeansOfType(StepScope.class);
|
||||
assertTrue("StepScope not defined properly", beans.size() == 1);
|
||||
assertEquals(1, beans.size(), "StepScope not defined properly");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
/**
|
||||
@@ -23,10 +23,10 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
* Test cases for BATCH-1863.
|
||||
* </p>
|
||||
*/
|
||||
public class BeanDefinitionOverrideTests {
|
||||
class BeanDefinitionOverrideTests {
|
||||
|
||||
@Test
|
||||
public void testAllowBeanOverride() {
|
||||
void testAllowBeanOverride() {
|
||||
ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext();
|
||||
applicationContext.setConfigLocation(
|
||||
"org/springframework/batch/core/configuration/xml/BeanDefinitionOverrideTests-context.xml");
|
||||
@@ -34,7 +34,7 @@ public class BeanDefinitionOverrideTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAllowBeanOverrideFalse() {
|
||||
void testAllowBeanOverrideFalse() {
|
||||
ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext();
|
||||
applicationContext.setAllowBeanDefinitionOverriding(false);
|
||||
applicationContext.setConfigLocation(
|
||||
|
||||
@@ -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,14 +15,13 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
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.Job;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
@@ -30,16 +29,14 @@ import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class BranchStepJobParserTests {
|
||||
@SpringJUnitConfig
|
||||
class BranchStepJobParserTests {
|
||||
|
||||
@Autowired
|
||||
private Job job;
|
||||
@@ -48,7 +45,7 @@ public class BranchStepJobParserTests {
|
||||
private JobRepository jobRepository;
|
||||
|
||||
@Test
|
||||
public void testBranchStep() throws Exception {
|
||||
void testBranchStep() throws Exception {
|
||||
assertNotNull(job);
|
||||
JobExecution jobExecution = jobRepository.createJobExecution(job.getName(), new JobParameters());
|
||||
job.execute(jobExecution);
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.core.Step;
|
||||
import org.springframework.batch.core.step.item.SimpleChunkProcessor;
|
||||
@@ -34,6 +34,7 @@ import org.springframework.classify.SubclassClassifier;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.core.NestedRuntimeException;
|
||||
import org.springframework.dao.CannotAcquireLockException;
|
||||
import org.springframework.dao.CannotSerializeTransactionException;
|
||||
import org.springframework.dao.ConcurrencyFailureException;
|
||||
@@ -45,11 +46,11 @@ import org.springframework.retry.policy.SimpleRetryPolicy;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
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.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.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* @author Dan Garrette
|
||||
@@ -57,56 +58,43 @@ import static org.junit.Assert.fail;
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @since 2.0
|
||||
*/
|
||||
public class ChunkElementParserTests {
|
||||
class ChunkElementParserTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void testSimpleAttributes() throws Exception {
|
||||
void testSimpleAttributes() {
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/ChunkElementSimpleAttributeParserTests-context.xml");
|
||||
Object step = context.getBean("s1", Step.class);
|
||||
assertNotNull("Step not parsed", step);
|
||||
assertNotNull(step, "Step not parsed");
|
||||
Object tasklet = ReflectionTestUtils.getField(step, "tasklet");
|
||||
Object chunkProcessor = ReflectionTestUtils.getField(tasklet, "chunkProcessor");
|
||||
assertTrue("Wrong processor type", chunkProcessor instanceof SimpleChunkProcessor);
|
||||
assertTrue(chunkProcessor instanceof SimpleChunkProcessor, "Wrong processor type");
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void testCommitIntervalLateBinding() throws Exception {
|
||||
void testCommitIntervalLateBinding() {
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/ChunkElementLateBindingParserTests-context.xml");
|
||||
Step step = context.getBean("s1", Step.class);
|
||||
assertNotNull("Step not parsed", step);
|
||||
assertNotNull(step, "Step not parsed");
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void testSkipAndRetryAttributes() throws Exception {
|
||||
void testSkipAndRetryAttributes() {
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/ChunkElementSkipAndRetryAttributeParserTests-context.xml");
|
||||
Step step = context.getBean("s1", Step.class);
|
||||
assertNotNull("Step not parsed", step);
|
||||
assertNotNull(step, "Step not parsed");
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void testIllegalSkipAndRetryAttributes() throws Exception {
|
||||
try {
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/ChunkElementIllegalSkipAndRetryAttributeParserTests-context.xml");
|
||||
Step step = context.getBean("s1", Step.class);
|
||||
assertNotNull("Step not parsed", step);
|
||||
fail("Expected BeanCreationException");
|
||||
}
|
||||
catch (BeanCreationException e) {
|
||||
// expected
|
||||
}
|
||||
void testIllegalSkipAndRetryAttributes() {
|
||||
assertThrows(BeanCreationException.class, () -> new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/ChunkElementIllegalSkipAndRetryAttributeParserTests-context.xml"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRetryPolicyAttribute() throws Exception {
|
||||
@SuppressWarnings("resource")
|
||||
void testRetryPolicyAttribute() throws Exception {
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/ChunkElementRetryPolicyParserTests-context.xml");
|
||||
Map<Class<? extends Throwable>, Boolean> retryable = getNestedExceptionMap("s1", context,
|
||||
@@ -118,8 +106,7 @@ public class ChunkElementParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRetryPolicyElement() throws Exception {
|
||||
@SuppressWarnings("resource")
|
||||
void testRetryPolicyElement() throws Exception {
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/ChunkElementRetryPolicyParserTests-context.xml");
|
||||
SimpleRetryPolicy policy = (SimpleRetryPolicy) getPolicy("s2", context,
|
||||
@@ -128,8 +115,7 @@ public class ChunkElementParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSkipPolicyAttribute() throws Exception {
|
||||
@SuppressWarnings("resource")
|
||||
void testSkipPolicyAttribute() throws Exception {
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/ChunkElementSkipPolicyParserTests-context.xml");
|
||||
SkipPolicy policy = getSkipPolicy("s1", context);
|
||||
@@ -138,8 +124,7 @@ public class ChunkElementParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSkipPolicyElement() throws Exception {
|
||||
@SuppressWarnings("resource")
|
||||
void testSkipPolicyElement() throws Exception {
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/ChunkElementSkipPolicyParserTests-context.xml");
|
||||
SkipPolicy policy = getSkipPolicy("s2", context);
|
||||
@@ -148,48 +133,41 @@ public class ChunkElementParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void testProcessorTransactionalAttributes() throws Exception {
|
||||
void testProcessorTransactionalAttributes() {
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/ChunkElementTransactionalAttributeParserTests-context.xml");
|
||||
Object step = context.getBean("s1", Step.class);
|
||||
assertNotNull("Step not parsed", step);
|
||||
assertNotNull(step, "Step not parsed");
|
||||
Object tasklet = ReflectionTestUtils.getField(step, "tasklet");
|
||||
Object chunkProcessor = ReflectionTestUtils.getField(tasklet, "chunkProcessor");
|
||||
Boolean processorTransactional = (Boolean) ReflectionTestUtils.getField(chunkProcessor,
|
||||
"processorTransactional");
|
||||
assertFalse("Flag not set", processorTransactional);
|
||||
assertFalse(processorTransactional, "Flag not set");
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void testProcessorTransactionalNotAllowedOnSimpleProcessor() throws Exception {
|
||||
void testProcessorTransactionalNotAllowedOnSimpleProcessor() {
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/ChunkElementIllegalAttributeParserTests-context.xml");
|
||||
Object step = context.getBean("s1", Step.class);
|
||||
assertNotNull("Step not parsed", step);
|
||||
assertNotNull(step, "Step not parsed");
|
||||
Object tasklet = ReflectionTestUtils.getField(step, "tasklet");
|
||||
Object chunkProcessor = ReflectionTestUtils.getField(tasklet, "chunkProcessor");
|
||||
assertTrue(chunkProcessor instanceof SimpleChunkProcessor<?, ?>);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessorNonTransactionalNotAllowedWithTransactionalReader() throws Exception {
|
||||
try {
|
||||
new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/ChunkElementIllegalTransactionalAttributeParserTests-context.xml");
|
||||
fail("Expected BeanCreationException");
|
||||
}
|
||||
catch (BeanCreationException e) {
|
||||
String msg = e.getRootCause().getMessage();
|
||||
assertTrue("Wrong message: " + msg,
|
||||
msg.contains("The field 'processor-transactional' cannot be false if 'reader-transactional"));
|
||||
}
|
||||
|
||||
void testProcessorNonTransactionalNotAllowedWithTransactionalReader() {
|
||||
NestedRuntimeException exception = assertThrows(BeanCreationException.class,
|
||||
() -> new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/ChunkElementIllegalTransactionalAttributeParserTests-context.xml"));
|
||||
String msg = exception.getRootCause().getMessage();
|
||||
assertTrue(msg.contains("The field 'processor-transactional' cannot be false if 'reader-transactional"),
|
||||
"Wrong message: " + msg);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRetryable() throws Exception {
|
||||
void testRetryable() throws Exception {
|
||||
Map<Class<? extends Throwable>, Boolean> retryable = getRetryableExceptionClasses("s1", getContext());
|
||||
System.err.println(retryable);
|
||||
assertEquals(3, retryable.size());
|
||||
@@ -198,7 +176,7 @@ public class ChunkElementParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRetryableInherited() throws Exception {
|
||||
void testRetryableInherited() throws Exception {
|
||||
Map<Class<? extends Throwable>, Boolean> retryable = getRetryableExceptionClasses("s3", getContext());
|
||||
System.err.println(retryable);
|
||||
assertEquals(2, retryable.size());
|
||||
@@ -206,7 +184,7 @@ public class ChunkElementParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRetryableInheritedMerge() throws Exception {
|
||||
void testRetryableInheritedMerge() throws Exception {
|
||||
Map<Class<? extends Throwable>, Boolean> retryable = getRetryableExceptionClasses("s4", getContext());
|
||||
System.err.println(retryable);
|
||||
assertEquals(3, retryable.size());
|
||||
@@ -214,7 +192,7 @@ public class ChunkElementParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInheritSkippable() throws Exception {
|
||||
void testInheritSkippable() throws Exception {
|
||||
Map<Class<? extends Throwable>, Boolean> skippable = getSkippableExceptionClasses("s1", getContext());
|
||||
System.err.println(skippable);
|
||||
assertEquals(5, skippable.size());
|
||||
@@ -225,7 +203,7 @@ public class ChunkElementParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInheritSkippableWithNoMerge() throws Exception {
|
||||
void testInheritSkippableWithNoMerge() throws Exception {
|
||||
Map<Class<? extends Throwable>, Boolean> skippable = getSkippableExceptionClasses("s2", getContext());
|
||||
assertEquals(3, skippable.size());
|
||||
containsClassified(skippable, IllegalArgumentException.class, true);
|
||||
@@ -235,7 +213,7 @@ public class ChunkElementParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInheritStreams() throws Exception {
|
||||
void testInheritStreams() throws Exception {
|
||||
Collection<ItemStream> streams = getStreams("s1", getContext());
|
||||
assertEquals(2, streams.size());
|
||||
boolean c = false;
|
||||
@@ -248,7 +226,7 @@ public class ChunkElementParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInheritRetryListeners() throws Exception {
|
||||
void testInheritRetryListeners() throws Exception {
|
||||
Collection<RetryListener> retryListeners = getRetryListeners("s1", getContext());
|
||||
assertEquals(2, retryListeners.size());
|
||||
boolean g = false;
|
||||
@@ -266,7 +244,7 @@ public class ChunkElementParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInheritStreamsWithNoMerge() throws Exception {
|
||||
void testInheritStreamsWithNoMerge() throws Exception {
|
||||
Collection<ItemStream> streams = getStreams("s2", getContext());
|
||||
assertEquals(1, streams.size());
|
||||
boolean c = false;
|
||||
@@ -279,7 +257,7 @@ public class ChunkElementParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInheritRetryListenersWithNoMerge() throws Exception {
|
||||
void testInheritRetryListenersWithNoMerge() throws Exception {
|
||||
Collection<RetryListener> retryListeners = getRetryListeners("s2", getContext());
|
||||
assertEquals(1, retryListeners.size());
|
||||
boolean h = false;
|
||||
|
||||
@@ -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,11 +15,10 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
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;
|
||||
@@ -31,16 +30,14 @@ import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class DecisionJobParserTests {
|
||||
@SpringJUnitConfig
|
||||
class DecisionJobParserTests {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("job")
|
||||
@@ -50,7 +47,7 @@ public class DecisionJobParserTests {
|
||||
private JobRepository jobRepository;
|
||||
|
||||
@Test
|
||||
public void testDecisionState() throws Exception {
|
||||
void testDecisionState() throws Exception {
|
||||
assertNotNull(job);
|
||||
JobExecution jobExecution = jobRepository.createJobExecution(job.getName(), new JobParameters());
|
||||
job.execute(jobExecution);
|
||||
|
||||
@@ -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,28 +15,25 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
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.core.BatchStatus;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
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
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class DefaultFailureJobParserTests extends AbstractJobParserTests {
|
||||
@SpringJUnitConfig
|
||||
class DefaultFailureJobParserTests extends AbstractJobParserTests {
|
||||
|
||||
@Test
|
||||
public void testDefaultFailure() throws Exception {
|
||||
void testDefaultFailure() throws Exception {
|
||||
|
||||
JobExecution jobExecution = createJobExecution();
|
||||
job.execute(jobExecution);
|
||||
|
||||
@@ -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,27 +15,24 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
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.ExitStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
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
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class DefaultSuccessJobParserTests extends AbstractJobParserTests {
|
||||
@SpringJUnitConfig
|
||||
class DefaultSuccessJobParserTests extends AbstractJobParserTests {
|
||||
|
||||
@Test
|
||||
public void testDefaultSuccess() throws Exception {
|
||||
void testDefaultSuccess() throws Exception {
|
||||
|
||||
JobExecution jobExecution = createJobExecution();
|
||||
job.execute(jobExecution);
|
||||
|
||||
@@ -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,30 +15,27 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
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.ExitStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.StepExecutionListener;
|
||||
import org.springframework.lang.Nullable;
|
||||
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 Mahmoud Ben Hassine
|
||||
* @since 2.0
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class DefaultUnknownJobParserTests extends AbstractJobParserTests {
|
||||
@SpringJUnitConfig
|
||||
class DefaultUnknownJobParserTests extends AbstractJobParserTests {
|
||||
|
||||
@Test
|
||||
public void testDefaultUnknown() throws Exception {
|
||||
void testDefaultUnknown() throws Exception {
|
||||
|
||||
JobExecution jobExecution = createJobExecution();
|
||||
job.execute(jobExecution);
|
||||
|
||||
@@ -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,30 +15,30 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.BeanDefinitionStoreException;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
/**
|
||||
* @author Dan Garrette
|
||||
* @author Dave Syer
|
||||
* @since 2.0
|
||||
*/
|
||||
public class DuplicateTransitionJobParserTests {
|
||||
class DuplicateTransitionJobParserTests {
|
||||
|
||||
@Test(expected = BeanDefinitionStoreException.class)
|
||||
@SuppressWarnings("resource")
|
||||
public void testNextAttributeWithNestedElement() throws Exception {
|
||||
new ClassPathXmlApplicationContext(ClassUtils.addResourcePathToPackagePath(getClass(),
|
||||
"NextAttributeMultipleFinalJobParserTests-context.xml"));
|
||||
@Test
|
||||
void testNextAttributeWithNestedElement() {
|
||||
assertThrows(BeanDefinitionStoreException.class, () -> new ClassPathXmlApplicationContext(ClassUtils
|
||||
.addResourcePathToPackagePath(getClass(), "NextAttributeMultipleFinalJobParserTests-context.xml")));
|
||||
}
|
||||
|
||||
@Test(expected = BeanDefinitionStoreException.class)
|
||||
@SuppressWarnings("resource")
|
||||
public void testDuplicateTransition() throws Exception {
|
||||
new ClassPathXmlApplicationContext(
|
||||
ClassUtils.addResourcePathToPackagePath(getClass(), "DuplicateTransitionJobParserTests-context.xml"));
|
||||
@Test
|
||||
void testDuplicateTransition() {
|
||||
assertThrows(BeanDefinitionStoreException.class, () -> new ClassPathXmlApplicationContext(
|
||||
ClassUtils.addResourcePathToPackagePath(getClass(), "DuplicateTransitionJobParserTests-context.xml")));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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,28 +15,25 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
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.core.BatchStatus;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
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
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class EndTransitionDefaultStatusJobParserTests extends AbstractJobParserTests {
|
||||
@SpringJUnitConfig
|
||||
class EndTransitionDefaultStatusJobParserTests extends AbstractJobParserTests {
|
||||
|
||||
@Test
|
||||
public void testEndTransitionDefaultStatus() throws Exception {
|
||||
void testEndTransitionDefaultStatus() throws Exception {
|
||||
|
||||
JobExecution jobExecution = createJobExecution();
|
||||
job.execute(jobExecution);
|
||||
|
||||
@@ -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,30 +15,27 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
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.assertThrows;
|
||||
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.BatchStatus;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException;
|
||||
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
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class EndTransitionJobParserTests extends AbstractJobParserTests {
|
||||
@SpringJUnitConfig
|
||||
class EndTransitionJobParserTests extends AbstractJobParserTests {
|
||||
|
||||
@Test
|
||||
public void testEndTransition() throws Exception {
|
||||
void testEndTransition() throws Exception {
|
||||
|
||||
//
|
||||
// First Launch
|
||||
@@ -64,16 +61,7 @@ public class EndTransitionJobParserTests extends AbstractJobParserTests {
|
||||
// Second Launch
|
||||
//
|
||||
stepNamesList.clear();
|
||||
try {
|
||||
jobExecution = createJobExecution();
|
||||
fail("JobInstanceAlreadyCompleteException expected");
|
||||
}
|
||||
catch (JobInstanceAlreadyCompleteException e) {
|
||||
//
|
||||
// Expected
|
||||
//
|
||||
}
|
||||
|
||||
assertThrows(JobInstanceAlreadyCompleteException.class, this::createJobExecution);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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,28 +15,25 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
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.core.BatchStatus;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
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
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class FailTransitionDefaultStatusJobParserTests extends AbstractJobParserTests {
|
||||
@SpringJUnitConfig
|
||||
class FailTransitionDefaultStatusJobParserTests extends AbstractJobParserTests {
|
||||
|
||||
@Test
|
||||
public void testFailTransitionDefaultStatus() throws Exception {
|
||||
void testFailTransitionDefaultStatus() throws Exception {
|
||||
|
||||
JobExecution jobExecution = createJobExecution();
|
||||
job.execute(jobExecution);
|
||||
|
||||
@@ -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,28 +15,25 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
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.core.BatchStatus;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
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
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class FailTransitionJobParserTests extends AbstractJobParserTests {
|
||||
@SpringJUnitConfig
|
||||
class FailTransitionJobParserTests extends AbstractJobParserTests {
|
||||
|
||||
@Test
|
||||
public void testFailTransition() throws Exception {
|
||||
void testFailTransition() throws Exception {
|
||||
|
||||
//
|
||||
// First Launch
|
||||
|
||||
@@ -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,14 +15,13 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
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.Job;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
@@ -31,17 +30,15 @@ import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
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
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class FlowJobParserTests {
|
||||
@SpringJUnitConfig
|
||||
class FlowJobParserTests {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("job1")
|
||||
@@ -63,7 +60,7 @@ public class FlowJobParserTests {
|
||||
private JobRepository jobRepository;
|
||||
|
||||
@Test
|
||||
public void testFlowJob() throws Exception {
|
||||
void testFlowJob() throws Exception {
|
||||
assertNotNull(job1);
|
||||
JobExecution jobExecution = jobRepository.createJobExecution(job1.getName(), new JobParameters());
|
||||
job1.execute(jobExecution);
|
||||
@@ -74,7 +71,7 @@ public class FlowJobParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFlowJobWithNestedTransitions() throws Exception {
|
||||
void testFlowJobWithNestedTransitions() throws Exception {
|
||||
assertNotNull(job2);
|
||||
JobExecution jobExecution = jobRepository.createJobExecution(job2.getName(), new JobParameters());
|
||||
job2.execute(jobExecution);
|
||||
@@ -86,7 +83,7 @@ public class FlowJobParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFlowJobWithNoSteps() throws Exception {
|
||||
void testFlowJobWithNoSteps() throws Exception {
|
||||
assertNotNull(job3);
|
||||
JobExecution jobExecution = jobRepository.createJobExecution(job3.getName(), new JobParameters());
|
||||
job3.execute(jobExecution);
|
||||
@@ -97,7 +94,7 @@ public class FlowJobParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFlowInSplit() throws Exception {
|
||||
void testFlowInSplit() throws Exception {
|
||||
assertNotNull(job4);
|
||||
JobExecution jobExecution = jobRepository.createJobExecution(job4.getName(), new JobParameters());
|
||||
job4.execute(jobExecution);
|
||||
|
||||
@@ -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,14 +15,13 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
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.Job;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
@@ -34,17 +33,15 @@ import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class FlowStepParserTests {
|
||||
@SpringJUnitConfig
|
||||
class FlowStepParserTests {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("job1")
|
||||
@@ -66,7 +63,7 @@ public class FlowStepParserTests {
|
||||
private JobRepository jobRepository;
|
||||
|
||||
@Test
|
||||
public void testFlowStep() throws Exception {
|
||||
void testFlowStep() throws Exception {
|
||||
assertNotNull(job1);
|
||||
JobExecution jobExecution = jobRepository.createJobExecution(job1.getName(), new JobParameters());
|
||||
job1.execute(jobExecution);
|
||||
@@ -77,7 +74,7 @@ public class FlowStepParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFlowExternalStep() throws Exception {
|
||||
void testFlowExternalStep() throws Exception {
|
||||
assertNotNull(job2);
|
||||
JobExecution jobExecution = jobRepository.createJobExecution(job2.getName(), new JobParameters());
|
||||
job2.execute(jobExecution);
|
||||
@@ -88,7 +85,7 @@ public class FlowStepParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRepeatedFlow() throws Exception {
|
||||
void testRepeatedFlow() throws Exception {
|
||||
assertNotNull(job3);
|
||||
JobExecution jobExecution = jobRepository.createJobExecution(job3.getName(), new JobParameters());
|
||||
job3.execute(jobExecution);
|
||||
@@ -100,7 +97,7 @@ public class FlowStepParserTests {
|
||||
|
||||
@Test
|
||||
// TODO: BATCH-1745
|
||||
public void testRestartedFlow() throws Exception {
|
||||
void testRestartedFlow() throws Exception {
|
||||
assertNotNull(job4);
|
||||
JobExecution jobExecution = jobRepository.createJobExecution(job4.getName(), new JobParameters());
|
||||
job4.execute(jobExecution);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2009-2014 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,13 +15,13 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
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.Map;
|
||||
|
||||
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.JobExecution;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.scope.context.StepSynchronizationManager;
|
||||
@@ -37,12 +37,12 @@ import org.springframework.test.util.ReflectionTestUtils;
|
||||
* @author Dan Garrette
|
||||
* @since 2.1
|
||||
*/
|
||||
public class InlineItemHandlerParserTests {
|
||||
class InlineItemHandlerParserTests {
|
||||
|
||||
private ConfigurableApplicationContext context;
|
||||
|
||||
@After
|
||||
public void close() {
|
||||
@AfterEach
|
||||
void close() {
|
||||
if (context != null) {
|
||||
context.close();
|
||||
}
|
||||
@@ -50,7 +50,7 @@ public class InlineItemHandlerParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInlineHandlers() throws Exception {
|
||||
void testInlineHandlers() {
|
||||
context = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/InlineItemHandlerParserTests-context.xml");
|
||||
Object step = context.getBean("inlineHandlers");
|
||||
@@ -67,7 +67,7 @@ public class InlineItemHandlerParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInlineAdapters() throws Exception {
|
||||
void testInlineAdapters() {
|
||||
context = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/InlineItemHandlerParserTests-context.xml");
|
||||
Object step = context.getBean("inlineAdapters");
|
||||
@@ -98,7 +98,7 @@ public class InlineItemHandlerParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInlineHandlersWithStepScope() throws Exception {
|
||||
void testInlineHandlersWithStepScope() {
|
||||
context = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/InlineItemHandlerWithStepScopeParserTests-context.xml");
|
||||
StepSynchronizationManager.register(new StepExecution("step", new JobExecution(123L)));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-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.core.configuration.xml;
|
||||
|
||||
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.Job;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobParametersBuilder;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author Lucas Ward
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringJUnitConfig
|
||||
public class JobExecutionListenerMethodAttributeParserTests {
|
||||
|
||||
public static boolean beforeCalled = false;
|
||||
@@ -46,7 +43,7 @@ public class JobExecutionListenerMethodAttributeParserTests {
|
||||
JobRepository jobRepository;
|
||||
|
||||
@Test
|
||||
public void testListeners() throws Exception {
|
||||
void testListeners() throws Exception {
|
||||
JobExecution jobExecution = jobRepository.createJobExecution("testJob",
|
||||
new JobParametersBuilder().addLong("now", System.currentTimeMillis()).toJobParameters());
|
||||
job.execute(jobExecution);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-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.core.configuration.xml;
|
||||
|
||||
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.Job;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobParametersBuilder;
|
||||
@@ -26,15 +25,13 @@ import org.springframework.batch.core.annotation.AfterJob;
|
||||
import org.springframework.batch.core.annotation.BeforeJob;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author Lucas Ward
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringJUnitConfig
|
||||
public class JobExecutionListenerParserTests {
|
||||
|
||||
public static boolean beforeCalled = false;
|
||||
@@ -48,7 +45,7 @@ public class JobExecutionListenerParserTests {
|
||||
JobRepository jobRepository;
|
||||
|
||||
@Test
|
||||
public void testListeners() throws Exception {
|
||||
void testListeners() throws Exception {
|
||||
JobExecution jobExecution = jobRepository.createJobExecution("testJob",
|
||||
new JobParametersBuilder().addLong("now", System.currentTimeMillis()).toJobParameters());
|
||||
job.execute(jobExecution);
|
||||
|
||||
@@ -15,71 +15,52 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
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.beans.factory.BeanCreationException;
|
||||
import org.springframework.beans.factory.BeanDefinitionStoreException;
|
||||
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.core.NestedRuntimeException;
|
||||
|
||||
public class JobParserExceptionTests {
|
||||
class JobParserExceptionTests {
|
||||
|
||||
@Test
|
||||
public void testUnreachableStep() {
|
||||
try {
|
||||
new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/JobParserUnreachableStepTests-context.xml");
|
||||
fail("Error expected");
|
||||
}
|
||||
catch (BeanDefinitionParsingException e) {
|
||||
assertTrue(e.getMessage().contains("The element [s2] is unreachable"));
|
||||
}
|
||||
void testUnreachableStep() {
|
||||
Exception exception = assertThrows(BeanDefinitionParsingException.class,
|
||||
() -> new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/JobParserUnreachableStepTests-context.xml"));
|
||||
assertTrue(exception.getMessage().contains("The element [s2] is unreachable"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnreachableStepInFlow() {
|
||||
try {
|
||||
new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/JobParserUnreachableStepInFlowTests-context.xml");
|
||||
fail("Error expected");
|
||||
}
|
||||
catch (BeanDefinitionParsingException e) {
|
||||
assertTrue(e.getMessage().contains("The element [s4] is unreachable"));
|
||||
}
|
||||
void testUnreachableStepInFlow() {
|
||||
Exception exception = assertThrows(BeanDefinitionParsingException.class,
|
||||
() -> new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/JobParserUnreachableStepInFlowTests-context.xml"));
|
||||
assertTrue(exception.getMessage().contains("The element [s4] is unreachable"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNextOutOfScope() {
|
||||
try {
|
||||
new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/JobParserNextOutOfScopeTests-context.xml");
|
||||
fail("Error expected");
|
||||
}
|
||||
catch (BeanCreationException e) {
|
||||
String message = e.getRootCause().getMessage();
|
||||
assertTrue("Wrong message: " + message, message
|
||||
.matches(".*Missing state for \\[StateTransition: \\[state=.*s2, pattern=\\*, next=.*s3\\]\\]"));
|
||||
}
|
||||
void testNextOutOfScope() {
|
||||
NestedRuntimeException exception = assertThrows(BeanCreationException.class,
|
||||
() -> new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/JobParserNextOutOfScopeTests-context.xml"));
|
||||
String message = exception.getRootCause().getMessage();
|
||||
assertTrue(
|
||||
message.matches(".*Missing state for \\[StateTransition: \\[state=.*s2, pattern=\\*, next=.*s3\\]\\]"),
|
||||
"Wrong message: " + message);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWrongSchemaInRoot() {
|
||||
try {
|
||||
new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/JobParserWrongSchemaInRootTests-context.xml");
|
||||
fail("Error expected");
|
||||
}
|
||||
catch (BeanDefinitionParsingException e) {
|
||||
String message = e.getMessage();
|
||||
assertTrue("Wrong message: " + message,
|
||||
message.startsWith("Configuration problem: You are using a version of the spring-batch XSD"));
|
||||
}
|
||||
catch (BeanDefinitionStoreException e) {
|
||||
// Probably the internet is not available and the schema validation failed.
|
||||
fail("Wrong exception when schema didn't match: " + e.getMessage());
|
||||
}
|
||||
void testWrongSchemaInRoot() {
|
||||
Exception exception = assertThrows(BeanDefinitionParsingException.class,
|
||||
() -> new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/JobParserWrongSchemaInRootTests-context.xml"));
|
||||
String message = exception.getMessage();
|
||||
assertTrue(message.startsWith("Configuration problem: You are using a version of the spring-batch XSD"),
|
||||
"Wrong message: " + message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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,17 +15,17 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class JobParserJobFactoryBeanTests {
|
||||
class JobParserJobFactoryBeanTests {
|
||||
|
||||
private JobParserJobFactoryBean factory = new JobParserJobFactoryBean("jobFactory");
|
||||
private final JobParserJobFactoryBean factory = new JobParserJobFactoryBean("jobFactory");
|
||||
|
||||
@Test
|
||||
public void testSingleton() throws Exception {
|
||||
assertTrue("Expected singleton", factory.isSingleton());
|
||||
void testSingleton() {
|
||||
assertTrue(factory.isSingleton(), "Expected singleton");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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,14 +15,13 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
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.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.aop.framework.Advised;
|
||||
import org.springframework.batch.core.Job;
|
||||
import org.springframework.batch.core.JobExecutionListener;
|
||||
@@ -31,8 +30,7 @@ import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.core.repository.support.SimpleJobRepository;
|
||||
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;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
/**
|
||||
@@ -41,9 +39,8 @@ import org.springframework.test.util.ReflectionTestUtils;
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @since 2.0
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class JobParserParentAttributeTests {
|
||||
@SpringJUnitConfig
|
||||
class JobParserParentAttributeTests {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("listenerClearingJob")
|
||||
@@ -78,7 +75,7 @@ public class JobParserParentAttributeTests {
|
||||
private Job job1;
|
||||
|
||||
@Test
|
||||
public void testInheritListeners() throws Exception {
|
||||
void testInheritListeners() throws Exception {
|
||||
List<?> job1Listeners = getListeners(job1);
|
||||
assertEquals(2, job1Listeners.size());
|
||||
boolean a = false;
|
||||
@@ -96,7 +93,7 @@ public class JobParserParentAttributeTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInheritListeners_NoMerge() throws Exception {
|
||||
void testInheritListeners_NoMerge() throws Exception {
|
||||
List<?> job2Listeners = getListeners(job2);
|
||||
assertEquals(1, job2Listeners.size());
|
||||
boolean c = false;
|
||||
@@ -109,7 +106,7 @@ public class JobParserParentAttributeTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStandaloneListener() throws Exception {
|
||||
void testStandaloneListener() throws Exception {
|
||||
List<?> jobListeners = getListeners(job3);
|
||||
assertEquals(2, jobListeners.size());
|
||||
boolean a = false;
|
||||
@@ -127,7 +124,7 @@ public class JobParserParentAttributeTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJobRepositoryDefaults() throws Exception {
|
||||
void testJobRepositoryDefaults() throws Exception {
|
||||
assertTrue(getJobRepository(defaultRepoJob) instanceof SimpleJobRepository);
|
||||
assertTrue(getJobRepository(specifiedRepoJob) instanceof DummyJobRepository);
|
||||
assertTrue(getJobRepository(inheritSpecifiedRepoJob) instanceof DummyJobRepository);
|
||||
@@ -135,7 +132,7 @@ public class JobParserParentAttributeTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListenerClearingJob() throws Exception {
|
||||
void testListenerClearingJob() throws Exception {
|
||||
assertEquals(0, getListeners(listenerClearingJob).size());
|
||||
}
|
||||
|
||||
|
||||
@@ -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,14 +15,14 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
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.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.core.Job;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.JobParametersInvalidException;
|
||||
@@ -31,17 +31,15 @@ import org.springframework.batch.core.job.AbstractJob;
|
||||
import org.springframework.batch.core.job.DefaultJobParametersValidator;
|
||||
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;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class JobParserValidatorTests {
|
||||
@SpringJUnitConfig
|
||||
class JobParserValidatorTests {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("job1")
|
||||
@@ -55,35 +53,35 @@ public class JobParserValidatorTests {
|
||||
@Qualifier("job3")
|
||||
private Job job3;
|
||||
|
||||
@Test(expected = JobParametersInvalidException.class)
|
||||
public void testValidatorAttribute() throws Exception {
|
||||
@Test
|
||||
void testValidatorAttribute() {
|
||||
assertNotNull(job1);
|
||||
JobParametersValidator validator = (JobParametersValidator) ReflectionTestUtils.getField(job1,
|
||||
"jobParametersValidator");
|
||||
assertNotNull(validator);
|
||||
validator.validate(new JobParameters());
|
||||
assertThrows(JobParametersInvalidException.class, () -> validator.validate(new JobParameters()));
|
||||
}
|
||||
|
||||
@Test(expected = JobParametersInvalidException.class)
|
||||
public void testValidatorRef() throws Exception {
|
||||
@Test
|
||||
void testValidatorRef() {
|
||||
assertNotNull(job2);
|
||||
JobParametersValidator validator = (JobParametersValidator) ReflectionTestUtils.getField(job2,
|
||||
"jobParametersValidator");
|
||||
assertNotNull(validator);
|
||||
validator.validate(new JobParameters());
|
||||
assertThrows(JobParametersInvalidException.class, () -> validator.validate(new JobParameters()));
|
||||
}
|
||||
|
||||
@Test(expected = JobParametersInvalidException.class)
|
||||
public void testValidatorBean() throws Exception {
|
||||
@Test
|
||||
void testValidatorBean() {
|
||||
assertNotNull(job3);
|
||||
JobParametersValidator validator = (JobParametersValidator) ReflectionTestUtils.getField(job3,
|
||||
"jobParametersValidator");
|
||||
assertNotNull(validator);
|
||||
validator.validate(new JobParameters());
|
||||
assertThrows(JobParametersInvalidException.class, () -> validator.validate(new JobParameters()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParametersValidator() {
|
||||
void testParametersValidator() {
|
||||
assertTrue(job1 instanceof AbstractJob);
|
||||
Object validator = ReflectionTestUtils.getField(job1, "jobParametersValidator");
|
||||
assertTrue(validator instanceof DefaultJobParametersValidator);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2013 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,25 +15,22 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
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.Job;
|
||||
import org.springframework.batch.core.configuration.ListableJobLocator;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringJUnitConfig
|
||||
public class JobRegistryJobParserTests implements ApplicationContextAware {
|
||||
|
||||
@Autowired
|
||||
@@ -47,7 +44,7 @@ public class JobRegistryJobParserTests implements ApplicationContextAware {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOneStep() throws Exception {
|
||||
void testOneStep() {
|
||||
assertEquals(2, applicationContext.getBeanNamesForType(Job.class).length);
|
||||
assertEquals(2, jobRegistry.getJobNames().size());
|
||||
}
|
||||
|
||||
@@ -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,30 +15,27 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
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
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class JobRepositoryDefaultParserTests {
|
||||
@SpringJUnitConfig
|
||||
class JobRepositoryDefaultParserTests {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("jobRepository")
|
||||
private JobRepository jobRepository;
|
||||
|
||||
@Test
|
||||
public void testOneStep() throws Exception {
|
||||
void testOneStep() {
|
||||
assertNotNull(jobRepository);
|
||||
}
|
||||
|
||||
|
||||
@@ -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,30 +15,27 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
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
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class JobRepositoryParserReferenceTests {
|
||||
@SpringJUnitConfig
|
||||
class JobRepositoryParserReferenceTests {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("jobRepo1")
|
||||
private JobRepository jobRepository;
|
||||
|
||||
@Test
|
||||
public void testOneStep() throws Exception {
|
||||
void testOneStep() {
|
||||
assertNotNull(jobRepository);
|
||||
}
|
||||
|
||||
|
||||
@@ -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,30 +15,27 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
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 Thomas Risberg
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class JobRepositoryParserTests {
|
||||
@SpringJUnitConfig
|
||||
class JobRepositoryParserTests {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("jobRepo1")
|
||||
private JobRepository jobRepository;
|
||||
|
||||
@Test
|
||||
public void testOneStep() throws Exception {
|
||||
void testOneStep() {
|
||||
assertNotNull(jobRepository);
|
||||
}
|
||||
|
||||
|
||||
@@ -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,14 +15,13 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
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.Job;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
@@ -31,17 +30,15 @@ import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
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
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class JobStepParserTests {
|
||||
@SpringJUnitConfig
|
||||
class JobStepParserTests {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("job1")
|
||||
@@ -55,7 +52,7 @@ public class JobStepParserTests {
|
||||
private JobRepository jobRepository;
|
||||
|
||||
@Test
|
||||
public void testFlowStep() throws Exception {
|
||||
void testFlowStep() throws Exception {
|
||||
assertNotNull(job1);
|
||||
JobExecution jobExecution = jobRepository.createJobExecution(job1.getName(), new JobParameters());
|
||||
job1.execute(jobExecution);
|
||||
@@ -66,7 +63,7 @@ public class JobStepParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFlowExternalStep() throws Exception {
|
||||
void testFlowExternalStep() throws Exception {
|
||||
assertNotNull(job2);
|
||||
JobExecution jobExecution = jobRepository.createJobExecution(job2.getName(), new JobParameters());
|
||||
job2.execute(jobExecution);
|
||||
|
||||
@@ -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,11 +15,10 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
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;
|
||||
@@ -27,17 +26,15 @@ import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
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
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class NamespacePrefixedJobParserTests {
|
||||
@SpringJUnitConfig
|
||||
class NamespacePrefixedJobParserTests {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("job1")
|
||||
@@ -47,7 +44,7 @@ public class NamespacePrefixedJobParserTests {
|
||||
private JobRepository jobRepository;
|
||||
|
||||
@Test
|
||||
public void testNoopJob() throws Exception {
|
||||
void testNoopJob() throws Exception {
|
||||
assertNotNull(job1);
|
||||
JobExecution jobExecution = jobRepository.createJobExecution(job1.getName(), new JobParameters());
|
||||
job1.execute(jobExecution);
|
||||
|
||||
@@ -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,28 +15,25 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
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.core.BatchStatus;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
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
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class NextAttributeJobParserTests extends AbstractJobParserTests {
|
||||
@SpringJUnitConfig
|
||||
class NextAttributeJobParserTests extends AbstractJobParserTests {
|
||||
|
||||
@Test
|
||||
public void testNextAttributeFailedDefault() throws Exception {
|
||||
void testNextAttributeFailedDefault() throws Exception {
|
||||
|
||||
//
|
||||
// Launch 1
|
||||
|
||||
@@ -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,30 +15,27 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
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.ExitStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.StepExecutionListener;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @since 2.1.9
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class NextAttributeUnknownJobParserTests extends AbstractJobParserTests {
|
||||
@SpringJUnitConfig
|
||||
class NextAttributeUnknownJobParserTests extends AbstractJobParserTests {
|
||||
|
||||
@Test
|
||||
public void testDefaultUnknown() throws Exception {
|
||||
void testDefaultUnknown() throws Exception {
|
||||
|
||||
JobExecution jobExecution = createJobExecution();
|
||||
job.execute(jobExecution);
|
||||
|
||||
@@ -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,11 +15,10 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
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;
|
||||
@@ -27,16 +26,14 @@ import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
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
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class OneStepJobParserTests {
|
||||
@SpringJUnitConfig
|
||||
class OneStepJobParserTests {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("job")
|
||||
@@ -46,7 +43,7 @@ public class OneStepJobParserTests {
|
||||
private JobRepository jobRepository;
|
||||
|
||||
@Test
|
||||
public void testOneStep() throws Exception {
|
||||
void testOneStep() throws Exception {
|
||||
assertNotNull(job);
|
||||
JobExecution jobExecution = jobRepository.createJobExecution(job.getName(), new JobParameters());
|
||||
job.execute(jobExecution);
|
||||
|
||||
@@ -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,10 +15,10 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.core.Step;
|
||||
import org.springframework.batch.core.step.item.FaultTolerantChunkProcessor;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
@@ -29,68 +29,63 @@ import org.springframework.test.util.ReflectionTestUtils;
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class ParentStepFactoryBeanParserTests {
|
||||
class ParentStepFactoryBeanParserTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void testSimpleAttributes() throws Exception {
|
||||
void testSimpleAttributes() {
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/ParentStepFactoryBeanParserTests-context.xml");
|
||||
Object step = context.getBean("s1", Step.class);
|
||||
assertNotNull("Step not parsed", step);
|
||||
assertNotNull(step, "Step not parsed");
|
||||
Object tasklet = ReflectionTestUtils.getField(step, "tasklet");
|
||||
Object chunkProcessor = ReflectionTestUtils.getField(tasklet, "chunkProcessor");
|
||||
assertTrue("Wrong processor type", chunkProcessor instanceof FaultTolerantChunkProcessor<?, ?>);
|
||||
assertTrue(chunkProcessor instanceof FaultTolerantChunkProcessor<?, ?>, "Wrong processor type");
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void testSkippableAttributes() throws Exception {
|
||||
void testSkippableAttributes() {
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/ParentSkippableStepFactoryBeanParserTests-context.xml");
|
||||
Object step = context.getBean("s1", Step.class);
|
||||
assertNotNull("Step not parsed", step);
|
||||
assertNotNull(step, "Step not parsed");
|
||||
Object tasklet = ReflectionTestUtils.getField(step, "tasklet");
|
||||
Object chunkProcessor = ReflectionTestUtils.getField(tasklet, "chunkProcessor");
|
||||
assertTrue("Wrong processor type", chunkProcessor instanceof FaultTolerantChunkProcessor<?, ?>);
|
||||
assertTrue(chunkProcessor instanceof FaultTolerantChunkProcessor<?, ?>, "Wrong processor type");
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void testRetryableAttributes() throws Exception {
|
||||
void testRetryableAttributes() {
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/ParentRetryableStepFactoryBeanParserTests-context.xml");
|
||||
Object step = context.getBean("s1", Step.class);
|
||||
assertNotNull("Step not parsed", step);
|
||||
assertNotNull(step, "Step not parsed");
|
||||
Object tasklet = ReflectionTestUtils.getField(step, "tasklet");
|
||||
Object chunkProcessor = ReflectionTestUtils.getField(tasklet, "chunkProcessor");
|
||||
assertTrue("Wrong processor type", chunkProcessor instanceof FaultTolerantChunkProcessor<?, ?>);
|
||||
assertTrue(chunkProcessor instanceof FaultTolerantChunkProcessor<?, ?>, "Wrong processor type");
|
||||
}
|
||||
|
||||
// BATCH-1396
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void testRetryableLateBindingAttributes() throws Exception {
|
||||
void testRetryableLateBindingAttributes() {
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/ParentRetryableLateBindingStepFactoryBeanParserTests-context.xml");
|
||||
Object step = context.getBean("s1", Step.class);
|
||||
assertNotNull("Step not parsed", step);
|
||||
assertNotNull(step, "Step not parsed");
|
||||
Object tasklet = ReflectionTestUtils.getField(step, "tasklet");
|
||||
Object chunkProcessor = ReflectionTestUtils.getField(tasklet, "chunkProcessor");
|
||||
assertTrue("Wrong processor type", chunkProcessor instanceof FaultTolerantChunkProcessor<?, ?>);
|
||||
assertTrue(chunkProcessor instanceof FaultTolerantChunkProcessor<?, ?>, "Wrong processor type");
|
||||
}
|
||||
|
||||
// BATCH-1396
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void testSkippableLateBindingAttributes() throws Exception {
|
||||
void testSkippableLateBindingAttributes() {
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/ParentSkippableLateBindingStepFactoryBeanParserTests-context.xml");
|
||||
Object step = context.getBean("s1", Step.class);
|
||||
assertNotNull("Step not parsed", step);
|
||||
assertNotNull(step, "Step not parsed");
|
||||
Object tasklet = ReflectionTestUtils.getField(step, "tasklet");
|
||||
Object chunkProcessor = ReflectionTestUtils.getField(tasklet, "chunkProcessor");
|
||||
assertTrue("Wrong processor type", chunkProcessor instanceof FaultTolerantChunkProcessor<?, ?>);
|
||||
assertTrue(chunkProcessor instanceof FaultTolerantChunkProcessor<?, ?>, "Wrong processor type");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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,8 +15,8 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
@@ -25,9 +25,8 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
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.JobExecution;
|
||||
@@ -45,8 +44,7 @@ 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;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
/**
|
||||
@@ -54,8 +52,7 @@ import org.springframework.util.ReflectionUtils;
|
||||
* @author Josh Long
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringJUnitConfig
|
||||
public class PartitionStepParserTests implements ApplicationContextAware {
|
||||
|
||||
@Autowired
|
||||
@@ -94,8 +91,8 @@ public class PartitionStepParserTests implements ApplicationContextAware {
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
nameStoringTasklet.setStepNamesList(savedStepNames);
|
||||
}
|
||||
|
||||
@@ -110,7 +107,7 @@ public class PartitionStepParserTests implements ApplicationContextAware {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultHandlerStep() throws Exception {
|
||||
void testDefaultHandlerStep() throws Exception {
|
||||
assertNotNull(job1);
|
||||
JobExecution jobExecution = jobRepository.createJobExecution(job1.getName(), new JobParameters());
|
||||
job1.execute(jobExecution);
|
||||
@@ -124,7 +121,7 @@ public class PartitionStepParserTests implements ApplicationContextAware {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandlerRefStep() throws Exception {
|
||||
void testHandlerRefStep() throws Exception {
|
||||
assertNotNull(job2);
|
||||
JobExecution jobExecution = jobRepository.createJobExecution(job2.getName(), new JobParameters());
|
||||
job2.execute(jobExecution);
|
||||
@@ -142,8 +139,8 @@ public class PartitionStepParserTests implements ApplicationContextAware {
|
||||
* handler has a reference to the inline step definition
|
||||
*/
|
||||
@Test
|
||||
public void testNestedPartitionStepStepReference() throws Throwable {
|
||||
assertNotNull("the reference to the job3 configured in the XML file must not be null", job3);
|
||||
void testNestedPartitionStepStepReference() throws Throwable {
|
||||
assertNotNull(job3, "the reference to the job3 configured in the XML file must not be null");
|
||||
JobExecution jobExecution = jobRepository.createJobExecution(job3.getName(), new JobParameters());
|
||||
|
||||
job3.execute(jobExecution);
|
||||
@@ -159,8 +156,8 @@ public class PartitionStepParserTests implements ApplicationContextAware {
|
||||
"partitionHandler");
|
||||
TaskletStep taskletStep = accessPrivateField(taskExecutorPartitionHandler, "step");
|
||||
|
||||
assertNotNull("the taskletStep wasn't configured with a step. "
|
||||
+ "We're trusting that the factory ensured " + "a reference was given.", taskletStep);
|
||||
assertNotNull(taskletStep, "the taskletStep wasn't configured with a step. "
|
||||
+ "We're trusting that the factory ensured " + "a reference was given.");
|
||||
}
|
||||
}
|
||||
assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
|
||||
@@ -181,8 +178,8 @@ public class PartitionStepParserTests implements ApplicationContextAware {
|
||||
* handler has a reference to the inline step definition
|
||||
*/
|
||||
@Test
|
||||
public void testNestedPartitionStep() throws Throwable {
|
||||
assertNotNull("the reference to the job4 configured in the XML file must not be null", job4);
|
||||
void testNestedPartitionStep() throws Throwable {
|
||||
assertNotNull(job4, "the reference to the job4 configured in the XML file must not be null");
|
||||
JobExecution jobExecution = jobRepository.createJobExecution(job4.getName(), new JobParameters());
|
||||
|
||||
job4.execute(jobExecution);
|
||||
@@ -199,8 +196,8 @@ public class PartitionStepParserTests implements ApplicationContextAware {
|
||||
"partitionHandler");
|
||||
TaskletStep taskletStep = accessPrivateField(taskExecutorPartitionHandler, "step");
|
||||
|
||||
assertNotNull("the taskletStep wasn't configured with a step. "
|
||||
+ "We're trusting that the factory ensured " + "a reference was given.", taskletStep);
|
||||
assertNotNull(taskletStep, "the taskletStep wasn't configured with a step. "
|
||||
+ "We're trusting that the factory ensured " + "a reference was given.");
|
||||
}
|
||||
}
|
||||
assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
|
||||
@@ -214,7 +211,7 @@ public class PartitionStepParserTests implements ApplicationContextAware {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomHandlerRefStep() throws Exception {
|
||||
void testCustomHandlerRefStep() throws Exception {
|
||||
assertNotNull(job5);
|
||||
JobExecution jobExecution = jobRepository.createJobExecution(job5.getName(), new JobParameters());
|
||||
job5.execute(jobExecution);
|
||||
|
||||
@@ -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,16 +15,15 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
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.JobExecution;
|
||||
@@ -36,17 +35,15 @@ import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
* @author Josh Long
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class PartitionStepWithFlowParserTests {
|
||||
@SpringJUnitConfig
|
||||
class PartitionStepWithFlowParserTests {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("job1")
|
||||
@@ -59,15 +56,15 @@ public class PartitionStepWithFlowParserTests {
|
||||
@Autowired
|
||||
private JobRepository jobRepository;
|
||||
|
||||
private List<String> savedStepNames = new ArrayList<>();
|
||||
private final List<String> savedStepNames = new ArrayList<>();
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
nameStoringTasklet.setStepNamesList(savedStepNames);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRepeatedFlowStep() throws Exception {
|
||||
void testRepeatedFlowStep() throws Exception {
|
||||
assertNotNull(job1);
|
||||
JobExecution jobExecution = jobRepository.createJobExecution(job1.getName(),
|
||||
new JobParametersBuilder().addLong("gridSize", 1L).toJobParameters());
|
||||
|
||||
@@ -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,16 +15,15 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
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.JobExecution;
|
||||
@@ -33,17 +32,15 @@ import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
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
|
||||
* @author Josh Long
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class PartitionStepWithLateBindingParserTests {
|
||||
@SpringJUnitConfig
|
||||
class PartitionStepWithLateBindingParserTests {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("job1")
|
||||
@@ -56,15 +53,15 @@ public class PartitionStepWithLateBindingParserTests {
|
||||
@Autowired
|
||||
private JobRepository jobRepository;
|
||||
|
||||
private List<String> savedStepNames = new ArrayList<>();
|
||||
private final List<String> savedStepNames = new ArrayList<>();
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
nameStoringTasklet.setStepNamesList(savedStepNames);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExplicitHandlerStep() throws Exception {
|
||||
void testExplicitHandlerStep() throws Exception {
|
||||
assertNotNull(job1);
|
||||
JobExecution jobExecution = jobRepository.createJobExecution(job1.getName(),
|
||||
new JobParametersBuilder().addLong("gridSize", 1L).toJobParameters());
|
||||
|
||||
@@ -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,28 +15,25 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
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;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class PartitionStepWithNonDefaultTransactionManagerParserTests {
|
||||
@SpringJUnitConfig
|
||||
class PartitionStepWithNonDefaultTransactionManagerParserTests {
|
||||
|
||||
@Autowired
|
||||
private Job job;
|
||||
@@ -45,7 +42,7 @@ public class PartitionStepWithNonDefaultTransactionManagerParserTests {
|
||||
private JobRepository jobRepository;
|
||||
|
||||
@Test
|
||||
public void testDefaultHandlerStep() throws Exception {
|
||||
void testDefaultHandlerStep() throws Exception {
|
||||
assertNotNull(job);
|
||||
JobExecution jobExecution = jobRepository.createJobExecution(job.getName(), new JobParameters());
|
||||
job.execute(jobExecution);
|
||||
|
||||
@@ -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,11 +15,10 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
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;
|
||||
@@ -27,16 +26,14 @@ import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
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
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class RepositoryJobParserTests {
|
||||
@SpringJUnitConfig
|
||||
class RepositoryJobParserTests {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("job")
|
||||
@@ -46,7 +43,7 @@ public class RepositoryJobParserTests {
|
||||
private JobRepository jobRepository;
|
||||
|
||||
@Test
|
||||
public void testTaskletStepWithBadListener() throws Exception {
|
||||
void testTaskletStepWithBadListener() throws Exception {
|
||||
assertNotNull(job);
|
||||
JobExecution jobExecution = jobRepository.createJobExecution(job.getName(), new JobParameters());
|
||||
job.execute(jobExecution);
|
||||
|
||||
@@ -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,32 +15,29 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
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.ExitStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
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
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class SplitDifferentResultsFailFirstJobParserTests extends AbstractJobParserTests {
|
||||
@SpringJUnitConfig
|
||||
class SplitDifferentResultsFailFirstJobParserTests extends AbstractJobParserTests {
|
||||
|
||||
@Test
|
||||
public void testSplitDifferentResultsFailFirst() throws Exception {
|
||||
void testSplitDifferentResultsFailFirst() throws Exception {
|
||||
|
||||
JobExecution jobExecution = createJobExecution();
|
||||
job.execute(jobExecution);
|
||||
assertEquals(2, stepNamesList.size());
|
||||
assertEquals("Wrong step names: " + stepNamesList, "[fail, s1]", stepNamesList.toString());
|
||||
assertEquals("[fail, s1]", stepNamesList.toString(), "Wrong step names: " + stepNamesList);
|
||||
|
||||
assertEquals(BatchStatus.FAILED, jobExecution.getStatus());
|
||||
assertEquals(ExitStatus.FAILED, jobExecution.getExitStatus());
|
||||
|
||||
@@ -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,34 +15,31 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
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.core.BatchStatus;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
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
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class SplitDifferentResultsFailSecondJobParserTests extends AbstractJobParserTests {
|
||||
@SpringJUnitConfig
|
||||
class SplitDifferentResultsFailSecondJobParserTests extends AbstractJobParserTests {
|
||||
|
||||
@Test
|
||||
public void testSplitDifferentResultsFailSecond() throws Exception {
|
||||
void testSplitDifferentResultsFailSecond() throws Exception {
|
||||
|
||||
JobExecution jobExecution = createJobExecution();
|
||||
job.execute(jobExecution);
|
||||
assertEquals("Wrong step names: " + stepNamesList, 3, stepNamesList.size());
|
||||
assertTrue("Wrong step names: " + stepNamesList, stepNamesList.contains("s1"));
|
||||
assertTrue("Wrong step names: " + stepNamesList, stepNamesList.contains("fail"));
|
||||
assertEquals(3, stepNamesList.size(), "Wrong step names: " + stepNamesList);
|
||||
assertTrue(stepNamesList.contains("s1"), "Wrong step names: " + stepNamesList);
|
||||
assertTrue(stepNamesList.contains("fail"), "Wrong step names: " + stepNamesList);
|
||||
assertTrue(stepNamesList.contains("s3"));
|
||||
|
||||
assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2013 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,28 +15,25 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
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.core.BatchStatus;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
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
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class SplitInterruptedJobParserTests extends AbstractJobParserTests {
|
||||
@SpringJUnitConfig
|
||||
class SplitInterruptedJobParserTests extends AbstractJobParserTests {
|
||||
|
||||
@Test
|
||||
public void testSplitInterrupted() throws Exception {
|
||||
void testSplitInterrupted() throws Exception {
|
||||
|
||||
final JobExecution jobExecution = createJobExecution();
|
||||
new Thread(new Runnable() {
|
||||
@@ -53,12 +50,12 @@ public class SplitInterruptedJobParserTests extends AbstractJobParserTests {
|
||||
while (jobExecution.getStatus() == BatchStatus.STOPPING && count++ < 10) {
|
||||
Thread.sleep(200L);
|
||||
}
|
||||
assertTrue("Timed out waiting for job to stop: " + jobExecution, count < 10);
|
||||
assertTrue(count < 10, "Timed out waiting for job to stop: " + jobExecution);
|
||||
|
||||
assertEquals(BatchStatus.STOPPED, jobExecution.getStatus());
|
||||
assertEquals(ExitStatus.STOPPED.getExitCode(), jobExecution.getExitStatus().getExitCode());
|
||||
|
||||
assertTrue("Wrong step names: " + stepNamesList, stepNamesList.contains("stop"));
|
||||
assertTrue(stepNamesList.contains("stop"), "Wrong step names: " + stepNamesList);
|
||||
|
||||
StepExecution stepExecution = getStepExecution(jobExecution, "stop");
|
||||
assertEquals(BatchStatus.STOPPED, stepExecution.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.
|
||||
@@ -15,14 +15,13 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
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;
|
||||
@@ -31,16 +30,14 @@ import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.core.step.StepLocator;
|
||||
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
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class SplitJobParserTests {
|
||||
@SpringJUnitConfig
|
||||
class SplitJobParserTests {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("job")
|
||||
@@ -50,7 +47,7 @@ public class SplitJobParserTests {
|
||||
private JobRepository jobRepository;
|
||||
|
||||
@Test
|
||||
public void testSplitJob() throws Exception {
|
||||
void testSplitJob() throws Exception {
|
||||
assertNotNull(job);
|
||||
JobExecution jobExecution = jobRepository.createJobExecution(job.getName(), new JobParameters());
|
||||
job.execute(jobExecution);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2011 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,11 +15,10 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
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;
|
||||
@@ -27,16 +26,14 @@ import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
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 Josh Long
|
||||
*
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class SplitNestedJobParserTests {
|
||||
@SpringJUnitConfig
|
||||
class SplitNestedJobParserTests {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("job")
|
||||
@@ -46,7 +43,7 @@ public class SplitNestedJobParserTests {
|
||||
private JobRepository jobRepository;
|
||||
|
||||
@Test
|
||||
public void testSplitJob() throws Exception {
|
||||
void testSplitJob() throws Exception {
|
||||
assertNotNull(job);
|
||||
JobExecution jobExecution = jobRepository.createJobExecution(job.getName(), new JobParameters());
|
||||
job.execute(jobExecution);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-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,13 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
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.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.aop.framework.Advised;
|
||||
import org.springframework.batch.core.Step;
|
||||
import org.springframework.batch.core.StepListener;
|
||||
@@ -30,8 +29,7 @@ import org.springframework.batch.core.listener.ItemListenerSupport;
|
||||
import org.springframework.batch.core.step.tasklet.TaskletStep;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
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;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
/**
|
||||
@@ -39,15 +37,14 @@ import org.springframework.test.util.ReflectionTestUtils;
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @since 2.0
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class StepListenerInStepParserTests {
|
||||
@SpringJUnitConfig
|
||||
class StepListenerInStepParserTests {
|
||||
|
||||
@Autowired
|
||||
private BeanFactory beanFactory;
|
||||
|
||||
@Test
|
||||
public void testListenersAtStepLevel() throws Exception {
|
||||
void testListenersAtStepLevel() throws Exception {
|
||||
Step step = (Step) beanFactory.getBean("s1");
|
||||
List<?> list = getListeners(step);
|
||||
assertEquals(1, list.size());
|
||||
@@ -56,7 +53,7 @@ public class StepListenerInStepParserTests {
|
||||
|
||||
@Test
|
||||
// TODO: BATCH-1689 (expected=BeanCreationException.class)
|
||||
public void testListenersAtStepLevelWrongType() throws Exception {
|
||||
void testListenersAtStepLevelWrongType() throws Exception {
|
||||
Step step = (Step) beanFactory.getBean("s2");
|
||||
List<?> list = getListeners(step);
|
||||
assertEquals(1, list.size());
|
||||
@@ -64,7 +61,7 @@ public class StepListenerInStepParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListenersAtTaskletAndStepLevels() throws Exception {
|
||||
void testListenersAtTaskletAndStepLevels() throws Exception {
|
||||
Step step = (Step) beanFactory.getBean("s3");
|
||||
List<?> list = getListeners(step);
|
||||
assertEquals(2, list.size());
|
||||
@@ -73,7 +70,7 @@ public class StepListenerInStepParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListenersAtChunkAndStepLevels() throws Exception {
|
||||
void testListenersAtChunkAndStepLevels() throws Exception {
|
||||
Step step = (Step) beanFactory.getBean("s4");
|
||||
List<?> list = getListeners(step);
|
||||
assertEquals(2, list.size());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-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,35 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
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.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.aop.framework.Advised;
|
||||
import org.springframework.batch.core.Step;
|
||||
import org.springframework.batch.core.StepExecutionListener;
|
||||
import org.springframework.batch.core.step.tasklet.TaskletStep;
|
||||
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;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
/**
|
||||
* @author Dan Garrette
|
||||
* @since 2.0
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class StepListenerMethodAttributeParserTests {
|
||||
@SpringJUnitConfig
|
||||
class StepListenerMethodAttributeParserTests {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("s1")
|
||||
private Step step1;
|
||||
|
||||
@Test
|
||||
public void testInheritListeners() throws Exception {
|
||||
void testInheritListeners() throws Exception {
|
||||
List<?> list = getListeners(step1);
|
||||
assertEquals(2, list.size());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-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,13 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
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.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.aop.framework.Advised;
|
||||
import org.springframework.batch.core.Step;
|
||||
import org.springframework.batch.core.StepListener;
|
||||
@@ -31,8 +30,7 @@ import org.springframework.batch.core.listener.ItemListenerSupport;
|
||||
import org.springframework.batch.core.step.tasklet.TaskletStep;
|
||||
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;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
/**
|
||||
@@ -40,9 +38,8 @@ import org.springframework.test.util.ReflectionTestUtils;
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @since 2.0
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class StepListenerParserTests {
|
||||
@SpringJUnitConfig
|
||||
class StepListenerParserTests {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("s1")
|
||||
@@ -57,7 +54,7 @@ public class StepListenerParserTests {
|
||||
private Step step3;
|
||||
|
||||
@Test
|
||||
public void testInheritListeners() throws Exception {
|
||||
void testInheritListeners() throws Exception {
|
||||
|
||||
List<?> list = getListeners(step1);
|
||||
|
||||
@@ -82,7 +79,7 @@ public class StepListenerParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInheritListenersNoMerge() throws Exception {
|
||||
void testInheritListenersNoMerge() throws Exception {
|
||||
|
||||
List<?> list = getListeners(step2);
|
||||
|
||||
@@ -102,7 +99,7 @@ public class StepListenerParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInheritListenersNoMergeFaultTolerant() throws Exception {
|
||||
void testInheritListenersNoMergeFaultTolerant() throws Exception {
|
||||
|
||||
List<?> list = getListeners(step3);
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -15,19 +15,18 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
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 java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.springframework.batch.core.Job;
|
||||
import org.springframework.batch.core.step.StepLocator;
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
@@ -36,49 +35,45 @@ import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.FileSystemXmlApplicationContext;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.support.ResourceArrayPropertyEditor;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public class StepNameTests {
|
||||
class StepNameTests {
|
||||
|
||||
private Map<String, StepLocator> stepLocators = new HashMap<>();
|
||||
|
||||
private ApplicationContext context;
|
||||
|
||||
public StepNameTests(Resource resource) throws Exception {
|
||||
@Nullable
|
||||
private ApplicationContext getContextFromResource(Resource resource) throws IOException {
|
||||
try {
|
||||
context = new FileSystemXmlApplicationContext("file:///" + resource.getFile().getAbsolutePath());
|
||||
return new FileSystemXmlApplicationContext("file:///" + resource.getFile().getAbsolutePath());
|
||||
}
|
||||
catch (BeanDefinitionParsingException e) {
|
||||
return;
|
||||
catch (BeanDefinitionParsingException | BeanCreationException e) {
|
||||
return null;
|
||||
}
|
||||
catch (BeanCreationException e) {
|
||||
}
|
||||
|
||||
@MethodSource
|
||||
@ParameterizedTest
|
||||
void testStepNames(Resource resource) throws Exception {
|
||||
ApplicationContext context = getContextFromResource(resource);
|
||||
if (context == null) {
|
||||
return;
|
||||
}
|
||||
Map<String, StepLocator> stepLocators = context.getBeansOfType(StepLocator.class);
|
||||
this.stepLocators = stepLocators;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStepNames() throws Exception {
|
||||
for (String name : stepLocators.keySet()) {
|
||||
StepLocator stepLocator = stepLocators.get(name);
|
||||
Collection<String> stepNames = stepLocator.getStepNames();
|
||||
Job job = (Job) context.getBean(name);
|
||||
String jobName = job.getName();
|
||||
assertTrue("Job has no steps: " + jobName, !stepNames.isEmpty());
|
||||
assertFalse(stepNames.isEmpty(), "Job has no steps: " + jobName);
|
||||
for (String registeredName : stepNames) {
|
||||
String stepName = stepLocator.getStep(registeredName).getName();
|
||||
assertEquals(
|
||||
"Step name not equal to registered value: " + stepName + "!=" + registeredName + ", " + jobName,
|
||||
stepName, registeredName);
|
||||
assertEquals(stepName, registeredName, "Step name not equal to registered value: " + stepName + "!="
|
||||
+ registeredName + ", " + jobName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Parameters
|
||||
public static List<Object[]> data() throws Exception {
|
||||
List<Object[]> list = new ArrayList<>();
|
||||
static List<Arguments> testStepNames() throws Exception {
|
||||
List<Arguments> list = new ArrayList<>();
|
||||
ResourceArrayPropertyEditor editor = new ResourceArrayPropertyEditor();
|
||||
editor.setAsText("classpath*:" + ClassUtils.addResourcePathToPackagePath(StepNameTests.class, "*.xml"));
|
||||
Resource[] resources = (Resource[]) editor.getValue();
|
||||
@@ -86,7 +81,7 @@ public class StepNameTests {
|
||||
if (resource.getFile().getName().contains("WrongSchema")) {
|
||||
continue;
|
||||
}
|
||||
list.add(new Object[] { resource });
|
||||
list.add(Arguments.of(resource));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -19,7 +19,7 @@ package org.springframework.batch.core.configuration.xml;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.aop.framework.Advised;
|
||||
import org.springframework.aop.framework.ProxyFactory;
|
||||
@@ -48,25 +48,26 @@ import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.transaction.annotation.Isolation;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
|
||||
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.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* @author Dan Garrette
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @since 2.0
|
||||
*/
|
||||
public class StepParserStepFactoryBeanTests {
|
||||
class StepParserStepFactoryBeanTests {
|
||||
|
||||
@Test(expected = StepBuilderException.class)
|
||||
public void testNothingSet() throws Exception {
|
||||
@Test
|
||||
void testNothingSet() {
|
||||
StepParserStepFactoryBean<Object, Object> fb = new StepParserStepFactoryBean<>();
|
||||
fb.getObject();
|
||||
assertThrows(StepBuilderException.class, fb::getObject);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnlyTaskletSet() throws Exception {
|
||||
void testOnlyTaskletSet() throws Exception {
|
||||
StepParserStepFactoryBean<Object, Object> fb = new StepParserStepFactoryBean<>();
|
||||
fb.setName("step");
|
||||
fb.setTransactionManager(new ResourcelessTransactionManager());
|
||||
@@ -79,7 +80,7 @@ public class StepParserStepFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnlyTaskletTaskExecutor() throws Exception {
|
||||
void testOnlyTaskletTaskExecutor() throws Exception {
|
||||
StepParserStepFactoryBean<Object, Object> fb = new StepParserStepFactoryBean<>();
|
||||
fb.setName("step");
|
||||
fb.setTransactionManager(new ResourcelessTransactionManager());
|
||||
@@ -92,16 +93,16 @@ public class StepParserStepFactoryBeanTests {
|
||||
assertTrue(stepOperations instanceof TaskExecutorRepeatTemplate);
|
||||
}
|
||||
|
||||
@Test(expected = StepBuilderException.class)
|
||||
public void testSkipLimitSet() throws Exception {
|
||||
@Test
|
||||
void testSkipLimitSet() {
|
||||
StepParserStepFactoryBean<Object, Object> fb = new StepParserStepFactoryBean<>();
|
||||
fb.setName("step");
|
||||
fb.setSkipLimit(5);
|
||||
fb.getObject();
|
||||
assertThrows(StepBuilderException.class, fb::getObject);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTaskletStepAll() throws Exception {
|
||||
void testTaskletStepAll() throws Exception {
|
||||
StepParserStepFactoryBean<Object, Object> fb = new StepParserStepFactoryBean<>();
|
||||
fb.setBeanName("step1");
|
||||
fb.setAllowStartIfComplete(true);
|
||||
@@ -121,7 +122,7 @@ public class StepParserStepFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTaskletStepMissingIsolation() throws Exception {
|
||||
void testTaskletStepMissingIsolation() throws Exception {
|
||||
StepParserStepFactoryBean<Object, Object> fb = new StepParserStepFactoryBean<>();
|
||||
fb.setBeanName("step1");
|
||||
fb.setJobRepository(new JobRepositorySupport());
|
||||
@@ -134,8 +135,8 @@ public class StepParserStepFactoryBeanTests {
|
||||
assertTrue(tasklet instanceof DummyTasklet);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testSimpleStepAll() throws Exception {
|
||||
@Test
|
||||
void testSimpleStepAll() {
|
||||
StepParserStepFactoryBean<Object, Object> fb = new StepParserStepFactoryBean<>();
|
||||
fb.setBeanName("step1");
|
||||
fb.setAllowStartIfComplete(true);
|
||||
@@ -155,14 +156,11 @@ public class StepParserStepFactoryBeanTests {
|
||||
fb.setStreams(new ItemStream[] { new FlatFileItemReader<>() });
|
||||
fb.setHasChunkElement(true);
|
||||
|
||||
Object step = fb.getObject();
|
||||
assertTrue(step instanceof TaskletStep);
|
||||
Object tasklet = ReflectionTestUtils.getField(step, "tasklet");
|
||||
assertTrue(tasklet instanceof ChunkOrientedTasklet<?>);
|
||||
assertThrows(IllegalStateException.class, fb::getObject);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testFaultTolerantStepAll() throws Exception {
|
||||
@Test
|
||||
void testFaultTolerantStepAll() {
|
||||
StepParserStepFactoryBean<Object, Object> fb = new StepParserStepFactoryBean<>();
|
||||
fb.setBeanName("step1");
|
||||
fb.setAllowStartIfComplete(true);
|
||||
@@ -189,14 +187,11 @@ public class StepParserStepFactoryBeanTests {
|
||||
fb.setRetryableExceptionClasses(new HashMap<>());
|
||||
fb.setHasChunkElement(true);
|
||||
|
||||
Object step = fb.getObject();
|
||||
assertTrue(step instanceof TaskletStep);
|
||||
Object tasklet = ReflectionTestUtils.getField(step, "tasklet");
|
||||
assertTrue(tasklet instanceof ChunkOrientedTasklet<?>);
|
||||
assertThrows(IllegalArgumentException.class, fb::getObject);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleStep() throws Exception {
|
||||
void testSimpleStep() throws Exception {
|
||||
StepParserStepFactoryBean<Object, Object> fb = new StepParserStepFactoryBean<>();
|
||||
fb.setHasChunkElement(true);
|
||||
fb.setBeanName("step1");
|
||||
@@ -223,7 +218,7 @@ public class StepParserStepFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFaultTolerantStep() throws Exception {
|
||||
void testFaultTolerantStep() throws Exception {
|
||||
StepParserStepFactoryBean<Object, Object> fb = new StepParserStepFactoryBean<>();
|
||||
fb.setHasChunkElement(true);
|
||||
fb.setBeanName("step1");
|
||||
@@ -265,7 +260,7 @@ public class StepParserStepFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPartitionStep() throws Exception {
|
||||
void testPartitionStep() throws Exception {
|
||||
StepParserStepFactoryBean<Object, Object> fb = new StepParserStepFactoryBean<>();
|
||||
fb.setBeanName("step1");
|
||||
fb.setAllowStartIfComplete(true);
|
||||
@@ -286,7 +281,7 @@ public class StepParserStepFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPartitionStepWithProxyHandler() throws Exception {
|
||||
void testPartitionStepWithProxyHandler() throws Exception {
|
||||
StepParserStepFactoryBean<Object, Object> fb = new StepParserStepFactoryBean<>();
|
||||
fb.setBeanName("step1");
|
||||
fb.setAllowStartIfComplete(true);
|
||||
@@ -310,7 +305,7 @@ public class StepParserStepFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFlowStep() throws Exception {
|
||||
void testFlowStep() throws Exception {
|
||||
StepParserStepFactoryBean<Object, Object> fb = new StepParserStepFactoryBean<>();
|
||||
fb.setBeanName("step1");
|
||||
fb.setAllowStartIfComplete(true);
|
||||
|
||||
@@ -15,8 +15,10 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
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.assertSame;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -27,8 +29,8 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.aop.framework.Advised;
|
||||
import org.springframework.batch.core.Step;
|
||||
import org.springframework.batch.core.StepExecutionListener;
|
||||
@@ -70,15 +72,14 @@ public class StepParserTests {
|
||||
|
||||
private static ApplicationContext stepParserParentAttributeTestsCtx;
|
||||
|
||||
@BeforeClass
|
||||
@BeforeAll
|
||||
public static void loadAppCtx() {
|
||||
stepParserParentAttributeTestsCtx = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/StepParserParentAttributeTests-context.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void testTaskletStepAttributes() throws Exception {
|
||||
void testTaskletStepAttributes() throws Exception {
|
||||
ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/StepParserTaskletAttributesTests-context.xml");
|
||||
@SuppressWarnings({ "rawtypes" })
|
||||
@@ -87,36 +88,33 @@ public class StepParserTests {
|
||||
@SuppressWarnings("unchecked")
|
||||
StepParserStepFactoryBean<Object, Object> factory = beans.get(factoryName);
|
||||
TaskletStep bean = (TaskletStep) factory.getObject();
|
||||
assertEquals("wrong start-limit:", 25, bean.getStartLimit());
|
||||
assertEquals(25, bean.getStartLimit(), "wrong start-limit:");
|
||||
Object throttleLimit = ReflectionTestUtils.getField(factory, "throttleLimit");
|
||||
assertEquals(Integer.valueOf(10), throttleLimit);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void testStepParserBeanName() throws Exception {
|
||||
void testStepParserBeanName() {
|
||||
ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/StepParserBeanNameTests-context.xml");
|
||||
Map<String, Step> beans = ctx.getBeansOfType(Step.class);
|
||||
assertTrue("'s1' bean not found", beans.containsKey("s1"));
|
||||
assertTrue(beans.containsKey("s1"), "'s1' bean not found");
|
||||
Step s1 = (Step) ctx.getBean("s1");
|
||||
assertEquals("wrong name", "s1", s1.getName());
|
||||
}
|
||||
|
||||
@Test(expected = BeanDefinitionParsingException.class)
|
||||
@SuppressWarnings("resource")
|
||||
public void testStepParserCommitIntervalCompletionPolicy() throws Exception {
|
||||
new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/StepParserCommitIntervalCompletionPolicyTests-context.xml");
|
||||
assertEquals("s1", s1.getName(), "wrong name");
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void testStepParserCommitInterval() throws Exception {
|
||||
void testStepParserCommitIntervalCompletionPolicy() {
|
||||
assertThrows(BeanDefinitionParsingException.class, () -> new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/StepParserCommitIntervalCompletionPolicyTests-context.xml"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testStepParserCommitInterval() throws Exception {
|
||||
ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/StepParserCommitIntervalTests-context.xml");
|
||||
Map<String, Step> beans = ctx.getBeansOfType(Step.class);
|
||||
assertTrue("'s1' bean not found", beans.containsKey("s1"));
|
||||
assertTrue(beans.containsKey("s1"), "'s1' bean not found");
|
||||
Step s1 = (Step) ctx.getBean("s1");
|
||||
CompletionPolicy completionPolicy = getCompletionPolicy(s1);
|
||||
assertTrue(completionPolicy instanceof SimpleCompletionPolicy);
|
||||
@@ -124,12 +122,11 @@ public class StepParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void testStepParserCompletionPolicy() throws Exception {
|
||||
void testStepParserCompletionPolicy() throws Exception {
|
||||
ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/StepParserCompletionPolicyTests-context.xml");
|
||||
Map<String, Step> beans = ctx.getBeansOfType(Step.class);
|
||||
assertTrue("'s1' bean not found", beans.containsKey("s1"));
|
||||
assertTrue(beans.containsKey("s1"), "'s1' bean not found");
|
||||
Step s1 = (Step) ctx.getBean("s1");
|
||||
CompletionPolicy completionPolicy = getCompletionPolicy(s1);
|
||||
assertTrue(completionPolicy instanceof DummyCompletionPolicy);
|
||||
@@ -142,29 +139,26 @@ public class StepParserTests {
|
||||
return (CompletionPolicy) ReflectionTestUtils.getField(repeatOperations, "completionPolicy");
|
||||
}
|
||||
|
||||
@Test(expected = BeanDefinitionParsingException.class)
|
||||
@SuppressWarnings("resource")
|
||||
public void testStepParserNoCommitIntervalOrCompletionPolicy() throws Exception {
|
||||
new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/StepParserNoCommitIntervalOrCompletionPolicyTests-context.xml");
|
||||
}
|
||||
|
||||
@Test(expected = BeanDefinitionParsingException.class)
|
||||
@SuppressWarnings("resource")
|
||||
public void testTaskletStepWithBadStepListener() throws Exception {
|
||||
new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/StepParserBadStepListenerTests-context.xml");
|
||||
}
|
||||
|
||||
@Test(expected = BeanDefinitionParsingException.class)
|
||||
@SuppressWarnings("resource")
|
||||
public void testTaskletStepWithBadRetryListener() throws Exception {
|
||||
new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/StepParserBadRetryListenerTests-context.xml");
|
||||
@Test
|
||||
void testStepParserNoCommitIntervalOrCompletionPolicy() {
|
||||
assertThrows(BeanDefinitionParsingException.class, () -> new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/StepParserNoCommitIntervalOrCompletionPolicyTests-context.xml"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParentStep() throws Exception {
|
||||
void testTaskletStepWithBadStepListener() {
|
||||
assertThrows(BeanDefinitionParsingException.class, () -> new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/StepParserBadStepListenerTests-context.xml"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTaskletStepWithBadRetryListener() {
|
||||
assertThrows(BeanDefinitionParsingException.class, () -> new ClassPathXmlApplicationContext(
|
||||
"org/springframework/batch/core/configuration/xml/StepParserBadRetryListenerTests-context.xml"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testParentStep() throws Exception {
|
||||
ApplicationContext ctx = stepParserParentAttributeTestsCtx;
|
||||
|
||||
// Inline Step
|
||||
@@ -181,7 +175,7 @@ public class StepParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInheritTransactionAttributes() throws Exception {
|
||||
void testInheritTransactionAttributes() throws Exception {
|
||||
ApplicationContext ctx = stepParserParentAttributeTestsCtx;
|
||||
|
||||
// On Inline - No Merge
|
||||
@@ -250,7 +244,7 @@ public class StepParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInheritFromBean() throws Exception {
|
||||
void testInheritFromBean() {
|
||||
ApplicationContext ctx = stepParserParentAttributeTestsCtx;
|
||||
|
||||
assertTrue(getTasklet("s9", ctx) instanceof DummyTasklet);
|
||||
@@ -267,7 +261,7 @@ public class StepParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJobRepositoryDefaults() throws Exception {
|
||||
void testJobRepositoryDefaults() throws Exception {
|
||||
ApplicationContext ctx = stepParserParentAttributeTestsCtx;
|
||||
|
||||
assertTrue(getJobRepository("defaultRepoStep", ctx) instanceof SimpleJobRepository);
|
||||
@@ -294,7 +288,7 @@ public class StepParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTransactionManagerDefaults() throws Exception {
|
||||
void testTransactionManagerDefaults() throws Exception {
|
||||
ApplicationContext ctx = stepParserParentAttributeTestsCtx;
|
||||
|
||||
assertTrue(getTransactionManager("defaultTxMgrStep", ctx) instanceof JdbcTransactionManager);
|
||||
@@ -344,7 +338,7 @@ public class StepParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNonAbstractStep() {
|
||||
void testNonAbstractStep() {
|
||||
ApplicationContext ctx = stepParserParentAttributeTestsCtx;
|
||||
|
||||
assertTrue(ctx.containsBean("s11"));
|
||||
@@ -353,7 +347,7 @@ public class StepParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInlineTaskletElementOverridesParentBeanClass() {
|
||||
void testInlineTaskletElementOverridesParentBeanClass() {
|
||||
ApplicationContext ctx = stepParserParentAttributeTestsCtx;
|
||||
|
||||
assertTrue(ctx.containsBean("&s12"));
|
||||
@@ -370,7 +364,7 @@ public class StepParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTaskletElementOverridesChildBeanClass() {
|
||||
void testTaskletElementOverridesChildBeanClass() {
|
||||
ApplicationContext ctx = stepParserParentAttributeTestsCtx;
|
||||
|
||||
assertTrue(ctx.containsBean("&s13"));
|
||||
@@ -399,7 +393,7 @@ public class StepParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTaskletElementOverridesParentBeanClass() {
|
||||
void testTaskletElementOverridesParentBeanClass() {
|
||||
ApplicationContext ctx = stepParserParentAttributeTestsCtx;
|
||||
|
||||
assertTrue(ctx.containsBean("&s14"));
|
||||
@@ -425,7 +419,7 @@ public class StepParserTests {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testStepWithListsMerge() throws Exception {
|
||||
void testStepWithListsMerge() throws Exception {
|
||||
ApplicationContext ctx = stepParserParentAttributeTestsCtx;
|
||||
|
||||
Map<Class<? extends Throwable>, Boolean> skippable = new HashMap<>();
|
||||
@@ -466,7 +460,7 @@ public class StepParserTests {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testStepWithListsNoMerge() throws Exception {
|
||||
void testStepWithListsNoMerge() throws Exception {
|
||||
ApplicationContext ctx = stepParserParentAttributeTestsCtx;
|
||||
|
||||
Map<Class<? extends Throwable>, Boolean> skippable = new HashMap<>();
|
||||
@@ -501,7 +495,7 @@ public class StepParserTests {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testStepWithListsOverrideWithEmpty() throws Exception {
|
||||
void testStepWithListsOverrideWithEmpty() throws Exception {
|
||||
ApplicationContext ctx = stepParserParentAttributeTestsCtx;
|
||||
|
||||
StepParserStepFactoryBean<?, ?> fb = (StepParserStepFactoryBean<?, ?>) ctx
|
||||
|
||||
@@ -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,14 +15,13 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
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.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
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.Job;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
@@ -32,17 +31,15 @@ import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.item.ItemStream;
|
||||
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;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
/**
|
||||
* @author Thomas Risberg
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class StepWithBasicProcessTaskJobParserTests {
|
||||
@SpringJUnitConfig
|
||||
class StepWithBasicProcessTaskJobParserTests {
|
||||
|
||||
@Autowired
|
||||
private Job job;
|
||||
@@ -68,14 +65,14 @@ public class StepWithBasicProcessTaskJobParserTests {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testStepWithTask() throws Exception {
|
||||
void testStepWithTask() throws Exception {
|
||||
assertNotNull(job);
|
||||
Object ci = ReflectionTestUtils.getField(factory, "commitInterval");
|
||||
assertEquals("wrong chunk-size:", 10, ci);
|
||||
assertEquals(10, ci, "wrong chunk-size:");
|
||||
Object listeners = ReflectionTestUtils.getField(factory, "stepExecutionListeners");
|
||||
assertEquals("wrong number of listeners:", 2, ((Set<StepExecutionListener>) listeners).size());
|
||||
assertEquals(2, ((Set<StepExecutionListener>) listeners).size(), "wrong number of listeners:");
|
||||
Object streams = ReflectionTestUtils.getField(factory, "streams");
|
||||
assertEquals("wrong number of streams:", 1, ((ItemStream[]) streams).length);
|
||||
assertEquals(1, ((ItemStream[]) streams).length, "wrong number of streams:");
|
||||
JobExecution jobExecution = jobRepository.createJobExecution(job.getName(), new JobParameters());
|
||||
job.execute(jobExecution);
|
||||
assertEquals(BatchStatus.COMPLETED, 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.
|
||||
@@ -15,14 +15,13 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
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.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
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.Job;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
@@ -34,8 +33,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.retry.RetryListener;
|
||||
import org.springframework.scheduling.concurrent.ConcurrentTaskExecutor;
|
||||
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.util.ReflectionTestUtils;
|
||||
import org.springframework.transaction.annotation.Isolation;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
@@ -44,9 +42,8 @@ import org.springframework.transaction.annotation.Propagation;
|
||||
* @author Thomas Risberg
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class StepWithFaultTolerantProcessTaskJobParserTests {
|
||||
@SpringJUnitConfig
|
||||
class StepWithFaultTolerantProcessTaskJobParserTests {
|
||||
|
||||
@Autowired
|
||||
private Job job;
|
||||
@@ -75,31 +72,31 @@ public class StepWithFaultTolerantProcessTaskJobParserTests {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testStepWithTask() throws Exception {
|
||||
void testStepWithTask() throws Exception {
|
||||
assertNotNull(job);
|
||||
Object ci = ReflectionTestUtils.getField(factory, "commitInterval");
|
||||
assertEquals("wrong chunk-size:", 10, ci);
|
||||
assertEquals(10, ci, "wrong chunk-size:");
|
||||
Object sl = ReflectionTestUtils.getField(factory, "skipLimit");
|
||||
assertEquals("wrong skip-limit:", 20, sl);
|
||||
assertEquals(20, sl, "wrong skip-limit:");
|
||||
Object rl = ReflectionTestUtils.getField(factory, "retryLimit");
|
||||
assertEquals("wrong retry-limit:", 3, rl);
|
||||
assertEquals(3, rl, "wrong retry-limit:");
|
||||
Object cc = ReflectionTestUtils.getField(factory, "cacheCapacity");
|
||||
assertEquals("wrong cache-capacity:", 100, cc);
|
||||
assertEquals("wrong transaction-attribute:", Propagation.REQUIRED,
|
||||
ReflectionTestUtils.getField(factory, "propagation"));
|
||||
assertEquals("wrong transaction-attribute:", Isolation.DEFAULT,
|
||||
ReflectionTestUtils.getField(factory, "isolation"));
|
||||
assertEquals("wrong transaction-attribute:", 10, ReflectionTestUtils.getField(factory, "transactionTimeout"));
|
||||
assertEquals(100, cc, "wrong cache-capacity:");
|
||||
assertEquals(Propagation.REQUIRED, ReflectionTestUtils.getField(factory, "propagation"),
|
||||
"wrong transaction-attribute:");
|
||||
assertEquals(Isolation.DEFAULT, ReflectionTestUtils.getField(factory, "isolation"),
|
||||
"wrong transaction-attribute:");
|
||||
assertEquals(10, ReflectionTestUtils.getField(factory, "transactionTimeout"), "wrong transaction-attribute:");
|
||||
Object txq = ReflectionTestUtils.getField(factory, "readerTransactionalQueue");
|
||||
assertEquals("wrong reader-transactional-queue:", true, txq);
|
||||
assertEquals(true, txq, "wrong reader-transactional-queue:");
|
||||
Object te = ReflectionTestUtils.getField(factory, "taskExecutor");
|
||||
assertEquals("wrong task-executor:", ConcurrentTaskExecutor.class, te.getClass());
|
||||
assertEquals(ConcurrentTaskExecutor.class, te.getClass(), "wrong task-executor:");
|
||||
Object listeners = ReflectionTestUtils.getField(factory, "stepExecutionListeners");
|
||||
assertEquals("wrong number of listeners:", 2, ((Set<StepExecutionListener>) listeners).size());
|
||||
assertEquals(2, ((Set<StepExecutionListener>) listeners).size(), "wrong number of listeners:");
|
||||
Object retryListeners = ReflectionTestUtils.getField(factory, "retryListeners");
|
||||
assertEquals("wrong number of retry-listeners:", 2, ((RetryListener[]) retryListeners).length);
|
||||
assertEquals(2, ((RetryListener[]) retryListeners).length, "wrong number of retry-listeners:");
|
||||
Object streams = ReflectionTestUtils.getField(factory, "streams");
|
||||
assertEquals("wrong number of streams:", 1, ((ItemStream[]) streams).length);
|
||||
assertEquals(1, ((ItemStream[]) streams).length, "wrong number of streams:");
|
||||
JobExecution jobExecution = jobRepository.createJobExecution(job.getName(), new JobParameters());
|
||||
job.execute(jobExecution);
|
||||
assertEquals(BatchStatus.COMPLETED, 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.
|
||||
@@ -15,12 +15,11 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
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.assertNotNull;
|
||||
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.BatchStatus;
|
||||
import org.springframework.batch.core.Job;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
@@ -28,16 +27,14 @@ import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
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
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class StepWithPojoListenerJobParserTests {
|
||||
@SpringJUnitConfig
|
||||
class StepWithPojoListenerJobParserTests {
|
||||
|
||||
@Autowired
|
||||
private Job job;
|
||||
@@ -56,7 +53,7 @@ public class StepWithPojoListenerJobParserTests {
|
||||
private TestWriter writer;
|
||||
|
||||
@Test
|
||||
public void testStepWithTask() throws Exception {
|
||||
void testStepWithTask() throws Exception {
|
||||
assertNotNull(job);
|
||||
JobExecution jobExecution = jobRepository.createJobExecution(job.getName(), new JobParameters());
|
||||
job.execute(jobExecution);
|
||||
|
||||
@@ -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,12 +15,12 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
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.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;
|
||||
@@ -31,16 +31,14 @@ import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.core.step.tasklet.TaskletStep;
|
||||
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;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
/**
|
||||
* @author Thomas Risberg
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class StepWithSimpleTaskJobParserTests {
|
||||
@SpringJUnitConfig
|
||||
class StepWithSimpleTaskJobParserTests {
|
||||
|
||||
@Autowired
|
||||
private Job job;
|
||||
@@ -53,7 +51,7 @@ public class StepWithSimpleTaskJobParserTests {
|
||||
private TestListener listener;
|
||||
|
||||
@Test
|
||||
public void testJob() throws Exception {
|
||||
void testJob() throws Exception {
|
||||
assertNotNull(job);
|
||||
assertTrue(job instanceof FlowJob);
|
||||
JobExecution jobExecution = jobRepository.createJobExecution(job.getName(), new JobParameters());
|
||||
@@ -78,12 +76,12 @@ public class StepWithSimpleTaskJobParserTests {
|
||||
private TestTasklet assertTasklet(Job job, String stepName, String taskletName) {
|
||||
System.err.println(((FlowJob) job).getStepNames());
|
||||
Step step = ((FlowJob) job).getStep(stepName);
|
||||
assertTrue("Wrong type for step name=" + stepName + ": " + step, step instanceof TaskletStep);
|
||||
assertTrue(step instanceof TaskletStep, "Wrong type for step name=" + stepName + ": " + step);
|
||||
Object tasklet = ReflectionTestUtils.getField(step, "tasklet");
|
||||
assertTrue(tasklet instanceof TestTasklet);
|
||||
TestTasklet testTasklet = (TestTasklet) tasklet;
|
||||
assertEquals(taskletName, testTasklet.getName());
|
||||
assertTrue(!testTasklet.isExecuted());
|
||||
assertFalse(testTasklet.isExecuted());
|
||||
return testTasklet;
|
||||
}
|
||||
|
||||
|
||||
@@ -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,10 +15,9 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
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.ExitStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
@@ -26,22 +25,20 @@ import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
|
||||
import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException;
|
||||
import org.springframework.batch.core.repository.JobRestartException;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringJUnitConfig
|
||||
// FIXME this test fails when upgrading the batch xsd from 2.2 to 3.0:
|
||||
// https://github.com/spring-projects/spring-batch/issues/1287
|
||||
public class StopAndRestartFailedJobParserTests extends AbstractJobParserTests {
|
||||
class StopAndRestartFailedJobParserTests extends AbstractJobParserTests {
|
||||
|
||||
@Test
|
||||
public void testStopRestartOnCompletedStep() throws Exception {
|
||||
void testStopRestartOnCompletedStep() throws Exception {
|
||||
|
||||
//
|
||||
// First Launch
|
||||
|
||||
@@ -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.core.configuration.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringJUnitConfig
|
||||
// FIXME this test fails when upgrading the batch xsd from 2.2 to 3.0:
|
||||
// https://github.com/spring-projects/spring-batch/issues/1287
|
||||
public class StopAndRestartJobParserTests extends AbstractJobParserTests {
|
||||
class StopAndRestartJobParserTests extends AbstractJobParserTests {
|
||||
|
||||
@Test
|
||||
public void testStopIncomplete() throws Exception {
|
||||
void testStopIncomplete() throws Exception {
|
||||
|
||||
//
|
||||
// First Launch
|
||||
|
||||
@@ -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.core.configuration.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringJUnitConfig
|
||||
// FIXME this test fails when upgrading the batch xsd from 2.2 to 3.0:
|
||||
// https://github.com/spring-projects/spring-batch/issues/1287
|
||||
public class StopCustomStatusJobParserTests extends AbstractJobParserTests {
|
||||
class StopCustomStatusJobParserTests extends AbstractJobParserTests {
|
||||
|
||||
@Test
|
||||
public void testStopCustomStatus() throws Exception {
|
||||
void testStopCustomStatus() throws Exception {
|
||||
|
||||
//
|
||||
// First Launch
|
||||
@@ -45,7 +42,7 @@ public class StopCustomStatusJobParserTests extends AbstractJobParserTests {
|
||||
JobExecution jobExecution = createJobExecution();
|
||||
job.execute(jobExecution);
|
||||
assertEquals(1, stepNamesList.size());
|
||||
assertEquals("Wrong steps executed: " + stepNamesList, "[stop]", stepNamesList.toString());
|
||||
assertEquals("[stop]", stepNamesList.toString(), "Wrong steps executed: " + stepNamesList);
|
||||
|
||||
assertEquals(BatchStatus.STOPPED, jobExecution.getStatus());
|
||||
assertEquals(ExitStatus.STOPPED.getExitCode(), jobExecution.getExitStatus().getExitCode());
|
||||
@@ -61,7 +58,7 @@ public class StopCustomStatusJobParserTests extends AbstractJobParserTests {
|
||||
jobExecution = createJobExecution();
|
||||
job.execute(jobExecution);
|
||||
assertEquals(1, stepNamesList.size()); // step1 is not executed
|
||||
assertEquals("Wrong steps executed: " + stepNamesList, "[s2]", stepNamesList.toString());
|
||||
assertEquals("[s2]", stepNamesList.toString(), "Wrong steps executed: " + stepNamesList);
|
||||
|
||||
assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
|
||||
assertEquals(ExitStatus.COMPLETED, jobExecution.getExitStatus());
|
||||
|
||||
@@ -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.core.configuration.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringJUnitConfig
|
||||
// FIXME this test fails when upgrading the batch xsd from 2.2 to 3.0:
|
||||
// https://github.com/spring-projects/spring-batch/issues/1287
|
||||
public class StopIncompleteJobParserTests extends AbstractJobParserTests {
|
||||
class StopIncompleteJobParserTests extends AbstractJobParserTests {
|
||||
|
||||
@Test
|
||||
public void testStopIncomplete() throws Exception {
|
||||
void testStopIncomplete() throws Exception {
|
||||
|
||||
//
|
||||
// First Launch
|
||||
@@ -45,7 +42,7 @@ public class StopIncompleteJobParserTests extends AbstractJobParserTests {
|
||||
JobExecution jobExecution = createJobExecution();
|
||||
job.execute(jobExecution);
|
||||
assertEquals(1, stepNamesList.size());
|
||||
assertEquals("Wrong steps executed: " + stepNamesList, "[fail]", stepNamesList.toString());
|
||||
assertEquals("[fail]", stepNamesList.toString(), "Wrong steps executed: " + stepNamesList);
|
||||
|
||||
assertEquals(BatchStatus.STOPPED, jobExecution.getStatus());
|
||||
assertEquals(ExitStatus.STOPPED.getExitCode(), jobExecution.getExitStatus().getExitCode());
|
||||
@@ -61,7 +58,7 @@ public class StopIncompleteJobParserTests extends AbstractJobParserTests {
|
||||
jobExecution = createJobExecution();
|
||||
job.execute(jobExecution);
|
||||
assertEquals(1, stepNamesList.size()); // step1 is not executed
|
||||
assertEquals("Wrong steps executed: " + stepNamesList, "[s2]", stepNamesList.toString());
|
||||
assertEquals("[s2]", stepNamesList.toString(), "Wrong steps executed: " + stepNamesList);
|
||||
|
||||
assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
|
||||
assertEquals(ExitStatus.COMPLETED, jobExecution.getExitStatus());
|
||||
|
||||
@@ -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,11 +15,10 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
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.core.BatchStatus;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
@@ -27,22 +26,20 @@ import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.job.flow.FlowExecutionStatus;
|
||||
import org.springframework.batch.core.job.flow.JobExecutionDecider;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringJUnitConfig
|
||||
// FIXME this test fails when upgrading the batch xsd from 2.2 to 3.0:
|
||||
// https://github.com/spring-projects/spring-batch/issues/1287
|
||||
public class StopJobParserTests extends AbstractJobParserTests {
|
||||
class StopJobParserTests extends AbstractJobParserTests {
|
||||
|
||||
@Test
|
||||
public void testStopState() throws Exception {
|
||||
void testStopState() throws Exception {
|
||||
|
||||
//
|
||||
// First Launch
|
||||
|
||||
@@ -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,10 +15,9 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
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.ExitStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
@@ -26,19 +25,17 @@ import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
|
||||
import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException;
|
||||
import org.springframework.batch.core.repository.JobRestartException;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class StopRestartOnCompletedStepJobParserTests extends AbstractJobParserTests {
|
||||
@SpringJUnitConfig
|
||||
class StopRestartOnCompletedStepJobParserTests extends AbstractJobParserTests {
|
||||
|
||||
@Test
|
||||
public void testStopRestartOnCompletedStep() throws Exception {
|
||||
void testStopRestartOnCompletedStep() throws Exception {
|
||||
|
||||
//
|
||||
// First Launch
|
||||
|
||||
@@ -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,10 +15,9 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
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.ExitStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
@@ -26,19 +25,17 @@ import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
|
||||
import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException;
|
||||
import org.springframework.batch.core.repository.JobRestartException;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class StopRestartOnFailedStepJobParserTests extends AbstractJobParserTests {
|
||||
@SpringJUnitConfig
|
||||
class StopRestartOnFailedStepJobParserTests extends AbstractJobParserTests {
|
||||
|
||||
@Test
|
||||
public void testStopRestartOnCompletedStep() throws Exception {
|
||||
void testStopRestartOnCompletedStep() throws Exception {
|
||||
|
||||
//
|
||||
// First Launch
|
||||
|
||||
@@ -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,11 +15,10 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
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;
|
||||
@@ -27,17 +26,15 @@ import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
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
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class TaskletParserAdapterTests {
|
||||
@SpringJUnitConfig
|
||||
class TaskletParserAdapterTests {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("job1")
|
||||
@@ -51,7 +48,7 @@ public class TaskletParserAdapterTests {
|
||||
private JobRepository jobRepository;
|
||||
|
||||
@Test
|
||||
public void testTaskletRef() throws Exception {
|
||||
void testTaskletRef() throws Exception {
|
||||
assertNotNull(job1);
|
||||
JobExecution jobExecution = jobRepository.createJobExecution(job1.getName(), new JobParameters());
|
||||
job1.execute(jobExecution);
|
||||
@@ -59,7 +56,7 @@ public class TaskletParserAdapterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTaskletInline() throws Exception {
|
||||
void testTaskletInline() throws Exception {
|
||||
assertNotNull(job2);
|
||||
JobExecution jobExecution = jobRepository.createJobExecution(job2.getName(), new JobParameters());
|
||||
job2.execute(jobExecution);
|
||||
|
||||
@@ -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.
|
||||
@@ -17,8 +17,7 @@ package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
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;
|
||||
@@ -30,21 +29,19 @@ import org.springframework.batch.core.step.tasklet.TaskletStep;
|
||||
import org.springframework.batch.core.test.namespace.config.DummyNamespaceHandler;
|
||||
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;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class TaskletParserBeanPropertiesTests {
|
||||
@SpringJUnitConfig
|
||||
class TaskletParserBeanPropertiesTests {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("job1")
|
||||
@@ -70,7 +67,7 @@ public class TaskletParserBeanPropertiesTests {
|
||||
private JobRepository jobRepository;
|
||||
|
||||
@Test
|
||||
public void testTaskletRef() throws Exception {
|
||||
void testTaskletRef() throws Exception {
|
||||
assertNotNull(job1);
|
||||
JobExecution jobExecution = jobRepository.createJobExecution(job1.getName(), new JobParameters());
|
||||
job1.execute(jobExecution);
|
||||
@@ -79,7 +76,7 @@ public class TaskletParserBeanPropertiesTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTaskletInline() throws Exception {
|
||||
void testTaskletInline() throws Exception {
|
||||
assertNotNull(job2);
|
||||
JobExecution jobExecution = jobRepository.createJobExecution(job2.getName(), new JobParameters());
|
||||
job2.execute(jobExecution);
|
||||
@@ -90,7 +87,7 @@ public class TaskletParserBeanPropertiesTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTasklet3() throws Exception {
|
||||
void testTasklet3() throws Exception {
|
||||
assertNotNull(job3);
|
||||
JobExecution jobExecution = jobRepository.createJobExecution(job3.getName(), new JobParameters());
|
||||
job3.execute(jobExecution);
|
||||
@@ -104,7 +101,7 @@ public class TaskletParserBeanPropertiesTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomNestedTasklet() throws Exception {
|
||||
void testCustomNestedTasklet() throws Exception {
|
||||
assertNotNull(job4);
|
||||
JobExecution jobExecution = jobRepository.createJobExecution(job4.getName(), new JobParameters());
|
||||
job4.execute(jobExecution);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2021 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,15 +15,14 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
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.Date;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.core.Job;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobParametersBuilder;
|
||||
@@ -31,12 +30,10 @@ import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.core.step.AbstractStep;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
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 TaskletStepAllowStartIfCompleteTests {
|
||||
@SpringJUnitConfig
|
||||
class TaskletStepAllowStartIfCompleteTests {
|
||||
|
||||
@Autowired
|
||||
Job job;
|
||||
@@ -48,14 +45,14 @@ public class TaskletStepAllowStartIfCompleteTests {
|
||||
private ApplicationContext context;
|
||||
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
void test() throws Exception {
|
||||
// retrieve the step from the context and see that it's allow is set
|
||||
AbstractStep abstractStep = (AbstractStep) context.getBean("simpleJob.step1");
|
||||
assertTrue(abstractStep.isAllowStartIfComplete());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRestart() throws Exception {
|
||||
void testRestart() throws Exception {
|
||||
JobParametersBuilder paramBuilder = new JobParametersBuilder();
|
||||
paramBuilder.addDate("value", new Date());
|
||||
JobExecution jobExecution = jobRepository.createJobExecution(job.getName(), paramBuilder.toJobParameters());
|
||||
|
||||
@@ -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,27 +15,24 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
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;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class TwoStepJobParserTests {
|
||||
@SpringJUnitConfig
|
||||
class TwoStepJobParserTests {
|
||||
|
||||
@Autowired
|
||||
private Job job;
|
||||
@@ -44,7 +41,7 @@ public class TwoStepJobParserTests {
|
||||
private JobRepository jobRepository;
|
||||
|
||||
@Test
|
||||
public void testTwoStep() throws Exception {
|
||||
void testTwoStep() throws Exception {
|
||||
assertNotNull(job);
|
||||
JobExecution jobExecution = jobRepository.createJobExecution(job.getName(), new JobParameters());
|
||||
job.execute(jobExecution);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user