org.springframework.cloud.task.launcher.TaskLaunchRequest Java Examples
The following examples show how to use
org.springframework.cloud.task.launcher.TaskLaunchRequest.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TriggertaskSourceTests.java From spring-cloud-stream-app-starters with Apache License 2.0 | 6 votes |
@Test public void fixedDelayTest() throws InterruptedException { TaskLaunchRequest tlr = (TaskLaunchRequest) messageCollector.forChannel(triggerSource.output()).poll(2100, TimeUnit.MILLISECONDS).getPayload(); assertEquals(BASE_URI, tlr.getUri()); checkConfigurationSize(3, 3, 3, tlr); for (int i = 0; i < 3; i++) { assertEquals(String.format("the expected environment property for %s was %s but expected %s", PROP_PREFIX + i, tlr.getEnvironmentProperties().get(PROP_PREFIX + i), environmentPropertyMap.get(PROP_PREFIX + i )), environmentPropertyMap.get(PROP_PREFIX + i ), tlr.getEnvironmentProperties().get(PROP_PREFIX + i)); assertEquals(String.format("the expected deployment property for %s was %s but expected %s", PROP_PREFIX + i, tlr.getDeploymentProperties().get(PROP_PREFIX + i), deploymentPropertyMap.get(PROP_PREFIX + i )), deploymentPropertyMap.get(PROP_PREFIX + i ), tlr.getDeploymentProperties().get(PROP_PREFIX + i)); assertEquals(String.format("the expected commandLineArg was %s but expected param%s", i, tlr.getCommandlineArguments().get(i), PARAMS[i]), PARAMS[i], tlr.getCommandlineArguments().get(i)); } }
Example #2
Source File: TaskProcessorApplicationTests.java From spring-cloud-task with Apache License 2.0 | 6 votes |
@Test public void test() throws InterruptedException, IOException { this.channels.input().send(new GenericMessage<Object>(DEFAULT_PAYLOAD)); Map<String, String> properties = new HashMap(); properties.put("payload", DEFAULT_PAYLOAD); TaskLaunchRequest expectedRequest = new TaskLaunchRequest( "maven://org.springframework.cloud.task.app:" + "timestamp-task:jar:1.0.1.RELEASE", null, properties, null, null); Message<String> result = (Message<String>) this.collector .forChannel(this.channels.output()) .take(); TaskLaunchRequest tlq = this.mapper .readValue(result.getPayload(), TaskLaunchRequest.class); assertThat(tlq).isEqualTo(expectedRequest); }
Example #3
Source File: TaskLauncherLocalSinkIntegrationTests.java From spring-cloud-stream-app-starters with Apache License 2.0 | 5 votes |
@Test @Ignore public void sendRequest() throws IOException { TaskSinkConfiguration.TestTaskLauncher testTaskLauncher = (TaskSinkConfiguration.TestTaskLauncher) applicationContext.getBean(TaskSinkConfiguration.TestTaskLauncher.class); TaskLaunchRequest request = new TaskLaunchRequest("maven://org.springframework.cloud.task.app:timestamp-task:jar:1.0.0.BUILD-SNAPSHOT", null, null, null); sink.input().send(new GenericMessage<>(request)); assertEquals(LaunchState.complete, testTaskLauncher.status("TESTSTATUS").getState()); }
Example #4
Source File: TasklaunchrequestTransformProcessorConfiguration.java From spring-cloud-stream-app-starters with Apache License 2.0 | 5 votes |
@Transformer(inputChannel = Processor.INPUT, outputChannel = Processor.OUTPUT) public Object setupRequest(String message) { Map<String, String> properties = new HashMap<String, String>(); Map<String, String> deploymentProperties = null; List<String> commandLineArgs = null; if (StringUtils.hasText(processorProperties.getDataSourceUrl())) { properties.put("spring_datasource_url", processorProperties.getDataSourceUrl()); } if (StringUtils.hasText(processorProperties.getDataSourceDriverClassName())) { properties.put("spring_datasource_driverClassName", processorProperties.getDataSourceDriverClassName()); } if (StringUtils.hasText(processorProperties.getDataSourceUserName())) { properties.put("spring_datasource_username", processorProperties.getDataSourceUserName()); } if (StringUtils.hasText(processorProperties.getDataSourcePassword())) { properties.put("spring_datasource_password", processorProperties.getDataSourcePassword()); } if (StringUtils.hasLength(processorProperties.getDeploymentProperties())) { deploymentProperties = parse(processorProperties.getDeploymentProperties()); } if (StringUtils.hasLength(processorProperties.getCommandLineArguments())) { commandLineArgs = parseParams(processorProperties.getCommandLineArguments()); } TaskLaunchRequest request = new TaskLaunchRequest( processorProperties.getUri(), commandLineArgs, properties, deploymentProperties); return request; }
Example #5
Source File: TasklaunchrequestTransformProcessorIntegrationTests.java From spring-cloud-stream-app-starters with Apache License 2.0 | 5 votes |
protected TaskLaunchRequest getDefaultRequest( Map <String,String> environmentVariables, Map<String,String> deploymentProperties, List<String> commandLineArgs) { TaskLaunchRequest request = new TaskLaunchRequest( DEFAULT_URI, commandLineArgs, environmentVariables, deploymentProperties); return request; }
Example #6
Source File: TriggertaskSourceConfiguration.java From spring-cloud-stream-app-starters with Apache License 2.0 | 5 votes |
@PollableSource public Object triggerTaskSource() { return new TaskLaunchRequest(taskPayloadProperties.getUri(), parseParams( commandLineArgumentTransformer.transform( taskPayloadProperties.getCommandLineArgs())), parseProperties(taskPayloadProperties.getEnvironmentProperties()), parseProperties(taskPayloadProperties.getDeploymentProperties())); }
Example #7
Source File: TaskSinkApplicationTests.java From spring-cloud-task with Apache License 2.0 | 5 votes |
@Test public void testLaunch() throws IOException { assertThat(this.sink.input()).isNotNull(); TaskLauncher testTaskLauncher = this.context.getBean(TaskLauncher.class); Map<String, String> properties = new HashMap(); properties.put("server.port", "0"); TaskLaunchRequest request = new TaskLaunchRequest( "maven://org.springframework.cloud.task.app:" + "timestamp-task:jar:1.0.1.RELEASE", null, properties, null, null); GenericMessage<TaskLaunchRequest> message = new GenericMessage<>(request); this.sink.input().send(message); ArgumentCaptor<AppDeploymentRequest> deploymentRequest = ArgumentCaptor .forClass(AppDeploymentRequest.class); verify(testTaskLauncher).launch(deploymentRequest.capture()); AppDeploymentRequest actualRequest = deploymentRequest.getValue(); assertThat(actualRequest.getCommandlineArguments().isEmpty()).isTrue(); assertThat(actualRequest.getDefinition().getProperties() .get("server.port")).isEqualTo("0"); assertThat(actualRequest.getResource().toString() .contains("maven://org.springframework.cloud.task.app:timestamp-task:jar:1.0.1.RELEASE")) .isTrue(); }
Example #8
Source File: TaskProcessor.java From spring-cloud-task with Apache License 2.0 | 5 votes |
@Transformer(inputChannel = Processor.INPUT, outputChannel = Processor.OUTPUT) public Object setupRequest(String message) { Map<String, String> properties = new HashMap<>(); if (StringUtils.hasText(this.processorProperties.getDataSourceUrl())) { properties .put("spring_datasource_url", this.processorProperties .getDataSourceUrl()); } if (StringUtils .hasText(this.processorProperties.getDataSourceDriverClassName())) { properties.put("spring_datasource_driverClassName", this.processorProperties .getDataSourceDriverClassName()); } if (StringUtils.hasText(this.processorProperties.getDataSourceUserName())) { properties.put("spring_datasource_username", this.processorProperties .getDataSourceUserName()); } if (StringUtils.hasText(this.processorProperties.getDataSourcePassword())) { properties.put("spring_datasource_password", this.processorProperties .getDataSourcePassword()); } properties.put("payload", message); TaskLaunchRequest request = new TaskLaunchRequest( this.processorProperties.getUri(), null, properties, null, this.processorProperties.getApplicationName()); return new GenericMessage<>(request); }
Example #9
Source File: SpringCloudTaskSinkApplicationIntegrationTest.java From tutorials with MIT License | 5 votes |
@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")); }
Example #10
Source File: TaskLauncherLocalSinkIntegrationTests.java From spring-cloud-stream-app-starters with Apache License 2.0 | 4 votes |
@Test(expected = MessageHandlingException.class) public void sendBadRequest() throws IOException { TaskLaunchRequest request = new TaskLaunchRequest("maven://foo", null, null, null); sink.input().send(new GenericMessage<>(request)); }
Example #11
Source File: TasklaunchrequestTransformProcessorIntegrationTests.java From spring-cloud-stream-app-starters with Apache License 2.0 | 4 votes |
protected TaskLaunchRequest getDefaultRequest() { Map<String, String> environmentVariables = new HashMap<>(1); return getDefaultRequest(environmentVariables, null, null); }
Example #12
Source File: TriggertaskSourceTests.java From spring-cloud-stream-app-starters with Apache License 2.0 | 4 votes |
@Test public void fixedDelayNoCommantLineArgumentsTest() throws InterruptedException { TaskLaunchRequest tlr = (TaskLaunchRequest) messageCollector.forChannel(triggerSource.output()).poll(2100, TimeUnit.MILLISECONDS).getPayload(); assertEquals(BASE_URI, tlr.getUri()); checkConfigurationSize(0, 0, 0, tlr); }
Example #13
Source File: TriggertaskSourceTests.java From spring-cloud-stream-app-starters with Apache License 2.0 | 4 votes |
@Test(expected = NullPointerException.class) public void MissingURITest() throws InterruptedException { TaskLaunchRequest tlr = (TaskLaunchRequest) messageCollector.forChannel(triggerSource.output()).poll(2100, TimeUnit.MILLISECONDS).getPayload(); }
Example #14
Source File: TriggertaskSourceTests.java From spring-cloud-stream-app-starters with Apache License 2.0 | 4 votes |
@Test public void fixedDelayTest() throws InterruptedException { TaskLaunchRequest tlr = (TaskLaunchRequest) messageCollector.forChannel(triggerSource.output()).poll(2100, TimeUnit.MILLISECONDS).getPayload(); assertEquals(BASE_URI, tlr.getUri()); checkConfigurationSize(0, 0, 0, tlr); }
Example #15
Source File: TriggertaskSourceTests.java From spring-cloud-stream-app-starters with Apache License 2.0 | 4 votes |
private static void checkConfigurationSize(int commandLineArgSize, int environmentPropertySize, int deploymentPropertySize, TaskLaunchRequest tlr) { assertEquals(String.format("expected %d commandLineArgs", commandLineArgSize), commandLineArgSize, tlr.getCommandlineArguments().size()); assertEquals(String.format("expected %d environmentProperties", environmentPropertySize), environmentPropertySize, tlr.getEnvironmentProperties().size()); assertEquals(String.format("expected %d deploymentProperties", deploymentPropertySize), deploymentPropertySize, tlr.getDeploymentProperties().size()); }