From fd525077bd77e416fb5829b596bd054663e85d33 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Mon, 19 Oct 2015 11:46:15 +0200 Subject: [PATCH] Improve HornetQ/Artemis embedded tests Previously, HornetQ and Artemis tests were using a test configuration class listing the configuration classes to use explicitly in the purpose of disabling the XA support. This had a very unfortunate side effect for Artemis as we forgot to add an import on the "real" configuration and this got unnoticed because of this duplication. It turns out that this special configuration class is no longer necessary as XA backs off automatically anyway now. The tests have been updated to use the regular auto-configuration and were failing with Artemis. The import has now be added. Closes gh-4226 --- .../jms/artemis/ArtemisAutoConfiguration.java | 4 +++- .../jms/artemis/ArtemisAutoConfigurationTests.java | 12 +----------- .../jms/hornetq/HornetQAutoConfigurationTests.java | 11 +---------- 3 files changed, 5 insertions(+), 22 deletions(-) diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisAutoConfiguration.java index 41d0022c64e..286069500ed 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisAutoConfiguration.java @@ -37,6 +37,7 @@ import org.springframework.context.annotation.Import; * settings. * * @author EddĂș MelĂ©ndez + * @author Stephane Nicoll * @since 1.3.0 * @see ArtemisProperties */ @@ -46,7 +47,8 @@ import org.springframework.context.annotation.Import; @ConditionalOnClass({ ConnectionFactory.class, ActiveMQConnectionFactory.class }) @ConditionalOnMissingBean(ConnectionFactory.class) @EnableConfigurationProperties(ArtemisProperties.class) -@Import({ ArtemisXAConnectionFactoryConfiguration.class, +@Import({ ArtemisEmbeddedServerConfiguration.class, + ArtemisXAConnectionFactoryConfiguration.class, ArtemisConnectionFactoryConfiguration.class }) public class ArtemisAutoConfiguration { diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisAutoConfigurationTests.java index 47ab2506cb8..e4a047ef5c0 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisAutoConfigurationTests.java @@ -42,13 +42,11 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.springframework.boot.autoconfigure.jms.JmsAutoConfiguration; -import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.test.EnvironmentTestUtils; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; import org.springframework.jms.core.JmsTemplate; import org.springframework.jms.core.MessageCreator; import org.springframework.jms.core.SessionCallback; @@ -305,7 +303,7 @@ public class ArtemisAutoConfigurationTests { String... environment) { AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(); applicationContext.register(config); - applicationContext.register(ArtemisAutoConfigurationWithoutXA.class, + applicationContext.register(ArtemisAutoConfiguration.class, JmsAutoConfiguration.class); EnvironmentTestUtils.addEnvironment(applicationContext, environment); applicationContext.refresh(); @@ -413,12 +411,4 @@ public class ArtemisAutoConfigurationTests { } - @Configuration - @EnableConfigurationProperties(ArtemisProperties.class) - @Import({ ArtemisEmbeddedServerConfiguration.class, - ArtemisConnectionFactoryConfiguration.class }) - protected static class ArtemisAutoConfigurationWithoutXA { - - } - } diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQAutoConfigurationTests.java index 154c69bb590..5c760d33fec 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQAutoConfigurationTests.java @@ -42,13 +42,11 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.springframework.boot.autoconfigure.jms.JmsAutoConfiguration; -import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.test.EnvironmentTestUtils; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; import org.springframework.jms.core.JmsTemplate; import org.springframework.jms.core.MessageCreator; import org.springframework.jms.core.SessionCallback; @@ -319,7 +317,7 @@ public class HornetQAutoConfigurationTests { String... environment) { AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(); applicationContext.register(config); - applicationContext.register(HornetQAutoConfigurationWithoutXA.class, + applicationContext.register(HornetQAutoConfiguration.class, JmsAutoConfiguration.class); EnvironmentTestUtils.addEnvironment(applicationContext, environment); applicationContext.refresh(); @@ -417,11 +415,4 @@ public class HornetQAutoConfigurationTests { } } - @Configuration - @EnableConfigurationProperties(HornetQProperties.class) - @Import({ HornetQEmbeddedServerConfiguration.class, - HornetQConnectionFactoryConfiguration.class }) - protected static class HornetQAutoConfigurationWithoutXA { - } - }