Merge branch '1.5.x'

This commit is contained in:
Phillip Webb
2016-12-21 22:32:43 -08:00
33 changed files with 540 additions and 130 deletions

View File

@@ -0,0 +1,38 @@
/*
* Copyright 2012-2016 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package sample.integration;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
@Component
public class SampleCommandLineRunner implements CommandLineRunner {
private final SampleMessageGateway gateway;
public SampleCommandLineRunner(SampleMessageGateway gateway) {
this.gateway = gateway;
}
@Override
public void run(String... args) throws Exception {
for (String arg : args) {
this.gateway.echo(arg);
}
}
}

View File

@@ -0,0 +1,26 @@
/*
* Copyright 2012-2016 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package sample.integration;
import org.springframework.integration.annotation.MessagingGateway;
@MessagingGateway(defaultRequestChannel = "outputChannel")
public interface SampleMessageGateway {
void echo(String message);
}

View File

@@ -23,9 +23,8 @@ import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import org.junit.AfterClass;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import sample.integration.SampleIntegrationApplication;
import sample.integration.producer.ProducerApplication;
@@ -48,32 +47,37 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
public class SampleIntegrationApplicationTests {
private static ConfigurableApplicationContext context;
@BeforeClass
public static void start() throws Exception {
context = SpringApplication.run(SampleIntegrationApplication.class);
}
@AfterClass
public static void stop() {
if (context != null) {
context.close();
}
}
private ConfigurableApplicationContext context;
@Before
public void deleteOutput() {
FileSystemUtils.deleteRecursively(new File("target/input"));
FileSystemUtils.deleteRecursively(new File("target/output"));
}
@After
public void stop() {
if (this.context != null) {
this.context.close();
}
}
@Test
public void testVanillaExchange() throws Exception {
this.context = SpringApplication.run(SampleIntegrationApplication.class);
SpringApplication.run(ProducerApplication.class, "World");
String output = getOutput();
assertThat(output).contains("Hello World");
}
@Test
public void testMessageGateway() throws Exception {
this.context = SpringApplication.run(SampleIntegrationApplication.class,
"testviamg");
String output = getOutput();
assertThat(output).contains("testviamg");
}
private String getOutput() throws Exception {
Future<String> future = Executors.newSingleThreadExecutor()
.submit(new Callable<String>() {