Upgraded versions and fixed test

This commit upgrades the versions to the latest and greatest as well as
removes the custom implementation of a TaskLauncher.
This commit is contained in:
Michael Minella
2017-04-13 13:12:42 -05:00
parent a1cffe8bd4
commit f135e84128
8 changed files with 37 additions and 60 deletions

12
pom.xml
View File

@@ -137,12 +137,12 @@
</modules>
<properties>
<spring-cloud-stream.version>1.2.0.RC1</spring-cloud-stream.version>
<spring-cloud-deployer-spi.version>1.2.0.M3</spring-cloud-deployer-spi.version>
<spring-cloud-deployer-local.version>1.2.0.M3</spring-cloud-deployer-local.version>
<spring-cloud-stream-binder-rabbit.version>1.2.0.RC1</spring-cloud-stream-binder-rabbit.version>
<spring-cloud-deployer-resource-support.version>1.2.0.M3</spring-cloud-deployer-resource-support.version>
<spring-cloud-deployer-resource-maven.version>1.2.0.M3</spring-cloud-deployer-resource-maven.version>
<spring-cloud-stream.version>1.2.1.RELEASE</spring-cloud-stream.version>
<spring-cloud-deployer-spi.version>1.2.0.RC1</spring-cloud-deployer-spi.version>
<spring-cloud-deployer-local.version>1.2.0.RC1</spring-cloud-deployer-local.version>
<spring-cloud-stream-binder-rabbit.version>1.2.0.RELEASE</spring-cloud-stream-binder-rabbit.version>
<spring-cloud-deployer-resource-support.version>1.2.0.RC1</spring-cloud-deployer-resource-support.version>
<spring-cloud-deployer-resource-maven.version>1.2.0.RC1</spring-cloud-deployer-resource-maven.version>
<spring-batch.version>3.0.7.RELEASE</spring-batch.version>
<commons-logging.version>1.1</commons-logging.version>

View File

@@ -51,19 +51,19 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rabbit</artifactId>
<version>1.1.2.RELEASE</version>
<version>1.2.0.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-rabbit-test-support</artifactId>
<version>1.1.2.RELEASE</version>
<version>1.2.0.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-test-support-internal</artifactId>
<version>1.1.1.RELEASE</version>
<version>1.2.1.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>

View File

@@ -53,7 +53,7 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-deployer-local</artifactId>
<version>1.1.3.RELEASE</version>
<version>1.2.0.RC1</version>
</dependency>
<dependency>

View File

@@ -48,7 +48,7 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rabbit</artifactId>
<version>1.1.2.RELEASE</version>
<version>1.2.0.RELEASE</version>
<scope>compile</scope>
</dependency>

View File

@@ -46,7 +46,7 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rabbit</artifactId>
<version>1.1.2.RELEASE</version>
<version>1.2.0.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>

View File

@@ -39,11 +39,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-deployer-local</artifactId>
<version>1.1.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-task</artifactId>
@@ -51,13 +46,13 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rabbit</artifactId>
<version>1.1.2.RELEASE</version>
<version>1.2.0.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-test-support</artifactId>
<version>1.1.1.RELEASE</version>
<version>1.2.1.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>

View File

@@ -16,16 +16,18 @@
package io.spring;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import io.spring.configuration.TaskSinkConfiguration;
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.task.LaunchState;
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;
@@ -34,6 +36,8 @@ import org.springframework.test.context.junit4.SpringRunner;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.verify;
/**
* @author Glenn Renfro
@@ -49,11 +53,11 @@ public class TaskSinkApplicationTests {
private Sink sink;
@Test
public void testLaunch() {
public void testLaunch() throws IOException {
assertNotNull(this.sink.input());
TaskSinkConfiguration.TestTaskLauncher testTaskLauncher =
context.getBean(TaskSinkConfiguration.TestTaskLauncher.class);
TaskLauncher testTaskLauncher =
context.getBean(TaskLauncher.class);
Map<String, String> properties = new HashMap();
properties.put("server.port", "0");
@@ -63,6 +67,16 @@ public class TaskSinkApplicationTests {
null, null);
GenericMessage<TaskLaunchRequest> message = new GenericMessage<TaskLaunchRequest>(request);
this.sink.input().send(message);
assertEquals(LaunchState.complete, testTaskLauncher.status("TESTSTATUS").getState());
ArgumentCaptor<AppDeploymentRequest> deploymentRequest = ArgumentCaptor.forClass(AppDeploymentRequest.class);
verify(testTaskLauncher).launch(deploymentRequest.capture());
AppDeploymentRequest actualRequest = deploymentRequest.getValue();
assertTrue(actualRequest.getCommandlineArguments().isEmpty());
assertEquals("0", actualRequest.getDefinition().getProperties().get("server.port"));
assertTrue(actualRequest.getResource().toString()
.contains("maven://org.springframework.cloud.task.app:timestamp-task:jar:1.0.1.RELEASE"));
}
}

View File

@@ -16,13 +16,12 @@
package io.spring.configuration;
import org.springframework.cloud.deployer.spi.core.AppDeploymentRequest;
import org.springframework.cloud.deployer.spi.task.LaunchState;
import org.springframework.cloud.deployer.spi.task.TaskLauncher;
import org.springframework.cloud.deployer.spi.task.TaskStatus;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import static org.mockito.Mockito.mock;
/**
* @author Glenn Renfro
*/
@@ -31,38 +30,7 @@ public class TaskSinkConfiguration {
@Bean
public TaskLauncher taskLauncher() {
return new TestTaskLauncher();
}
public class TestTaskLauncher implements TaskLauncher {
public static final String LAUNCH_ID = "TEST_LAUNCH_ID";
private LaunchState state = LaunchState.unknown;
@Override
public String launch(AppDeploymentRequest request) {
state = LaunchState.complete;
return null;
}
@Override
public void cancel(String id) {
}
@Override
public TaskStatus status(String id) {
String taskLaunchId = LAUNCH_ID;
TaskStatus taskStatus = new TaskStatus(taskLaunchId, state, null);
return taskStatus;
}
@Override
public void cleanup(String id) {}
@Override
public void destroy(String appName) {}
return mock(TaskLauncher.class);
}
}