SingleStepBatch Job can be used with spring-cloud-task-stream
resolves #799 Added config to reduce testcontainer logging Updated to use task starter
This commit is contained in:
committed by
Glenn Renfro
parent
a785fb00b1
commit
fb5d4b6573
@@ -1,4 +1,4 @@
|
||||
= Spring Cloud Task image:https://build.spring.io/plugins/servlet/wittified/build-status/SCT-STASK[Build Status, link=https://build.spring.io/browse/SCT-STASK]
|
||||
= Spring Cloud Task
|
||||
|
||||
Is a project centered around the idea of processing on demand. A user is able to develop
|
||||
a “task” that can be deployed, executed and removed on demand, yet the result of the
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
<artifactId>spring-cloud-starter-single-step-batch-job</artifactId>
|
||||
|
||||
<properties>
|
||||
<test.containers.version>1.16.0</test.containers.version>
|
||||
<test.rabbit.containers.version>1.16.0</test.rabbit.containers.version>
|
||||
<test.containers.version>1.16.1</test.containers.version>
|
||||
<test.rabbit.containers.version>1.16.1</test.rabbit.containers.version>
|
||||
<test.ducttape.version>1.0.8</test.ducttape.version>
|
||||
</properties>
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
<configuration>
|
||||
<include resource="org/springframework/boot/logging/logback/base.xml"/>
|
||||
<logger name="org.apache.http" level="WARN"/>
|
||||
<logger name="com.github.dockerjava" level="WARN"/>
|
||||
<logger name="org.zeroturnaround.exec" level="WARN"/>
|
||||
</configuration>
|
||||
@@ -13,8 +13,8 @@
|
||||
<artifactId>spring-cloud-task-integration-tests</artifactId>
|
||||
|
||||
<properties>
|
||||
<test.containers.version>1.16.0</test.containers.version>
|
||||
<test.rabbit.containers.version>1.16.0</test.rabbit.containers.version>
|
||||
<test.containers.version>1.16.1</test.containers.version>
|
||||
<test.rabbit.containers.version>1.16.1</test.rabbit.containers.version>
|
||||
<test.ducttape.version>1.0.8</test.ducttape.version>
|
||||
</properties>
|
||||
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<test.containers.version>1.16.0</test.containers.version>
|
||||
<test.rabbit.containers.version>1.16.0</test.rabbit.containers.version>
|
||||
<test.containers.version>1.16.1</test.containers.version>
|
||||
<test.rabbit.containers.version>1.16.1</test.rabbit.containers.version>
|
||||
<test.ducttape.version>1.0.8</test.ducttape.version>
|
||||
<spring.cloud.stream>3.2.0-SNAPSHOT</spring.cloud.stream>
|
||||
</properties>
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
<configuration>
|
||||
<include resource="org/springframework/boot/logging/logback/base.xml"/>
|
||||
<logger name="org.apache.http" level="WARN"/>
|
||||
<logger name="com.github.dockerjava" level="WARN"/>
|
||||
<logger name="org.zeroturnaround.exec" level="WARN"/>
|
||||
</configuration>
|
||||
@@ -41,7 +41,8 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-task-core</artifactId>
|
||||
<artifactId>spring-cloud-starter-task</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2019 the original author or authors.
|
||||
* Copyright 2016-2021 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.
|
||||
@@ -28,6 +28,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
@@ -182,6 +183,7 @@ public class BatchEventAutoConfiguration {
|
||||
@EnableBinding(BatchEventsChannels.class)
|
||||
@EnableConfigurationProperties(TaskEventProperties.class)
|
||||
@ConditionalOnMissingBean(name = JOB_EXECUTION_EVENTS_LISTENER)
|
||||
@ConditionalOnExpression("T(org.springframework.util.StringUtils).isEmpty('${spring.batch.job.jobName:}')")
|
||||
public static class JobExecutionListenerConfiguration {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2019 the original author or authors.
|
||||
* Copyright 2016-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,6 +20,7 @@ import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.cloud.stream.annotation.EnableBinding;
|
||||
import org.springframework.cloud.stream.annotation.Output;
|
||||
@@ -33,10 +34,12 @@ import org.springframework.messaging.MessageChannel;
|
||||
|
||||
/**
|
||||
* @author Michael Minella
|
||||
* @author Glenn Renfro
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnClass(EnableBinding.class)
|
||||
@ConditionalOnBean(TaskLifecycleListener.class)
|
||||
@ConditionalOnExpression("T(org.springframework.util.StringUtils).isEmpty('${spring.batch.job.jobName:}')")
|
||||
// @checkstyle:off
|
||||
@ConditionalOnProperty(prefix = "spring.cloud.task.events", name = "enabled",
|
||||
havingValue = "true", matchIfMissing = true)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2019 the original author or authors.
|
||||
* Copyright 2016-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,6 +23,7 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -339,6 +340,27 @@ public class JobExecutionEventTests {
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void singleStepBatchJobSkip() {
|
||||
ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(
|
||||
EventJobExecutionConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class,
|
||||
TestSupportBinderAutoConfiguration.class,
|
||||
SimpleTaskAutoConfiguration.class, SingleTaskConfiguration.class))
|
||||
.withUserConfiguration(
|
||||
BatchEventAutoConfiguration.JobExecutionListenerConfiguration.class)
|
||||
.withPropertyValues("--spring.cloud.task.closecontext_enabled=false",
|
||||
"--spring.main.web-environment=false", "spring.batch.job.jobName=FOO");
|
||||
applicationContextRunner.run((context) -> {
|
||||
NoSuchBeanDefinitionException exception = Assertions.assertThrows(NoSuchBeanDefinitionException.class, () -> {
|
||||
context.getBean("jobExecutionEventsListener");
|
||||
});
|
||||
assertThat(exception.getMessage()).contains(
|
||||
String.format("No bean named 'jobExecutionEventsListener' available"));
|
||||
});
|
||||
}
|
||||
|
||||
private void testDisabledConfiguration(String property, String disabledListener) {
|
||||
String disabledPropertyArg = (property != null) ? "--" + property + "=false" : "";
|
||||
ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
|
||||
|
||||
Reference in New Issue
Block a user