JAVA-11240 Moved spring-cloud to spring-cloud-modules
This commit is contained in:
+16
@@ -0,0 +1,16 @@
|
||||
package com.baeldung.SpringCloudTaskFinal;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.task.launcher.annotation.EnableTaskLauncher;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableTaskLauncher
|
||||
public class SpringCloudTaskSinkApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(
|
||||
SpringCloudTaskSinkApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
maven.remoteRepositories.springRepo.url=https://repo.spring.io/libs-snapshot
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
|
||||
</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
</configuration>
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
package com.baeldung.SpringCloudTaskFinal;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.cloud.deployer.spi.core.AppDeploymentRequest;
|
||||
import org.springframework.cloud.deployer.spi.task.TaskLauncher;
|
||||
import org.springframework.cloud.stream.messaging.Sink;
|
||||
import org.springframework.cloud.task.launcher.TaskLaunchRequest;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(
|
||||
classes = SpringCloudTaskSinkApplication.class)
|
||||
public class SpringCloudTaskSinkApplicationIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
ApplicationContext context;
|
||||
|
||||
@Autowired
|
||||
private Sink sink;
|
||||
|
||||
@Test
|
||||
public void testTaskLaunch() throws IOException {
|
||||
|
||||
TaskLauncher taskLauncher =
|
||||
context.getBean(TaskLauncher.class);
|
||||
|
||||
Map<String, String> prop = new HashMap<String, String>();
|
||||
prop.put("server.port", "0");
|
||||
TaskLaunchRequest request = new TaskLaunchRequest(
|
||||
"maven://org.springframework.cloud.task.app:"
|
||||
+ "timestamp-task:jar:1.0.1.RELEASE", null,
|
||||
prop,
|
||||
null, null);
|
||||
GenericMessage<TaskLaunchRequest> message = new GenericMessage<TaskLaunchRequest>(
|
||||
request);
|
||||
this.sink.input().send(message);
|
||||
|
||||
ArgumentCaptor<AppDeploymentRequest> deploymentRequest = ArgumentCaptor
|
||||
.forClass(AppDeploymentRequest.class);
|
||||
|
||||
verify(taskLauncher).launch(
|
||||
deploymentRequest.capture());
|
||||
|
||||
AppDeploymentRequest actualRequest = deploymentRequest
|
||||
.getValue();
|
||||
|
||||
// Verifying the co-ordinate of launched Task here.
|
||||
assertTrue(actualRequest.getCommandlineArguments()
|
||||
.isEmpty());
|
||||
assertEquals("0", actualRequest.getDefinition()
|
||||
.getProperties().get("server.port"));
|
||||
assertTrue(actualRequest
|
||||
.getResource()
|
||||
.toString()
|
||||
.contains(
|
||||
"org.springframework.cloud.task.app:timestamp-task:jar:1.0.1.RELEASE"));
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package com.baeldung.SpringCloudTaskFinal;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import org.springframework.cloud.deployer.spi.task.TaskLauncher;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
|
||||
@Configuration
|
||||
public class TaskSinkConfiguration {
|
||||
|
||||
@Bean
|
||||
public TaskLauncher taskLauncher() {
|
||||
return mock(TaskLauncher.class);
|
||||
}
|
||||
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.baeldung;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.baeldung.SpringCloudTaskFinal.SpringCloudTaskSinkApplication;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = SpringCloudTaskSinkApplication.class)
|
||||
public class SpringContextTest {
|
||||
|
||||
@Test
|
||||
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user