Commit fd525077 authored by Stephane Nicoll's avatar Stephane Nicoll

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
parent e72b14cb
...@@ -37,6 +37,7 @@ import org.springframework.context.annotation.Import; ...@@ -37,6 +37,7 @@ import org.springframework.context.annotation.Import;
* settings. * settings.
* *
* @author Eddú Meléndez * @author Eddú Meléndez
* @author Stephane Nicoll
* @since 1.3.0 * @since 1.3.0
* @see ArtemisProperties * @see ArtemisProperties
*/ */
...@@ -46,7 +47,8 @@ import org.springframework.context.annotation.Import; ...@@ -46,7 +47,8 @@ import org.springframework.context.annotation.Import;
@ConditionalOnClass({ ConnectionFactory.class, ActiveMQConnectionFactory.class }) @ConditionalOnClass({ ConnectionFactory.class, ActiveMQConnectionFactory.class })
@ConditionalOnMissingBean(ConnectionFactory.class) @ConditionalOnMissingBean(ConnectionFactory.class)
@EnableConfigurationProperties(ArtemisProperties.class) @EnableConfigurationProperties(ArtemisProperties.class)
@Import({ ArtemisXAConnectionFactoryConfiguration.class, @Import({ ArtemisEmbeddedServerConfiguration.class,
ArtemisXAConnectionFactoryConfiguration.class,
ArtemisConnectionFactoryConfiguration.class }) ArtemisConnectionFactoryConfiguration.class })
public class ArtemisAutoConfiguration { public class ArtemisAutoConfiguration {
......
...@@ -42,13 +42,11 @@ import org.junit.Rule; ...@@ -42,13 +42,11 @@ import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.TemporaryFolder; import org.junit.rules.TemporaryFolder;
import org.springframework.boot.autoconfigure.jms.JmsAutoConfiguration; import org.springframework.boot.autoconfigure.jms.JmsAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.EnvironmentTestUtils; import org.springframework.boot.test.EnvironmentTestUtils;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.jms.core.JmsTemplate; import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator; import org.springframework.jms.core.MessageCreator;
import org.springframework.jms.core.SessionCallback; import org.springframework.jms.core.SessionCallback;
...@@ -305,7 +303,7 @@ public class ArtemisAutoConfigurationTests { ...@@ -305,7 +303,7 @@ public class ArtemisAutoConfigurationTests {
String... environment) { String... environment) {
AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
applicationContext.register(config); applicationContext.register(config);
applicationContext.register(ArtemisAutoConfigurationWithoutXA.class, applicationContext.register(ArtemisAutoConfiguration.class,
JmsAutoConfiguration.class); JmsAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(applicationContext, environment); EnvironmentTestUtils.addEnvironment(applicationContext, environment);
applicationContext.refresh(); applicationContext.refresh();
...@@ -413,12 +411,4 @@ public class ArtemisAutoConfigurationTests { ...@@ -413,12 +411,4 @@ public class ArtemisAutoConfigurationTests {
} }
@Configuration
@EnableConfigurationProperties(ArtemisProperties.class)
@Import({ ArtemisEmbeddedServerConfiguration.class,
ArtemisConnectionFactoryConfiguration.class })
protected static class ArtemisAutoConfigurationWithoutXA {
}
} }
...@@ -42,13 +42,11 @@ import org.junit.Rule; ...@@ -42,13 +42,11 @@ import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.TemporaryFolder; import org.junit.rules.TemporaryFolder;
import org.springframework.boot.autoconfigure.jms.JmsAutoConfiguration; import org.springframework.boot.autoconfigure.jms.JmsAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.EnvironmentTestUtils; import org.springframework.boot.test.EnvironmentTestUtils;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.jms.core.JmsTemplate; import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator; import org.springframework.jms.core.MessageCreator;
import org.springframework.jms.core.SessionCallback; import org.springframework.jms.core.SessionCallback;
...@@ -319,7 +317,7 @@ public class HornetQAutoConfigurationTests { ...@@ -319,7 +317,7 @@ public class HornetQAutoConfigurationTests {
String... environment) { String... environment) {
AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
applicationContext.register(config); applicationContext.register(config);
applicationContext.register(HornetQAutoConfigurationWithoutXA.class, applicationContext.register(HornetQAutoConfiguration.class,
JmsAutoConfiguration.class); JmsAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(applicationContext, environment); EnvironmentTestUtils.addEnvironment(applicationContext, environment);
applicationContext.refresh(); applicationContext.refresh();
...@@ -417,11 +415,4 @@ public class HornetQAutoConfigurationTests { ...@@ -417,11 +415,4 @@ public class HornetQAutoConfigurationTests {
} }
} }
@Configuration
@EnableConfigurationProperties(HornetQProperties.class)
@Import({ HornetQEmbeddedServerConfiguration.class,
HornetQConnectionFactoryConfiguration.class })
protected static class HornetQAutoConfigurationWithoutXA {
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment