mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Polish spring-boot-sample-activemq
This commit is contained in:
parent
4dbf55ea13
commit
53ca15b478
@ -1,18 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<!-- Your own application should inherit from spring-boot-starter-parent -->
|
||||
<artifactId>spring-boot-samples</artifactId>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<version>1.3.0.BUILD-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>spring-boot-sample-activemq</artifactId>
|
||||
<name>Spring Boot ActiveMQ Sample</name>
|
||||
<description>Spring Boot ActiveMQ Sample</description>
|
||||
<url>http://projects.spring.io/spring-boot/</url>
|
||||
|
||||
<organization>
|
||||
<name>Pivotal Software, Inc.</name>
|
||||
<url>http://www.spring.io</url>
|
||||
</organization>
|
||||
<properties>
|
||||
<main.basedir>${basedir}/../..</main.basedir>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
@ -26,14 +31,12 @@
|
||||
<groupId>org.apache.activemq</groupId>
|
||||
<artifactId>activemq-broker</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
@ -42,5 +45,4 @@
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
@ -39,7 +39,7 @@ public class Producer implements CommandLineRunner {
|
||||
}
|
||||
|
||||
public void send(String msg) {
|
||||
jmsMessagingTemplate.convertAndSend(queue, msg);
|
||||
this.jmsMessagingTemplate.convertAndSend(this.queue, msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,14 +16,14 @@
|
||||
|
||||
package sample.activemq;
|
||||
|
||||
import javax.jms.Queue;
|
||||
|
||||
import org.apache.activemq.command.ActiveMQQueue;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.jms.annotation.EnableJms;
|
||||
|
||||
import javax.jms.Queue;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableJms
|
||||
public class SampleActiveMQApplication {
|
||||
|
@ -16,6 +16,8 @@
|
||||
|
||||
package sample.activemq;
|
||||
|
||||
import javax.jms.JMSException;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@ -24,12 +26,15 @@ import org.springframework.boot.test.OutputCapture;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import javax.jms.JMSException;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Integration tests for demo application.
|
||||
*
|
||||
* @author Eddú Meléndez
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringApplicationConfiguration(classes = {SampleActiveMQApplication.class})
|
||||
@SpringApplicationConfiguration(classes = { SampleActiveMQApplication.class })
|
||||
public class SampleActiveMqTests {
|
||||
|
||||
@Rule
|
||||
@ -40,9 +45,9 @@ public class SampleActiveMqTests {
|
||||
|
||||
@Test
|
||||
public void sendSimpleMessage() throws InterruptedException, JMSException {
|
||||
producer.send("Test message");
|
||||
this.producer.send("Test message");
|
||||
Thread.sleep(1000L);
|
||||
assertTrue(outputCapture.toString().contains("Test message"));
|
||||
assertTrue(this.outputCapture.toString().contains("Test message"));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user