Upgrade to Reactor 3.0 and start building against SI 5.0 snapshots

Closes gh-7301
See gh-7029
This commit is contained in:
Andy Wilkinson
2016-11-03 20:49:02 +00:00
parent f7618cb421
commit 4486d2d209
19 changed files with 50 additions and 355 deletions

View File

@@ -1,48 +0,0 @@
package org.test
import java.util.concurrent.CountDownLatch
@EnableReactor
@Log
class Runner implements CommandLineRunner {
@Autowired
EventBus eventBus
private CountDownLatch latch = new CountDownLatch(1)
@PostConstruct
void init() {
log.info "Registering consumer"
}
void run(String... args) {
eventBus.notify("hello", Event.wrap("Phil"))
log.info "Notified Phil"
latch.await()
}
@Bean
CountDownLatch latch() {
latch
}
}
@Consumer
@Log
class Greeter {
@Autowired
EventBus eventBus
@Autowired
private CountDownLatch latch
@Selector(value="hello")
void receive(String data) {
log.info "Hello ${data}"
latch.countDown()
}
}

View File

@@ -1,60 +0,0 @@
/*
* Copyright 2012-2015 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 org.springframework.boot.cli.compiler.autoconfigure;
import org.codehaus.groovy.ast.ClassNode;
import org.codehaus.groovy.control.customizers.ImportCustomizer;
import org.springframework.boot.cli.compiler.AstUtils;
import org.springframework.boot.cli.compiler.CompilerAutoConfiguration;
import org.springframework.boot.cli.compiler.DependencyCustomizer;
/**
* {@link CompilerAutoConfiguration} for the Reactor.
*
* @author Dave Syer
*/
public class ReactorCompilerAutoConfiguration extends CompilerAutoConfiguration {
@Override
public boolean matches(ClassNode classNode) {
return AstUtils.hasAtLeastOneAnnotation(classNode, "EnableReactor")
|| AstUtils.hasAtLeastOneFieldOrMethod(classNode, "EventBus");
}
@Override
public void applyDependencies(DependencyCustomizer dependencies) {
dependencies.ifAnyMissingClasses("reactor.bus.EventBus")
.add("reactor-spring-context", false).add("reactor-spring-core", false)
.add("reactor-bus").add("reactor-stream");
}
@Override
public void applyImports(ImportCustomizer imports) {
imports.addImports("reactor.bus.Bus", "reactor.bus.Event", "reactor.bus.EventBus",
"reactor.fn.Function", "reactor.fn.Functions", "reactor.fn.Predicate",
"reactor.fn.Predicates", "reactor.fn.Supplier", "reactor.fn.Suppliers",
"reactor.spring.context.annotation.Consumer",
"reactor.spring.context.annotation.ReplyTo",
"reactor.spring.context.annotation.Selector",
"reactor.spring.context.annotation.SelectorType",
"reactor.spring.context.config.EnableReactor")
.addStarImports("reactor.bus.selector.Selectors")
.addImport("ReactorEnvironment", "reactor.Environment");
}
}

View File

@@ -3,7 +3,6 @@ org.springframework.boot.cli.compiler.autoconfigure.GroovyTemplatesCompilerAutoC
org.springframework.boot.cli.compiler.autoconfigure.SpringMvcCompilerAutoConfiguration
org.springframework.boot.cli.compiler.autoconfigure.SpringBatchCompilerAutoConfiguration
org.springframework.boot.cli.compiler.autoconfigure.RabbitCompilerAutoConfiguration
org.springframework.boot.cli.compiler.autoconfigure.ReactorCompilerAutoConfiguration
org.springframework.boot.cli.compiler.autoconfigure.CachingCompilerAutoConfiguration
org.springframework.boot.cli.compiler.autoconfigure.JdbcCompilerAutoConfiguration
org.springframework.boot.cli.compiler.autoconfigure.JmsCompilerAutoConfiguration

View File

@@ -78,17 +78,6 @@ public class SampleIntegrationTests {
assertThat(output).contains("security.oauth2.client.secret =");
}
@Test
public void reactorSample() throws Exception {
String output = this.cli.run("reactor.groovy", "Phil");
int count = 0;
while (!output.contains("Hello Phil") && count++ < 5) {
Thread.sleep(200);
output = this.cli.getOutput();
}
assertThat(output).contains("Hello Phil");
}
@Test
public void jobWebSample() throws Exception {
String output = this.cli.run("job.groovy", "web.groovy", "foo=bar");

View File

@@ -96,7 +96,7 @@ public class TestCommandIntegrationTests {
@Test
public void integrationAutoConfigTest() throws Exception {
String output = this.cli.test("integration_auto_test.groovy", "reactor.groovy");
String output = this.cli.test("integration_auto_test.groovy", "jms.groovy");
assertThat(output).contains("OK (1 test)");
}

View File

@@ -1,12 +1,14 @@
@SpringBootTest(classes=ReactorApplication, webEnvironment=WebEnvironment.RANDOM_PORT)
class RestTests {
import org.springframework.jms.core.JmsTemplate
@SpringBootTest(classes=JmsExample)
class JmsTests {
@Autowired
EventBus eventBus
JmsTemplate jmsTemplate
@Test
void test() {
assertNotNull(eventBus)
assertNotNull(jmsTemplate)
}
}

View File

@@ -0,0 +1,31 @@
@Grab("spring-boot-starter-artemis")
@Grab("artemis-jms-server")
import java.util.concurrent.CountDownLatch
@Log
@Configuration
@EnableJms
class JmsExample implements CommandLineRunner {
private CountDownLatch latch = new CountDownLatch(1)
@Autowired
JmsTemplate jmsTemplate
void run(String... args) {
def messageCreator = { session ->
session.createObjectMessage("Greetings from Spring Boot via Artemis")
} as MessageCreator
log.info "Sending JMS message..."
jmsTemplate.send("spring-boot", messageCreator)
log.info "Send JMS message, waiting..."
latch.await()
}
@JmsListener(destination = 'spring-boot')
def receive(String message) {
log.info "Received ${message}"
latch.countDown()
}
}

View File

@@ -1,4 +0,0 @@
@Configuration
@EnableReactor
class ReactorApplication {
}