Polish spring-boot-sample-activemq

This commit is contained in:
Phillip Webb 2015-03-23 09:50:25 -07:00
parent 4dbf55ea13
commit 53ca15b478
4 changed files with 23 additions and 16 deletions

View File

@ -1,18 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <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">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <modelVersion>4.0.0</modelVersion>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<!-- Your own application should inherit from spring-boot-starter-parent -->
<artifactId>spring-boot-samples</artifactId> <artifactId>spring-boot-samples</artifactId>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<version>1.3.0.BUILD-SNAPSHOT</version> <version>1.3.0.BUILD-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-boot-sample-activemq</artifactId> <artifactId>spring-boot-sample-activemq</artifactId>
<name>Spring Boot ActiveMQ Sample</name> <name>Spring Boot ActiveMQ Sample</name>
<description>Spring Boot ActiveMQ Sample</description> <description>Spring Boot ActiveMQ Sample</description>
<url>http://projects.spring.io/spring-boot/</url> <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> <dependencies>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
@ -26,14 +31,12 @@
<groupId>org.apache.activemq</groupId> <groupId>org.apache.activemq</groupId>
<artifactId>activemq-broker</artifactId> <artifactId>activemq-broker</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
@ -42,5 +45,4 @@
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
</project> </project>

View File

@ -39,7 +39,7 @@ public class Producer implements CommandLineRunner {
} }
public void send(String msg) { public void send(String msg) {
jmsMessagingTemplate.convertAndSend(queue, msg); this.jmsMessagingTemplate.convertAndSend(this.queue, msg);
} }
} }

View File

@ -16,14 +16,14 @@
package sample.activemq; package sample.activemq;
import javax.jms.Queue;
import org.apache.activemq.command.ActiveMQQueue; import org.apache.activemq.command.ActiveMQQueue;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.jms.annotation.EnableJms; import org.springframework.jms.annotation.EnableJms;
import javax.jms.Queue;
@SpringBootApplication @SpringBootApplication
@EnableJms @EnableJms
public class SampleActiveMQApplication { public class SampleActiveMQApplication {

View File

@ -16,6 +16,8 @@
package sample.activemq; package sample.activemq;
import javax.jms.JMSException;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -24,10 +26,13 @@ import org.springframework.boot.test.OutputCapture;
import org.springframework.boot.test.SpringApplicationConfiguration; import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import javax.jms.JMSException;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
/**
* Integration tests for demo application.
*
* @author Eddú Meléndez
*/
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = { SampleActiveMQApplication.class }) @SpringApplicationConfiguration(classes = { SampleActiveMQApplication.class })
public class SampleActiveMqTests { public class SampleActiveMqTests {
@ -40,9 +45,9 @@ public class SampleActiveMqTests {
@Test @Test
public void sendSimpleMessage() throws InterruptedException, JMSException { public void sendSimpleMessage() throws InterruptedException, JMSException {
producer.send("Test message"); this.producer.send("Test message");
Thread.sleep(1000L); Thread.sleep(1000L);
assertTrue(outputCapture.toString().contains("Test message")); assertTrue(this.outputCapture.toString().contains("Test message"));
} }
} }