From b129bc261ae47953994fdeb4e6536f2042ac4760 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Mon, 15 Sep 2014 12:28:55 -0700 Subject: [PATCH] Polish --- .../RabbitAnnotationDrivenConfiguration.java | 2 +- .../autoconfigure/orm/jpa/JpaProperties.java | 8 ++--- .../amqp/RabbitAutoConfigurationTests.java | 32 +++++++++++-------- .../boot/context/embedded/Ssl.java | 1 + 4 files changed, 24 insertions(+), 19 deletions(-) diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAnnotationDrivenConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAnnotationDrivenConfiguration.java index 7b8e6d4e04..83cca30d10 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAnnotationDrivenConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAnnotationDrivenConfiguration.java @@ -16,7 +16,6 @@ package org.springframework.boot.autoconfigure.amqp; - import org.springframework.amqp.rabbit.annotation.EnableRabbit; import org.springframework.amqp.rabbit.config.RabbitListenerConfigUtils; import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory; @@ -56,6 +55,7 @@ class RabbitAnnotationDrivenConfiguration { @EnableRabbit @ConditionalOnMissingBean(name = RabbitListenerConfigUtils.RABBIT_LISTENER_ANNOTATION_PROCESSOR_BEAN_NAME) protected static class EnableRabbitConfiguration { + } } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaProperties.java index 871fad9a3e..386c7498a0 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaProperties.java @@ -25,7 +25,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.boot.autoconfigure.jdbc.EmbeddedDatabaseConnection; 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.util.StringUtils; @@ -113,9 +112,9 @@ public class JpaProperties { 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; @@ -150,8 +149,7 @@ public class JpaProperties { result.put("hibernate.ejb.naming_strategy", this.namingStrategy.getName()); } else if (this.namingStrategy == null) { - result.put("hibernate.ejb.naming_strategy", - DEFAULT_NAMING_STRATEGY); + result.put("hibernate.ejb.naming_strategy", DEFAULT_NAMING_STRATEGY); } String ddlAuto = getOrDeduceDdlAuto(existing, dataSource); if (StringUtils.hasText(ddlAuto) && !"none".equals(ddlAuto)) { diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java index 973bb04dff..ccbbcd7a28 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java @@ -19,7 +19,6 @@ package org.springframework.boot.autoconfigure.amqp; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; - import org.springframework.amqp.core.AmqpAdmin; import org.springframework.amqp.rabbit.annotation.EnableRabbit; 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.Configuration; -import static org.junit.Assert.*; -import static org.mockito.Mockito.*; +import static org.junit.Assert.assertEquals; +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}. @@ -71,10 +73,9 @@ public class RabbitAutoConfigurationTests { @Test public void testRabbitTemplateWithOverrides() { - load(TestConfiguration.class, - "spring.rabbitmq.host:remote-server", "spring.rabbitmq.port:9000", - "spring.rabbitmq.username:alice", "spring.rabbitmq.password:secret", - "spring.rabbitmq.virtual_host:/vhost"); + load(TestConfiguration.class, "spring.rabbitmq.host:remote-server", + "spring.rabbitmq.port:9000", "spring.rabbitmq.username:alice", + "spring.rabbitmq.password:secret", "spring.rabbitmq.virtual_host:/vhost"); CachingConnectionFactory connectionFactory = this.context .getBean(CachingConnectionFactory.class); assertEquals("remote-server", connectionFactory.getHost()); @@ -129,13 +130,15 @@ public class RabbitAutoConfigurationTests { public void testRabbitTemplateBackOff() { load(TestConfiguration3.class); RabbitTemplate rabbitTemplate = this.context.getBean(RabbitTemplate.class); - assertEquals(this.context.getBean("testMessageConverter"), rabbitTemplate.getMessageConverter()); + assertEquals(this.context.getBean("testMessageConverter"), + rabbitTemplate.getMessageConverter()); } @Test public void testRabbitMessagingTemplateBackOff() { load(TestConfiguration4.class); - RabbitMessagingTemplate messagingTemplate = this.context.getBean(RabbitMessagingTemplate.class); + RabbitMessagingTemplate messagingTemplate = this.context + .getBean(RabbitMessagingTemplate.class); assertEquals("fooBar", messagingTemplate.getDefaultDestination()); } @@ -153,7 +156,8 @@ public class RabbitAutoConfigurationTests { public void testEnableRabbitCreateDefaultContainerFactory() { load(EnableRabbitConfiguration.class); RabbitListenerContainerFactory rabbitListenerContainerFactory = this.context - .getBean("rabbitListenerContainerFactory", RabbitListenerContainerFactory.class); + .getBean("rabbitListenerContainerFactory", + RabbitListenerContainerFactory.class); assertEquals(SimpleRabbitListenerContainerFactory.class, rabbitListenerContainerFactory.getClass()); } @@ -162,7 +166,8 @@ public class RabbitAutoConfigurationTests { public void testRabbitListenerContainerFactoryBackOff() { load(TestConfiguration5.class); SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory = this.context - .getBean("rabbitListenerContainerFactory", SimpleRabbitListenerContainerFactory.class); + .getBean("rabbitListenerContainerFactory", + SimpleRabbitListenerContainerFactory.class); rabbitListenerContainerFactory.setTxSize(10); verify(rabbitListenerContainerFactory).setTxSize(10); } @@ -176,7 +181,7 @@ public class RabbitAutoConfigurationTests { } 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, @@ -224,7 +229,8 @@ public class RabbitAutoConfigurationTests { @Bean RabbitMessagingTemplate messagingTemplate(RabbitTemplate rabbitTemplate) { - RabbitMessagingTemplate messagingTemplate = new RabbitMessagingTemplate(rabbitTemplate); + RabbitMessagingTemplate messagingTemplate = new RabbitMessagingTemplate( + rabbitTemplate); messagingTemplate.setDefaultDestination("fooBar"); return messagingTemplate; } diff --git a/spring-boot/src/main/java/org/springframework/boot/context/embedded/Ssl.java b/spring-boot/src/main/java/org/springframework/boot/context/embedded/Ssl.java index 1bed822222..cd1d18b6c3 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/embedded/Ssl.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/embedded/Ssl.java @@ -20,6 +20,7 @@ package org.springframework.boot.context.embedded; * Simple container-independent abstraction for SSL configuration. * * @author Andy Wilkinson + * @author Vladimir Tsanev * @since 1.2.0 */ public class Ssl {