Avoid duplicate script
This commit avoids a script duplication: the integration test runs the sample instead of a copy of it in the repro directory. Also switched the sample from ActiveMQ to HornetQ as #323 revealed some locking on CI. Hopefully that should fix it as HornetQ is non persistent and can be embedded several times in the same VM. Fixes gh-1456
This commit is contained in:
parent
0dc389f5b3
commit
85c95744f9
|
@ -1,10 +1,12 @@
|
||||||
package org.test
|
package org.test
|
||||||
|
|
||||||
@Grab("org.apache.activemq:activemq-all:5.4.0")
|
@Grab("spring-boot-starter-hornetq")
|
||||||
@Grab("activemq-pool")
|
@Grab("hornetq-jms-server")
|
||||||
import java.util.concurrent.CountDownLatch
|
import java.util.concurrent.CountDownLatch
|
||||||
|
import org.hornetq.jms.server.config.impl.JMSQueueConfigurationImpl
|
||||||
|
|
||||||
@Log
|
@Log
|
||||||
|
@Configuration
|
||||||
@EnableJms
|
@EnableJms
|
||||||
class JmsExample implements CommandLineRunner {
|
class JmsExample implements CommandLineRunner {
|
||||||
|
|
||||||
|
@ -15,7 +17,7 @@ class JmsExample implements CommandLineRunner {
|
||||||
|
|
||||||
void run(String... args) {
|
void run(String... args) {
|
||||||
def messageCreator = { session ->
|
def messageCreator = { session ->
|
||||||
session.createObjectMessage("Greetings from Spring Boot via ActiveMQ")
|
session.createObjectMessage("Greetings from Spring Boot via HornetQ")
|
||||||
} as MessageCreator
|
} as MessageCreator
|
||||||
log.info "Sending JMS message..."
|
log.info "Sending JMS message..."
|
||||||
jmsTemplate.send("spring-boot", messageCreator)
|
jmsTemplate.send("spring-boot", messageCreator)
|
||||||
|
@ -29,4 +31,8 @@ class JmsExample implements CommandLineRunner {
|
||||||
latch.countDown()
|
latch.countDown()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean JMSQueueConfigurationImpl springBootQueue() {
|
||||||
|
new JMSQueueConfigurationImpl('spring-boot', null, false)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,10 +73,5 @@ public class ReproIntegrationTests {
|
||||||
this.cli.jar("secure.groovy", "crsh.groovy");
|
this.cli.jar("secure.groovy", "crsh.groovy");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void jmsListener() throws Exception {
|
|
||||||
this.cli.run("jms.groovy");
|
|
||||||
assertThat(this.cli.getOutput(), containsString("Hello World"));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,12 +136,10 @@ public class SampleIntegrationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore("Intermittent failure on CI. See #323")
|
|
||||||
public void jmsSample() throws Exception {
|
public void jmsSample() throws Exception {
|
||||||
String output = this.cli.run("jms.groovy");
|
String output = this.cli.run("jms.groovy");
|
||||||
assertTrue("Wrong output: " + output,
|
assertTrue("Wrong output: " + output,
|
||||||
output.contains("Received Greetings from Spring Boot via ActiveMQ"));
|
output.contains("Received Greetings from Spring Boot via HornetQ"));
|
||||||
FileUtils.deleteDirectory(new File("activemq-data"));// cleanup ActiveMQ cruft
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
package org.test
|
|
||||||
|
|
||||||
@Grab("org.apache.activemq:activemq-all:5.4.0")
|
|
||||||
@Grab("activemq-pool")
|
|
||||||
import java.util.concurrent.CountDownLatch
|
|
||||||
|
|
||||||
@Log
|
|
||||||
@EnableJms
|
|
||||||
class SampleJmsListener implements CommandLineRunner {
|
|
||||||
|
|
||||||
private CountDownLatch latch = new CountDownLatch(1)
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
JmsTemplate jmsTemplate
|
|
||||||
|
|
||||||
void run(String... args) {
|
|
||||||
def messageCreator = { session ->
|
|
||||||
session.createObjectMessage("Hello World")
|
|
||||||
} as MessageCreator
|
|
||||||
log.info "Sending JMS message..."
|
|
||||||
jmsTemplate.send("testQueue", messageCreator)
|
|
||||||
log.info "Sent JMS message, waiting..."
|
|
||||||
latch.await()
|
|
||||||
}
|
|
||||||
|
|
||||||
@JmsListener(destination = 'testQueue')
|
|
||||||
def receive(String message) {
|
|
||||||
log.info "Received ${message}"
|
|
||||||
latch.countDown()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue