pull/1652/head
Phillip Webb 10 years ago
parent 96dceb39a4
commit b129bc261a

@ -16,7 +16,6 @@
package org.springframework.boot.autoconfigure.amqp; package org.springframework.boot.autoconfigure.amqp;
import org.springframework.amqp.rabbit.annotation.EnableRabbit; import org.springframework.amqp.rabbit.annotation.EnableRabbit;
import org.springframework.amqp.rabbit.config.RabbitListenerConfigUtils; import org.springframework.amqp.rabbit.config.RabbitListenerConfigUtils;
import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory; import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
@ -56,6 +55,7 @@ class RabbitAnnotationDrivenConfiguration {
@EnableRabbit @EnableRabbit
@ConditionalOnMissingBean(name = RabbitListenerConfigUtils.RABBIT_LISTENER_ANNOTATION_PROCESSOR_BEAN_NAME) @ConditionalOnMissingBean(name = RabbitListenerConfigUtils.RABBIT_LISTENER_ANNOTATION_PROCESSOR_BEAN_NAME)
protected static class EnableRabbitConfiguration { protected static class EnableRabbitConfiguration {
} }
} }

@ -25,7 +25,6 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDatabaseConnection; import org.springframework.boot.autoconfigure.jdbc.EmbeddedDatabaseConnection;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.orm.jpa.hibernate.SpringNamingStrategy;
import org.springframework.orm.jpa.vendor.Database; import org.springframework.orm.jpa.vendor.Database;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@ -113,9 +112,9 @@ public class JpaProperties {
public static class Hibernate { public static class Hibernate {
private Class<?> namingStrategy; private static final String DEFAULT_NAMING_STRATEGY = "org.springframework.boot.orm.jpa.hibernate.SpringNamingStrategy";
private static String DEFAULT_NAMING_STRATEGY = "org.springframework.boot.orm.jpa.SpringNamingStrategy"; private Class<?> namingStrategy;
private String ddlAuto; private String ddlAuto;
@ -150,8 +149,7 @@ public class JpaProperties {
result.put("hibernate.ejb.naming_strategy", this.namingStrategy.getName()); result.put("hibernate.ejb.naming_strategy", this.namingStrategy.getName());
} }
else if (this.namingStrategy == null) { else if (this.namingStrategy == null) {
result.put("hibernate.ejb.naming_strategy", result.put("hibernate.ejb.naming_strategy", DEFAULT_NAMING_STRATEGY);
DEFAULT_NAMING_STRATEGY);
} }
String ddlAuto = getOrDeduceDdlAuto(existing, dataSource); String ddlAuto = getOrDeduceDdlAuto(existing, dataSource);
if (StringUtils.hasText(ddlAuto) && !"none".equals(ddlAuto)) { if (StringUtils.hasText(ddlAuto) && !"none".equals(ddlAuto)) {

@ -19,7 +19,6 @@ package org.springframework.boot.autoconfigure.amqp;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.ExpectedException; import org.junit.rules.ExpectedException;
import org.springframework.amqp.core.AmqpAdmin; import org.springframework.amqp.core.AmqpAdmin;
import org.springframework.amqp.rabbit.annotation.EnableRabbit; import org.springframework.amqp.rabbit.annotation.EnableRabbit;
import org.springframework.amqp.rabbit.config.RabbitListenerConfigUtils; import org.springframework.amqp.rabbit.config.RabbitListenerConfigUtils;
@ -37,8 +36,11 @@ 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 static org.junit.Assert.*; import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.*; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
/** /**
* Tests for {@link RabbitAutoConfiguration}. * Tests for {@link RabbitAutoConfiguration}.
@ -71,10 +73,9 @@ public class RabbitAutoConfigurationTests {
@Test @Test
public void testRabbitTemplateWithOverrides() { public void testRabbitTemplateWithOverrides() {
load(TestConfiguration.class, load(TestConfiguration.class, "spring.rabbitmq.host:remote-server",
"spring.rabbitmq.host:remote-server", "spring.rabbitmq.port:9000", "spring.rabbitmq.port:9000", "spring.rabbitmq.username:alice",
"spring.rabbitmq.username:alice", "spring.rabbitmq.password:secret", "spring.rabbitmq.password:secret", "spring.rabbitmq.virtual_host:/vhost");
"spring.rabbitmq.virtual_host:/vhost");
CachingConnectionFactory connectionFactory = this.context CachingConnectionFactory connectionFactory = this.context
.getBean(CachingConnectionFactory.class); .getBean(CachingConnectionFactory.class);
assertEquals("remote-server", connectionFactory.getHost()); assertEquals("remote-server", connectionFactory.getHost());
@ -129,13 +130,15 @@ public class RabbitAutoConfigurationTests {
public void testRabbitTemplateBackOff() { public void testRabbitTemplateBackOff() {
load(TestConfiguration3.class); load(TestConfiguration3.class);
RabbitTemplate rabbitTemplate = this.context.getBean(RabbitTemplate.class); RabbitTemplate rabbitTemplate = this.context.getBean(RabbitTemplate.class);
assertEquals(this.context.getBean("testMessageConverter"), rabbitTemplate.getMessageConverter()); assertEquals(this.context.getBean("testMessageConverter"),
rabbitTemplate.getMessageConverter());
} }
@Test @Test
public void testRabbitMessagingTemplateBackOff() { public void testRabbitMessagingTemplateBackOff() {
load(TestConfiguration4.class); load(TestConfiguration4.class);
RabbitMessagingTemplate messagingTemplate = this.context.getBean(RabbitMessagingTemplate.class); RabbitMessagingTemplate messagingTemplate = this.context
.getBean(RabbitMessagingTemplate.class);
assertEquals("fooBar", messagingTemplate.getDefaultDestination()); assertEquals("fooBar", messagingTemplate.getDefaultDestination());
} }
@ -153,7 +156,8 @@ public class RabbitAutoConfigurationTests {
public void testEnableRabbitCreateDefaultContainerFactory() { public void testEnableRabbitCreateDefaultContainerFactory() {
load(EnableRabbitConfiguration.class); load(EnableRabbitConfiguration.class);
RabbitListenerContainerFactory<?> rabbitListenerContainerFactory = this.context RabbitListenerContainerFactory<?> rabbitListenerContainerFactory = this.context
.getBean("rabbitListenerContainerFactory", RabbitListenerContainerFactory.class); .getBean("rabbitListenerContainerFactory",
RabbitListenerContainerFactory.class);
assertEquals(SimpleRabbitListenerContainerFactory.class, assertEquals(SimpleRabbitListenerContainerFactory.class,
rabbitListenerContainerFactory.getClass()); rabbitListenerContainerFactory.getClass());
} }
@ -162,7 +166,8 @@ public class RabbitAutoConfigurationTests {
public void testRabbitListenerContainerFactoryBackOff() { public void testRabbitListenerContainerFactoryBackOff() {
load(TestConfiguration5.class); load(TestConfiguration5.class);
SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory = this.context SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory = this.context
.getBean("rabbitListenerContainerFactory", SimpleRabbitListenerContainerFactory.class); .getBean("rabbitListenerContainerFactory",
SimpleRabbitListenerContainerFactory.class);
rabbitListenerContainerFactory.setTxSize(10); rabbitListenerContainerFactory.setTxSize(10);
verify(rabbitListenerContainerFactory).setTxSize(10); verify(rabbitListenerContainerFactory).setTxSize(10);
} }
@ -176,7 +181,7 @@ public class RabbitAutoConfigurationTests {
} }
private void load(Class<?> config, String... environment) { private void load(Class<?> config, String... environment) {
this.context = doLoad(new Class<?>[] {config}, environment); this.context = doLoad(new Class<?>[] { config }, environment);
} }
private AnnotationConfigApplicationContext doLoad(Class<?>[] configs, private AnnotationConfigApplicationContext doLoad(Class<?>[] configs,
@ -224,7 +229,8 @@ public class RabbitAutoConfigurationTests {
@Bean @Bean
RabbitMessagingTemplate messagingTemplate(RabbitTemplate rabbitTemplate) { RabbitMessagingTemplate messagingTemplate(RabbitTemplate rabbitTemplate) {
RabbitMessagingTemplate messagingTemplate = new RabbitMessagingTemplate(rabbitTemplate); RabbitMessagingTemplate messagingTemplate = new RabbitMessagingTemplate(
rabbitTemplate);
messagingTemplate.setDefaultDestination("fooBar"); messagingTemplate.setDefaultDestination("fooBar");
return messagingTemplate; return messagingTemplate;
} }

@ -20,6 +20,7 @@ package org.springframework.boot.context.embedded;
* Simple container-independent abstraction for SSL configuration. * Simple container-independent abstraction for SSL configuration.
* *
* @author Andy Wilkinson * @author Andy Wilkinson
* @author Vladimir Tsanev
* @since 1.2.0 * @since 1.2.0
*/ */
public class Ssl { public class Ssl {

Loading…
Cancel
Save