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
This commit is contained in:
Stephane Nicoll 2015-10-19 11:46:15 +02:00
parent e72b14cb5f
commit fd525077bd
3 changed files with 5 additions and 22 deletions

View File

@ -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 {

View File

@ -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 {
}
}

View File

@ -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 {
}
}