Updated for various code warnings

This commit addresses a number of deprications and other code warnings.
There are still many more to address, but this is a start.
This commit is contained in:
Michael Minella
2017-04-21 16:20:46 -05:00
parent a2a856e64b
commit 263e978a1f
128 changed files with 658 additions and 680 deletions

View File

@@ -15,11 +15,10 @@
*/
package org.springframework.batch.core.configuration.xml;
import static org.junit.Assert.fail;
import java.util.ArrayList;
import org.junit.Before;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobParametersBuilder;
@@ -31,6 +30,8 @@ import org.springframework.batch.core.repository.JobRestartException;
import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean;
import org.springframework.beans.factory.annotation.Autowired;
import static org.junit.Assert.fail;
/**
* @author Dan Garrette
* @since 2.0
@@ -63,11 +64,6 @@ public abstract class AbstractJobParserTests {
return jobRepository.createJobExecution(job.getName(), new JobParametersBuilder().addLong("key1", 1L).toJobParameters());
}
/**
* @param jobExecution
* @param stepName
* @return the StepExecution corresponding to the specified step
*/
protected StepExecution getStepExecution(JobExecution jobExecution, String stepName) {
for (StepExecution stepExecution : jobExecution.getStepExecutions()) {
if (stepExecution.getStepName().equals(stepName)) {

View File

@@ -15,18 +15,13 @@
*/
package org.springframework.batch.core.configuration.xml;
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 java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import java.util.Map;
import org.junit.Test;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.step.item.SimpleChunkProcessor;
import org.springframework.batch.core.step.skip.SkipPolicy;
@@ -50,6 +45,12 @@ 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;
/**
* @author Dan Garrette
* @author Dave Syer
@@ -338,7 +339,7 @@ public class ChunkElementParserTests {
/**
* @param object the target object
* @param path the path to the required field
* @return
* @return The field
*/
private Object getNestedPath(Object object, String path) {
while (StringUtils.hasText(path)) {

View File

@@ -43,9 +43,9 @@ public abstract class AbstractJsrTestCase {
* reach one of those statuses within the given timeout, a {@link java.util.concurrent.TimeoutException} is
* thrown.
*
* @param jobName
* @param properties
* @param timeout
* @param jobName Name of the job to run
* @param properties Properties to pass the job
* @param timeout length of time to wait for a job to finish
* @return the {@link javax.batch.runtime.JobExecution} for the final state of the job
* @throws java.util.concurrent.TimeoutException if the timeout occurs
*/
@@ -78,9 +78,9 @@ public abstract class AbstractJsrTestCase {
* reach one of those statuses within the given timeout, a {@link java.util.concurrent.TimeoutException} is
* thrown.
*
* @param executionId
* @param properties
* @param timeout
* @param executionId The execution id to restart
* @param properties The Properties to pass to the new run
* @param timeout The length of time to wait for the job to run
* @return the {@link JobExecution} for the final state of the job
* @throws java.util.concurrent.TimeoutException if the timeout occurs
*/

View File

@@ -15,12 +15,9 @@
*/
package org.springframework.batch.core.jsr.configuration.xml;
import static org.junit.Assert.assertEquals;
import java.io.Serializable;
import java.util.List;
import java.util.Properties;
import javax.batch.api.BatchProperty;
import javax.batch.api.Batchlet;
import javax.batch.api.Decider;
@@ -35,12 +32,15 @@ import javax.batch.runtime.context.JobContext;
import javax.inject.Inject;
import org.junit.Test;
import org.springframework.batch.core.StepContribution;
import org.springframework.batch.core.jsr.AbstractJsrTestCase;
import org.springframework.batch.core.scope.context.ChunkContext;
import org.springframework.batch.core.step.tasklet.Tasklet;
import org.springframework.batch.repeat.RepeatStatus;
import static org.junit.Assert.assertEquals;
/**
* <p>
* Configuration test for parsing various &lt;properties /&gt; elements defined by JSR-352.
@@ -78,30 +78,30 @@ public class JobPropertyTests extends AbstractJsrTestCase {
@Override
public void open(Serializable serializable) throws Exception {
org.springframework.util.Assert.notNull(stepContext);
org.springframework.util.Assert.isNull(stepContext.getProperties().get("step2PropertyName1"));
org.springframework.util.Assert.isNull(stepContext.getProperties().get("step2PropertyName2"));
org.springframework.util.Assert.isTrue(stepContext.getProperties().get("step1PropertyName1").equals("step1PropertyValue1"));
org.springframework.util.Assert.isTrue(stepContext.getProperties().get("step1PropertyName2").equals("step1PropertyValue2"));
org.springframework.util.Assert.isTrue(stepContext.getProperties().get("jobPropertyName1") == null);
org.springframework.util.Assert.isTrue(stepContext.getProperties().get("jobPropertyName2") == null);
org.springframework.util.Assert.isTrue("readerPropertyValue1".equals(readerPropertyName1));
org.springframework.util.Assert.isTrue("readerPropertyValue2".equals(readerPropertyName2));
org.springframework.util.Assert.isTrue("annotationNamedReaderPropertyValue".equals(annotationNamedProperty));
org.springframework.util.Assert.isNull(notDefinedProperty);
org.springframework.util.Assert.isNull(notDefinedAnnotationNamedProperty);
org.springframework.util.Assert.isNull(batchAnnotatedOnlyField);
org.springframework.util.Assert.notNull(injectAnnotatedOnlyField);
org.springframework.util.Assert.isTrue("job1".equals(injectAnnotatedOnlyField.getJobName()));
org.springframework.util.Assert.isNull(readerPropertyName3);
org.springframework.util.Assert.notNull(stepContext, "stepContext is not null");
org.springframework.util.Assert.isNull(stepContext.getProperties().get("step2PropertyName1"), "step2PropertyName1 is not null");
org.springframework.util.Assert.isNull(stepContext.getProperties().get("step2PropertyName2"), "step2PropertyName2 is not null");
org.springframework.util.Assert.isTrue(stepContext.getProperties().get("step1PropertyName1").equals("step1PropertyValue1"), "The value of step2PropertyName1 does not equal step2PropertyName1");
org.springframework.util.Assert.isTrue(stepContext.getProperties().get("step1PropertyName2").equals("step1PropertyValue2"), "The value of step2PropertyName2 does not equal step2PropertyName2");
org.springframework.util.Assert.isNull(stepContext.getProperties().get("jobPropertyName1"), "jobPropertyName1 is not null");
org.springframework.util.Assert.isNull(stepContext.getProperties().get("jobPropertyName2") == null, "jobPropertyName2 is not null");
org.springframework.util.Assert.isTrue("readerPropertyValue1".equals(readerPropertyName1), "The value of readerPropertyValue1 does not equal readerPropertyValue1");
org.springframework.util.Assert.isTrue("readerPropertyValue2".equals(readerPropertyName2), "The value of readerPropertyValue2 does not equal readerPropertyValue2");
org.springframework.util.Assert.isTrue("annotationNamedReaderPropertyValue".equals(annotationNamedProperty), "The value of annotationNamedReaderPropertyValue does not equal annotationNamedReaderPropertyValue");
org.springframework.util.Assert.isNull(notDefinedProperty, "notDefinedProperty is not null");
org.springframework.util.Assert.isNull(notDefinedAnnotationNamedProperty, "notDefinedAnnotationNamedProperty is not null");
org.springframework.util.Assert.isNull(batchAnnotatedOnlyField, "batchAnnotatedOnlyField is not null");
org.springframework.util.Assert.notNull(injectAnnotatedOnlyField, "injectAnnotatedOnlyField is not null");
org.springframework.util.Assert.isTrue("job1".equals(injectAnnotatedOnlyField.getJobName()), "injectAnnotatedOnlyField does not equal job1");
org.springframework.util.Assert.isNull(readerPropertyName3, "readerPropertyName3 is not null");
Properties jobProperties = injectAnnotatedOnlyField.getProperties();
org.springframework.util.Assert.isTrue(jobProperties.size() == 5);
org.springframework.util.Assert.isTrue(jobProperties.get("jobPropertyName1").equals("jobPropertyValue1"));
org.springframework.util.Assert.isTrue(jobProperties.get("jobPropertyName2").equals("jobPropertyValue2"));
org.springframework.util.Assert.isTrue(jobProperties.get("step2name").equals("step2"));
org.springframework.util.Assert.isTrue(jobProperties.get("filestem").equals("postings"));
org.springframework.util.Assert.isTrue(jobProperties.get("x").equals("xVal"));
org.springframework.util.Assert.isTrue(jobProperties.size() == 5, "jobProperties has the wrong number of values. Expected 5, got " + jobProperties.size());
org.springframework.util.Assert.isTrue(jobProperties.get("jobPropertyName1").equals("jobPropertyValue1"), "The value of jobPropertyName1 does not equal jobPropertyName1");
org.springframework.util.Assert.isTrue(jobProperties.get("jobPropertyName2").equals("jobPropertyValue2"), "The value of jobPropertyName2 does not equal jobPropertyName2");
org.springframework.util.Assert.isTrue(jobProperties.get("step2name").equals("step2"), "The value of step2name does note equal step2");
org.springframework.util.Assert.isTrue(jobProperties.get("filestem").equals("postings"), "The value of filestem does not equal postings");
org.springframework.util.Assert.isTrue(jobProperties.get("x").equals("xVal"), "The value of x does not equal xVal");
}
@Override
@@ -133,11 +133,11 @@ public class JobPropertyTests extends AbstractJsrTestCase {
@Override
public Object processItem(Object o) throws Exception {
org.springframework.util.Assert.isTrue("processorPropertyValue1".equals(processorPropertyName1));
org.springframework.util.Assert.isTrue("processorPropertyValue2".equals(processorPropertyName2));
org.springframework.util.Assert.isTrue("annotationNamedProcessorPropertyValue".equals(annotationNamedProperty));
org.springframework.util.Assert.isNull(notDefinedProperty);
org.springframework.util.Assert.isNull(notDefinedAnnotationNamedProperty);
org.springframework.util.Assert.isTrue("processorPropertyValue1".equals(processorPropertyName1), "The value of processorPropertyValue1 does not equal processorPropertyValue1");
org.springframework.util.Assert.isTrue("processorPropertyValue2".equals(processorPropertyName2), "The value of processorPropertyValue2 does not equal processorPropertyValue2");
org.springframework.util.Assert.isTrue("annotationNamedProcessorPropertyValue".equals(annotationNamedProperty), "The value of annotationNamedProcessorPropertyValue does not equal annotationNamedProcessorPropertyValue");
org.springframework.util.Assert.isNull(notDefinedProperty, "The notDefinedProperty is not null");
org.springframework.util.Assert.isNull(notDefinedAnnotationNamedProperty, "The notDefinedNamedProperty is not null");
return o;
}
@@ -152,11 +152,11 @@ public class JobPropertyTests extends AbstractJsrTestCase {
@Override
public void open(Serializable serializable) throws Exception {
org.springframework.util.Assert.isTrue("writerPropertyValue1".equals(writerPropertyName1));
org.springframework.util.Assert.isTrue("writerPropertyValue2".equals(writerPropertyName2));
org.springframework.util.Assert.isTrue("annotationNamedWriterPropertyValue".equals(annotationNamedProperty));
org.springframework.util.Assert.isNull(notDefinedProperty);
org.springframework.util.Assert.isNull(notDefinedAnnotationNamedProperty);
org.springframework.util.Assert.isTrue("writerPropertyValue1".equals(writerPropertyName1), "The value of writerPropertyValue1 does not equal writerPropertyValue1");
org.springframework.util.Assert.isTrue("writerPropertyValue2".equals(writerPropertyName2), "The value of writerPropertyValue2 does not equal writerPropertyValue2");
org.springframework.util.Assert.isTrue("annotationNamedWriterPropertyValue".equals(annotationNamedProperty), "The value of annotationNamedWriterPropertyValue does not equal annotationNamedWriterPropertyValue");
org.springframework.util.Assert.isNull(notDefinedProperty, "notDefinedProperty is not null");
org.springframework.util.Assert.isNull(notDefinedAnnotationNamedProperty, "notDefinedAnnotationNamedProperty is not null");
}
@Override
@@ -188,11 +188,11 @@ public class JobPropertyTests extends AbstractJsrTestCase {
@Override
public void beginCheckpoint() throws Exception {
org.springframework.util.Assert.isTrue("algorithmPropertyValue1".equals(algorithmPropertyName1));
org.springframework.util.Assert.isTrue("algorithmPropertyValue2".equals(algorithmPropertyName2));
org.springframework.util.Assert.isTrue("annotationNamedAlgorithmPropertyValue".equals(annotationNamedProperty));
org.springframework.util.Assert.isNull(notDefinedProperty);
org.springframework.util.Assert.isNull(notDefinedAnnotationNamedProperty);
org.springframework.util.Assert.isTrue("algorithmPropertyValue1".equals(algorithmPropertyName1), "The value of algorithmPropertyValue1 does not equal algorithmPropertyValue1");
org.springframework.util.Assert.isTrue("algorithmPropertyValue2".equals(algorithmPropertyName2), "The value of algorithmPropertyValue2 does not equal algorithmPropertyValue2");
org.springframework.util.Assert.isTrue("annotationNamedAlgorithmPropertyValue".equals(annotationNamedProperty), "The annotationNamedAlgorithmPropertyValue does not equal annotationNamedAlgorithmPropertyValue");
org.springframework.util.Assert.isNull(notDefinedProperty, "notDefinedProperty is not null");
org.springframework.util.Assert.isNull(notDefinedAnnotationNamedProperty, "notDefinedAnnotationNamedProperty is not null");
}
@Override
@@ -214,11 +214,11 @@ public class JobPropertyTests extends AbstractJsrTestCase {
@Override
public String decide(javax.batch.runtime.StepExecution[] executions) throws Exception {
org.springframework.util.Assert.isTrue("deciderPropertyValue1".equals(deciderPropertyName1));
org.springframework.util.Assert.isTrue("deciderPropertyValue2".equals(deciderPropertyName2));
org.springframework.util.Assert.isTrue("annotationNamedDeciderPropertyValue".equals(annotationNamedProperty));
org.springframework.util.Assert.isNull(notDefinedProperty);
org.springframework.util.Assert.isNull(notDefinedAnnotationNamedProperty);
org.springframework.util.Assert.isTrue("deciderPropertyValue1".equals(deciderPropertyName1), "The value of deciderPropertyValue1 does not equal deciderPropertyValue1");
org.springframework.util.Assert.isTrue("deciderPropertyValue2".equals(deciderPropertyName2), "The value of deciderPropertyValue2 does not equal deciderPropertyValue2");
org.springframework.util.Assert.isTrue("annotationNamedDeciderPropertyValue".equals(annotationNamedProperty), "The value of annotationNamedDeciderPropertyValue does not equal annotationNamedDeciderPropertyValue");
org.springframework.util.Assert.isNull(notDefinedProperty, "notDefinedProperty is not null");
org.springframework.util.Assert.isNull(notDefinedAnnotationNamedProperty, "notDefinedAnnotationNamedProperty is not null");
return "step2";
}
@@ -233,11 +233,11 @@ public class JobPropertyTests extends AbstractJsrTestCase {
@Override
public void beforeStep() throws Exception {
org.springframework.util.Assert.isTrue("stepListenerPropertyValue1".equals(stepListenerPropertyName1));
org.springframework.util.Assert.isTrue("stepListenerPropertyValue2".equals(stepListenerPropertyName2));
org.springframework.util.Assert.isTrue("annotationNamedStepListenerPropertyValue".equals(annotationNamedProperty));
org.springframework.util.Assert.isNull(notDefinedProperty);
org.springframework.util.Assert.isNull(notDefinedAnnotationNamedProperty);
org.springframework.util.Assert.isTrue("stepListenerPropertyValue1".equals(stepListenerPropertyName1), "The value of stepListenerPropertyValue1 does not equal stepListenerPropertyValue1");
org.springframework.util.Assert.isTrue("stepListenerPropertyValue2".equals(stepListenerPropertyName2), "The value of stepListenerPropertyValue2 does not equal stepListenerPropertyValue2");
org.springframework.util.Assert.isTrue("annotationNamedStepListenerPropertyValue".equals(annotationNamedProperty), "The value of annotationNamedStepListenerPropertyValue does note equal annotationNamedStepListenerPropertyValue");
org.springframework.util.Assert.isNull(notDefinedProperty, "notDefinedProperty is not null");
org.springframework.util.Assert.isNull(notDefinedAnnotationNamedProperty, "notDefinedAnnotationNamedProperty is not null");
}
@Override
@@ -258,22 +258,22 @@ public class JobPropertyTests extends AbstractJsrTestCase {
@Override
public String process() throws Exception {
org.springframework.util.Assert.notNull(stepContext);
org.springframework.util.Assert.isNull(stepContext.getProperties().get("step1PropertyName1"));
org.springframework.util.Assert.isNull(stepContext.getProperties().get("step1PropertyName2"));
org.springframework.util.Assert.isTrue(stepContext.getProperties().get("step2PropertyName1").equals("step2PropertyValue1"));
org.springframework.util.Assert.isTrue(stepContext.getProperties().get("step2PropertyName2").equals("step2PropertyValue2"));
org.springframework.util.Assert.isTrue(stepContext.getProperties().get("jobPropertyName1") == null);
org.springframework.util.Assert.isTrue(stepContext.getProperties().get("jobPropertyName2") == null);
org.springframework.util.Assert.notNull(stepContext, "StepContext is not null");
org.springframework.util.Assert.isNull(stepContext.getProperties().get("step1PropertyName1"), "The value of step1PropertyName1 is not null");
org.springframework.util.Assert.isNull(stepContext.getProperties().get("step1PropertyName2"), "The value of step1PropertyName2 is not null");
org.springframework.util.Assert.isTrue(stepContext.getProperties().get("step2PropertyName1").equals("step2PropertyValue1"), "The value of step2PropertyName1 does not equal step2PropertyName1");
org.springframework.util.Assert.isTrue(stepContext.getProperties().get("step2PropertyName2").equals("step2PropertyValue2"), "The value of step2PropertyName2 does not equal step2PropertyName2");
org.springframework.util.Assert.isTrue(stepContext.getProperties().get("jobPropertyName1") == null, "jobPropertyName1 is not null");
org.springframework.util.Assert.isTrue(stepContext.getProperties().get("jobPropertyName2") == null, "jobPropertyName2 is not null");
org.springframework.util.Assert.isTrue("batchletPropertyValue1".equals(batchletPropertyName1));
org.springframework.util.Assert.isTrue("batchletPropertyValue2".equals(batchletPropertyName2));
org.springframework.util.Assert.isTrue("annotationNamedBatchletPropertyValue".equals(annotationNamedProperty));
org.springframework.util.Assert.isTrue("postings.txt".equals(infile));
org.springframework.util.Assert.isTrue("xVal".equals(y));
org.springframework.util.Assert.isNull(notDefinedProperty);
org.springframework.util.Assert.isNull(notDefinedAnnotationNamedProperty);
org.springframework.util.Assert.isNull(x);
org.springframework.util.Assert.isTrue("batchletPropertyValue1".equals(batchletPropertyName1), "batchletPropertyValue1 does not equal batchletPropertyValue1");
org.springframework.util.Assert.isTrue("batchletPropertyValue2".equals(batchletPropertyName2), "batchletPropertyValue2 does not equal batchletPropertyValue2");
org.springframework.util.Assert.isTrue("annotationNamedBatchletPropertyValue".equals(annotationNamedProperty), "annotationNamedBatchletPropertyValue does not equal annotationNamedBatchletPropertyValue");
org.springframework.util.Assert.isTrue("postings.txt".equals(infile), "infile does not equal postings.txt");
org.springframework.util.Assert.isTrue("xVal".equals(y), "y does not equal xVal");
org.springframework.util.Assert.isNull(notDefinedProperty, "notDefinedProperty is not null");
org.springframework.util.Assert.isNull(notDefinedAnnotationNamedProperty, "notDefinedAnnotationNamedProperty is not null");
org.springframework.util.Assert.isNull(x, "x is not null");
return null;
}
@@ -290,7 +290,7 @@ public class JobPropertyTests extends AbstractJsrTestCase {
@Override
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
org.springframework.util.Assert.isTrue("p1val".equals(p1));
org.springframework.util.Assert.isTrue("p1val".equals(p1), "Expected p1val, got " + p1);
return RepeatStatus.FINISHED;
}

View File

@@ -15,11 +15,16 @@
*/
package org.springframework.batch.core.jsr.configuration.xml;
import org.junit.Before;
import org.junit.Test;
import org.springframework.batch.core.jsr.AbstractJsrTestCase;
import org.springframework.util.Assert;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Properties;
import java.util.Set;
import java.util.Vector;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.batch.api.BatchProperty;
import javax.batch.api.Batchlet;
import javax.batch.api.chunk.AbstractItemReader;
@@ -31,16 +36,12 @@ import javax.batch.runtime.JobExecution;
import javax.batch.runtime.context.JobContext;
import javax.batch.runtime.context.StepContext;
import javax.inject.Inject;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Properties;
import java.util.Set;
import java.util.Vector;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.junit.Before;
import org.junit.Test;
import org.springframework.batch.core.jsr.AbstractJsrTestCase;
import org.springframework.util.Assert;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -221,14 +222,14 @@ public class PartitionParserTests extends AbstractJsrTestCase {
public void analyzeCollectorData(Serializable data) throws Exception {
name = artifactName;
Assert.isTrue(data.equals("c"));
Assert.isTrue(data.equals("c"), "Expected c but was " + data);
jobContext.setExitStatus(jobContext.getExitStatus() + data + "a");
}
@Override
public void analyzeStatus(BatchStatus batchStatus, String exitStatus)
throws Exception {
Assert.isTrue(batchStatus.equals(BatchStatus.COMPLETED));
Assert.isTrue(batchStatus.equals(BatchStatus.COMPLETED), String.format("expected %s but received %s", BatchStatus.COMPLETED, batchStatus));
jobContext.setExitStatus(jobContext.getExitStatus() + "AS");
}
}

View File

@@ -124,7 +124,7 @@ public class RetryListenerTests {
String currentItem = (String) item;
Assert.isTrue("three".equals(currentItem));
Assert.isTrue("three".equals(currentItem), "currentItem was expected to be three but was not " + currentItem);
Assert.isInstanceOf(IllegalArgumentException.class, ex);
}
}

View File

@@ -37,8 +37,9 @@ public class ThreadLocalClassloaderBeanPostProcessorTestsBatchlet implements Bat
@Override
public String process() throws Exception {
Assert.isTrue("someParameter".equals(jobParam1), jobParam1 + " does not equal someParamter");
Assert.isTrue("threadLocalClassloaderBeanPostProcessorTestsJob".equals(jobContext.getJobName()));
Assert.isTrue("step1".equals(stepContext.getStepName()));
Assert.isTrue("threadLocalClassloaderBeanPostProcessorTestsJob".equals(jobContext.getJobName()),
"jobName does not equal threadLocalClassloaderBeanPostProcessorTestsJob");
Assert.isTrue("step1".equals(stepContext.getStepName()), "stepName does not equal step1");
return null;
}

View File

@@ -140,8 +140,8 @@ public class DecisionStepTests extends AbstractJsrTestCase {
@Override
public String decide(StepExecution[] executions) throws Exception {
Assert.isTrue(executions.length == 1);
Assert.isTrue(executions[0].getStepName().equals("step1"));
Assert.isTrue(executions.length == 1, "Invalid array length");
Assert.isTrue(executions[0].getStepName().equals("step1"), "Incorrect step name");
if(runs == 0) {
runs++;

View File

@@ -15,15 +15,16 @@
*/
package org.springframework.batch.core.listener;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import org.junit.Test;
import org.springframework.batch.core.ExitStatus;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.StepExecution;
import org.springframework.util.Assert;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
/**
* Tests for {@link ExecutionContextPromotionListener}.
*/
@@ -57,8 +58,8 @@ public class ExecutionContextPromotionListenerTests {
StepExecution stepExecution = jobExecution.createStepExecution("step1");
stepExecution.setExitStatus(ExitStatus.COMPLETED);
Assert.state(jobExecution.getExecutionContext().isEmpty());
Assert.state(stepExecution.getExecutionContext().isEmpty());
Assert.state(jobExecution.getExecutionContext().isEmpty(), "Job ExecutionContext is not empty");
Assert.state(stepExecution.getExecutionContext().isEmpty(), "Step ExecutionContext is not empty");
stepExecution.getExecutionContext().putString(key, value);
stepExecution.getExecutionContext().putString(key2, value2);
@@ -87,8 +88,8 @@ public class ExecutionContextPromotionListenerTests {
StepExecution stepExecution = jobExecution.createStepExecution("step1");
stepExecution.setExitStatus(new ExitStatus(status));
Assert.state(jobExecution.getExecutionContext().isEmpty());
Assert.state(stepExecution.getExecutionContext().isEmpty());
Assert.state(jobExecution.getExecutionContext().isEmpty(), "Job ExecutionContext is not empty");
Assert.state(stepExecution.getExecutionContext().isEmpty(), "Step ExecutionContext is not empty");
stepExecution.getExecutionContext().putString(key, value);
stepExecution.getExecutionContext().putString(key2, value2);
@@ -117,8 +118,8 @@ public class ExecutionContextPromotionListenerTests {
StepExecution stepExecution = jobExecution.createStepExecution("step1");
stepExecution.setExitStatus(new ExitStatus(status2));
Assert.state(jobExecution.getExecutionContext().isEmpty());
Assert.state(stepExecution.getExecutionContext().isEmpty());
Assert.state(jobExecution.getExecutionContext().isEmpty(), "Job ExecutionContext is not empty");
Assert.state(stepExecution.getExecutionContext().isEmpty(), "Step ExecutionContext is not empty");
stepExecution.getExecutionContext().putString(key, value);
stepExecution.getExecutionContext().putString(key2, value2);
@@ -147,8 +148,8 @@ public class ExecutionContextPromotionListenerTests {
StepExecution stepExecution = jobExecution.createStepExecution("step1");
stepExecution.setExitStatus(new ExitStatus(status));
Assert.state(jobExecution.getExecutionContext().isEmpty());
Assert.state(stepExecution.getExecutionContext().isEmpty());
Assert.state(jobExecution.getExecutionContext().isEmpty(), "Job ExecutionContext is not empty");
Assert.state(stepExecution.getExecutionContext().isEmpty(), "Step ExecutionContext is not empty");
stepExecution.getExecutionContext().putString(key, value);
stepExecution.getExecutionContext().putString(key2, value2);
@@ -176,8 +177,8 @@ public class ExecutionContextPromotionListenerTests {
StepExecution stepExecution = jobExecution.createStepExecution("step1");
stepExecution.setExitStatus(ExitStatus.COMPLETED);
Assert.state(jobExecution.getExecutionContext().isEmpty());
Assert.state(stepExecution.getExecutionContext().isEmpty());
Assert.state(jobExecution.getExecutionContext().isEmpty(), "Job ExecutionContext is not empty");
Assert.state(stepExecution.getExecutionContext().isEmpty(), "Step ExecutionContext is not empty");
stepExecution.getExecutionContext().putString(key, value);
@@ -203,8 +204,8 @@ public class ExecutionContextPromotionListenerTests {
StepExecution stepExecution = jobExecution.createStepExecution("step1");
stepExecution.setExitStatus(ExitStatus.COMPLETED);
Assert.state(jobExecution.getExecutionContext().isEmpty());
Assert.state(stepExecution.getExecutionContext().isEmpty());
Assert.state(jobExecution.getExecutionContext().isEmpty(), "Job ExecutionContext is not empty");
Assert.state(stepExecution.getExecutionContext().isEmpty(), "Step ExecutionContext is not empty");
jobExecution.getExecutionContext().putString(key, value);
@@ -231,8 +232,8 @@ public class ExecutionContextPromotionListenerTests {
StepExecution stepExecution = jobExecution.createStepExecution("step1");
stepExecution.setExitStatus(ExitStatus.COMPLETED);
Assert.state(jobExecution.getExecutionContext().isEmpty());
Assert.state(stepExecution.getExecutionContext().isEmpty());
Assert.state(jobExecution.getExecutionContext().isEmpty(), "Job ExecutionContext is not empty");
Assert.state(stepExecution.getExecutionContext().isEmpty(), "Step ExecutionContext is not empty");
stepExecution.getExecutionContext().putString(key, value);

View File

@@ -15,23 +15,17 @@
*/
package org.springframework.batch.core.listener;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.springframework.batch.core.listener.StepListenerMetaData.AFTER_STEP;
import static org.springframework.batch.core.listener.StepListenerMetaData.AFTER_WRITE;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.sql.DataSource;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.junit.Before;
import org.junit.Test;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.batch.core.ChunkListener;
import org.springframework.batch.core.ExitStatus;
@@ -63,6 +57,12 @@ import org.springframework.beans.factory.InitializingBean;
import org.springframework.core.Ordered;
import org.springframework.util.Assert;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.springframework.batch.core.listener.StepListenerMetaData.AFTER_STEP;
import static org.springframework.batch.core.listener.StepListenerMetaData.AFTER_WRITE;
/**
* @author Lucas Ward
*
@@ -380,7 +380,7 @@ public class StepListenerFactoryBeanTests {
@Override
@AfterStep
public ExitStatus afterStep(StepExecution stepExecution) {
Assert.notNull(stepExecution);
Assert.notNull(stepExecution, "A stepExecution is required");
callcount++;
return null;
}
@@ -399,7 +399,7 @@ public class StepListenerFactoryBeanTests {
@Override
public ExitStatus afterStep(StepExecution stepExecution) {
Assert.notNull(stepExecution);
Assert.notNull(stepExecution, "A stepExecution is required");
callcount++;
return null;
}
@@ -489,7 +489,7 @@ public class StepListenerFactoryBeanTests {
@AfterRead
public void afterReadMethod(Object item) {
Assert.notNull(item);
Assert.notNull(item, "An item is required");
afterReadCalled = true;
}

View File

@@ -15,11 +15,6 @@
*/
package org.springframework.batch.core.repository.dao;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
@@ -28,6 +23,7 @@ import java.util.Set;
import org.junit.Before;
import org.junit.Test;
import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.ExitStatus;
import org.springframework.batch.core.JobExecution;
@@ -36,7 +32,12 @@ import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.StepExecution;
import org.springframework.dao.OptimisticLockingFailureException;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
public abstract class AbstractJobExecutionDaoTests {
@@ -307,13 +308,13 @@ public abstract class AbstractJobExecutionDaoTests {
dao.saveJobExecution(exec1);
JobExecution exec2 = new JobExecution(jobInstance, jobParameters);
Assert.state(exec1.getId() != null);
assertTrue(exec1.getId() != null);
exec2.setId(exec1.getId());
exec2.setStatus(BatchStatus.STARTED);
exec2.setVersion(7);
Assert.state(exec1.getVersion() != exec2.getVersion());
Assert.state(exec1.getStatus() != exec2.getStatus());
assertTrue(exec1.getVersion() != exec2.getVersion());
assertTrue(exec1.getStatus() != exec2.getStatus());
dao.synchronizeStatus(exec2);
@@ -334,13 +335,13 @@ public abstract class AbstractJobExecutionDaoTests {
dao.saveJobExecution(exec1);
JobExecution exec2 = new JobExecution(jobInstance, jobParameters);
Assert.state(exec1.getId() != null);
assertTrue(exec1.getId() != null);
exec2.setId(exec1.getId());
exec2.setStatus(BatchStatus.UNKNOWN);
exec2.setVersion(7);
Assert.state(exec1.getVersion() != exec2.getVersion());
Assert.state(exec1.getStatus().isLessThan(exec2.getStatus()));
assertTrue(exec1.getVersion() != exec2.getVersion());
assertTrue(exec1.getStatus().isLessThan(exec2.getStatus()));
dao.synchronizeStatus(exec2);

View File

@@ -15,10 +15,6 @@
*/
package org.springframework.batch.core.step.item;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -30,6 +26,10 @@ import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
/**
* @author Dave Syer
*
@@ -81,8 +81,7 @@ public class AlmostStatefulRetryChunkTests {
}
/**
* @param chunk
* @throws Exception
* @param chunk Chunk to retry
*/
private void statefulRetry(Chunk<String> chunk) throws Exception {
if (retryAttempts <= retryLimit) {
@@ -113,8 +112,7 @@ public class AlmostStatefulRetryChunkTests {
}
/**
* @param chunk
* @throws Exception
* @param chunk Chunk to recover
*/
private void recover(Chunk<String> chunk) throws Exception {
for (Chunk<String>.ChunkIterator iterator = chunk.iterator(); iterator.hasNext();) {
@@ -129,8 +127,7 @@ public class AlmostStatefulRetryChunkTests {
}
/**
* @param items
* @throws Exception
* @param items items to write
*/
private void doWrite(List<String> items) throws Exception {
if (items.contains("fail")) {

View File

@@ -224,7 +224,7 @@ public class SystemCommandTaskletIntegrationTests {
@Test
public void testWorkingDirectory() throws Exception {
File notExistingFile = new File("not-existing-path");
Assert.state(!notExistingFile.exists());
Assert.state(!notExistingFile.exists(), "not-existing-path does actually exist");
try {
tasklet.setWorkingDirectory(notExistingFile.getCanonicalPath());
@@ -235,8 +235,8 @@ public class SystemCommandTaskletIntegrationTests {
}
File notDirectory = File.createTempFile(this.getClass().getName(), null);
Assert.state(notDirectory.exists());
Assert.state(!notDirectory.isDirectory());
Assert.state(notDirectory.exists(), "The file does not exist");
Assert.state(!notDirectory.isDirectory(), "The file is actually a directory");
try {
tasklet.setWorkingDirectory(notDirectory.getCanonicalPath());
@@ -247,8 +247,8 @@ public class SystemCommandTaskletIntegrationTests {
}
File directory = notDirectory.getParentFile();
Assert.state(directory.exists());
Assert.state(directory.isDirectory());
Assert.state(directory.exists(), "The directory does not exist");
Assert.state(directory.isDirectory(), "The directory is not a directory");
// no error expected now
tasklet.setWorkingDirectory(directory.getCanonicalPath());

View File

@@ -16,9 +16,14 @@
package test.jdbc.datasource;
import java.io.IOException;
import java.util.List;
import javax.sql.DataSource;
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.BeanInitializationException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -33,10 +38,6 @@ import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
import javax.sql.DataSource;
import java.io.IOException;
import java.util.List;
/**
* Wrapper for a {@link DataSource} that can run scripts on start up and shut
* down. Us as a bean definition <br><br>
@@ -75,7 +76,7 @@ public class DataSourceInitializer implements InitializingBean {
@Override
public void afterPropertiesSet() throws Exception {
Assert.notNull(dataSource);
Assert.notNull(dataSource, "A DataSource is required");
initialize();
}