Make sure integration still works in CLI

pull/187/head
Dave Syer 11 years ago
parent aa2b020660
commit 4cfc7b6ad9

@ -122,6 +122,11 @@
<artifactId>junit</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-core</artifactId>
<scope>provided</scope>
</dependency>
<!-- Test -->
<dependency>
<groupId>${project.groupId}</groupId>

@ -0,0 +1,26 @@
package org.test
@Component
@EnableIntegrationPatterns
class SpringIntegrationExample implements CommandLineRunner {
@Bean
DirectChannel input() {
new DirectChannel();
}
@Override
void run(String... args) {
print new MessagingTemplate(input()).convertSendAndReceive("World")
}
}
@MessageEndpoint
class HelloTransformer {
@Transformer(inputChannel="input")
String transform(String payload) {
"Hello, ${payload}"
}
}

@ -41,7 +41,7 @@ public class SpringIntegrationCompilerAutoConfiguration extends CompilerAutoConf
@Override
public void applyDependencies(DependencyCustomizer dependencies) {
dependencies.ifAnyMissingClasses("org.springframework.integration.Message").add(
"spring-boot-starter-integration", "spring-integration-dsl-groovy-core");
"spring-boot-starter-integration");
dependencies.ifAnyMissingClasses("groovy.util.XmlParser").add("groovy-xml");
}
@ -50,14 +50,14 @@ public class SpringIntegrationCompilerAutoConfiguration extends CompilerAutoConf
imports.addImports("org.springframework.integration.Message",
"org.springframework.integration.support.MessageBuilder",
"org.springframework.integration.MessageChannel",
"org.springframework.integration.channel.DirectChannel",
"org.springframework.integration.channel.QueueChannel",
"org.springframework.integration.channel.ExecutorChannel",
"org.springframework.integration.MessageHeaders",
"org.springframework.integration.annotation.MessageEndpoint",
"org.springframework.integration.annotation.Header",
"org.springframework.integration.annotation.Headers",
"org.springframework.integration.annotation.Payload",
"org.springframework.integration.annotation.Payloads",
"org.springframework.integration.dsl.groovy.MessageFlow",
"org.springframework.integration.dsl.groovy.builder.IntegrationBuilder",
"org.springframework.integration.core.MessagingTemplate",
"org.springframework.integration.core.SubscribableChannel",
"org.springframework.integration.core.PollableChannel",
EnableIntegrationPatterns.class.getCanonicalName());
imports.addStarImports("org.springframework.integration.annotation");
}
}

@ -22,9 +22,14 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
@Target(ElementType.TYPE)
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Configuration
@ImportResource("classpath:/org/springframework/boot/groovy/integration.xml")
public @interface EnableIntegrationPatterns {
}

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int="http://www.springframework.org/schema/integration"
xsi:schemaLocation="http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<int:annotation-config />
</beans>

@ -121,6 +121,12 @@ public class SampleIntegrationTests {
assertTrue("Wrong output: " + output, output.contains("Hello World"));
}
@Test
public void integrationSample() throws Exception {
String output = this.cli.run("integration.groovy");
assertTrue("Wrong output: " + output, output.contains("Hello, World"));
}
@Test
public void xmlSample() throws Exception {
String output = this.cli.run("runner.xml", "runner.groovy");

Loading…
Cancel
Save