Updated tests to remove SQL Bad Grammar warnings
Also replacing the last of the SpringJunit4ClassRunner with SpringRunner Other cleanup resolves #482
This commit is contained in:
committed by
Michael Minella
parent
ab58cdd9df
commit
fa3e4e55c6
@@ -43,13 +43,6 @@ public class TaskBatchProperties {
|
||||
*/
|
||||
private int commandLineRunnerOrder = 0;
|
||||
|
||||
/**
|
||||
* Maximum wait time in milliseconds that Spring Cloud Task will wait for tasks to complete
|
||||
* when spring.cloud.task.batch.failOnJobFailure is set to true. Defaults
|
||||
* to 0. 0 indicates no wait time is enforced.
|
||||
*/
|
||||
private long failOnJobFailurewaitTime = 0;
|
||||
|
||||
/**
|
||||
* Fixed delay in milliseconds that Spring Cloud Task will wait when checking if
|
||||
* {@link org.springframework.batch.core.JobExecution}s have completed,
|
||||
@@ -74,14 +67,6 @@ public class TaskBatchProperties {
|
||||
this.commandLineRunnerOrder = commandLineRunnerOrder;
|
||||
}
|
||||
|
||||
public long getFailOnJobFailurewaitTime() {
|
||||
return failOnJobFailurewaitTime;
|
||||
}
|
||||
|
||||
public void setFailOnJobFailurewaitTime(long failOnJobFailurewaitTime) {
|
||||
this.failOnJobFailurewaitTime = failOnJobFailurewaitTime;
|
||||
}
|
||||
|
||||
public long getFailOnJobFailurePollInterval() {
|
||||
return failOnJobFailurePollInterval;
|
||||
}
|
||||
|
||||
@@ -183,12 +183,6 @@ public class TaskJobLauncherCommandLineRunner extends JobLauncherCommandLineRunn
|
||||
if (repeatStatus.equals(RepeatStatus.FINISHED) && failedJobExecutions.size() > 0) {
|
||||
throwJobFailedException(failedJobExecutions);
|
||||
}
|
||||
if (repeatStatus.isContinuable() && taskBatchProperties.getFailOnJobFailurewaitTime() != 0
|
||||
&& (new Date()).getTime() - startDate.getTime() > taskBatchProperties.getFailOnJobFailurewaitTime()) {
|
||||
throw new IllegalStateException("Not all jobs were completed " +
|
||||
"within the time specified by spring.cloud.task.batch." +
|
||||
"failOnJobFailurewaitTime.");
|
||||
}
|
||||
return repeatStatus;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -45,8 +45,8 @@ import org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration;
|
||||
import org.springframework.cloud.task.batch.configuration.TaskBatchAutoConfiguration;
|
||||
import org.springframework.cloud.task.batch.configuration.TaskJobLauncherAutoConfiguration;
|
||||
import org.springframework.cloud.task.batch.configuration.TaskBatchTest;
|
||||
import org.springframework.cloud.task.batch.configuration.TaskJobLauncherAutoConfiguration;
|
||||
import org.springframework.cloud.task.configuration.EnableTask;
|
||||
import org.springframework.cloud.task.configuration.SimpleTaskAutoConfiguration;
|
||||
import org.springframework.cloud.task.configuration.SingleTaskConfiguration;
|
||||
@@ -74,7 +74,7 @@ public class TaskJobLauncherCommandLineRunnerTests {
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
if (this.applicationContext != null) {
|
||||
if (this.applicationContext != null && this.applicationContext.isActive()) {
|
||||
this.applicationContext.close();
|
||||
}
|
||||
}
|
||||
@@ -108,19 +108,6 @@ public class TaskJobLauncherCommandLineRunnerTests {
|
||||
enabledArgs);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testTaskJobLauncherCLRSuccessWithLongWaitTaskExecutor() {
|
||||
String[] enabledArgs = new String[] {
|
||||
"--spring.cloud.task.batch.failOnJobFailure=true",
|
||||
"--spring.cloud.task.batch.failOnJobFailurePollInterval=500",
|
||||
"--spring.cloud.task.batch.failOnJobFailurewaitTime=1000"
|
||||
};
|
||||
validateForFail("Not all jobs were completed within the time specified by spring.cloud.task.batch.failOnJobFailurewaitTime.",
|
||||
TaskJobLauncherCommandLineRunnerTests.JobWithFailureTaskExecutorLongWaitConfiguration.class,
|
||||
enabledArgs);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTaskJobLauncherPickOneJob() {
|
||||
String[] enabledArgs = new String[] {
|
||||
@@ -259,60 +246,6 @@ public class TaskJobLauncherCommandLineRunnerTests {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EnableBatchProcessing
|
||||
@ImportAutoConfiguration({
|
||||
PropertyPlaceholderAutoConfiguration.class,
|
||||
BatchAutoConfiguration.class,
|
||||
TaskBatchAutoConfiguration.class,
|
||||
TaskJobLauncherAutoConfiguration.class,
|
||||
SingleTaskConfiguration.class,
|
||||
SimpleTaskAutoConfiguration.class })
|
||||
@Import(EmbeddedDataSourceConfiguration.class)
|
||||
public static class JobWithFailureTaskExecutorLongWaitConfiguration {
|
||||
|
||||
@Autowired
|
||||
private JobBuilderFactory jobBuilderFactory;
|
||||
|
||||
@Autowired
|
||||
private StepBuilderFactory stepBuilderFactory;
|
||||
@Bean
|
||||
public BatchConfigurer batchConfigurer(DataSource dataSource) {
|
||||
return new TestBatchConfigurer(dataSource);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Job jobShortRunner() {
|
||||
return jobBuilderFactory.get("jobSucceedShort")
|
||||
.start(stepBuilderFactory.get("step1SucceedSort").tasklet(new Tasklet() {
|
||||
@Override
|
||||
public RepeatStatus execute(StepContribution contribution,
|
||||
ChunkContext chunkContext)
|
||||
throws Exception {
|
||||
System.out.println("Executed Short Runner");
|
||||
return RepeatStatus.FINISHED;
|
||||
}
|
||||
}).build())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Job jobLongRunner() {
|
||||
return jobBuilderFactory.get("jobSucceedLong")
|
||||
.start(stepBuilderFactory.get("step1SucceedLong").tasklet(new Tasklet() {
|
||||
@Override
|
||||
public RepeatStatus execute(StepContribution contribution,
|
||||
ChunkContext chunkContext)
|
||||
throws Exception {
|
||||
System.out.println("Executed Long Runner");
|
||||
Thread.sleep(5000);
|
||||
return RepeatStatus.FINISHED;
|
||||
}
|
||||
}).build())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
private static class TestBatchConfigurer extends DefaultBatchConfigurer{
|
||||
public TestBatchConfigurer(DataSource dataSource) {
|
||||
super(dataSource);
|
||||
|
||||
@@ -48,7 +48,7 @@ public class PrefixTests {
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
if (this.applicationContext != null) {
|
||||
if (this.applicationContext != null && this.applicationContext.isActive()) {
|
||||
this.applicationContext.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ public class TaskBatchExecutionListenerTests {
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
if(this.applicationContext != null) {
|
||||
if(this.applicationContext != null && this.applicationContext.isActive()) {
|
||||
this.applicationContext.close();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user