Skip to content

Commit f8a4df0

Browse files
committed
Polish
1 parent 544bc64 commit f8a4df0

File tree

12 files changed

+51
-48
lines changed

12 files changed

+51
-48
lines changed

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/rest/RepositoryRestMvcAutoConfiguration.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import org.springframework.boot.context.properties.ConfigurationProperties;
2424
import org.springframework.context.annotation.Bean;
2525
import org.springframework.context.annotation.Configuration;
26-
import org.springframework.context.annotation.Import;
2726
import org.springframework.data.rest.core.config.RepositoryRestConfiguration;
2827
import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration;
2928

@@ -33,12 +32,9 @@
3332
* <p>
3433
* Activates when the application is a web application and no
3534
* {@link RepositoryRestMvcConfiguration} is found.
36-
* </p>
3735
* <p>
38-
* Once in effect, the auto-configuration allows to configure any property
39-
* of {@link RepositoryRestConfiguration} using the {@code spring.data.rest}
40-
* prefix.
41-
* </p>
36+
* Once in effect, the auto-configuration allows to configure any property of
37+
* {@link RepositoryRestConfiguration} using the {@code spring.data.rest} prefix.
4238
*
4339
* @author Rob Winch
4440
* @author Stephane Nicoll
@@ -48,18 +44,17 @@
4844
@ConditionalOnWebApplication
4945
@ConditionalOnMissingBean(RepositoryRestMvcConfiguration.class)
5046
@ConditionalOnClass(RepositoryRestMvcConfiguration.class)
51-
@Import(RepositoryRestMvcAutoConfiguration.RepositoryRestMvcBootConfiguration.class)
5247
public class RepositoryRestMvcAutoConfiguration {
5348

49+
static class RepositoryRestMvcBootConfiguration extends
50+
RepositoryRestMvcConfiguration {
5451

55-
@Configuration
56-
static class RepositoryRestMvcBootConfiguration extends RepositoryRestMvcConfiguration {
57-
58-
@Override
5952
@Bean
6053
@ConfigurationProperties(prefix = "spring.data.rest")
54+
@Override
6155
public RepositoryRestConfiguration config() {
6256
return super.config();
6357
}
58+
6459
}
6560
}

spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/rest/RepositoryRestMvcAutoConfigurationTests.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
import org.junit.After;
2222
import org.junit.Test;
23-
2423
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
2524
import org.springframework.boot.autoconfigure.TestAutoConfigurationPackage;
2625
import org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration;
@@ -36,7 +35,8 @@
3635
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
3736
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
3837

39-
import static org.junit.Assert.*;
38+
import static org.junit.Assert.assertEquals;
39+
import static org.junit.Assert.assertNotNull;
4040

4141
/**
4242
* Tests for {@link RepositoryRestMvcAutoConfiguration}.
@@ -64,25 +64,26 @@ public void testDefaultRepositoryConfiguration() throws Exception {
6464
public void testWithCustomBaseUri() throws Exception {
6565
load(TestConfiguration.class, "spring.data.rest.baseUri:foo");
6666
assertNotNull(this.context.getBean(RepositoryRestMvcConfiguration.class));
67-
RepositoryRestConfiguration bean = this.context.getBean(RepositoryRestConfiguration.class);
67+
RepositoryRestConfiguration bean = this.context
68+
.getBean(RepositoryRestConfiguration.class);
6869
assertEquals("Custom baseURI not set", URI.create("foo"), bean.getBaseUri());
6970
}
7071

7172
@Test
7273
public void backOffWithCustomConfiguration() {
7374
load(TestConfigurationWithRestMvcConfig.class, "spring.data.rest.baseUri:foo");
7475
assertNotNull(this.context.getBean(RepositoryRestMvcConfiguration.class));
75-
RepositoryRestConfiguration bean = this.context.getBean(RepositoryRestConfiguration.class);
76-
assertEquals("Custom base URI should not have been set", URI.create(""), bean.getBaseUri());
76+
RepositoryRestConfiguration bean = this.context
77+
.getBean(RepositoryRestConfiguration.class);
78+
assertEquals("Custom base URI should not have been set", URI.create(""),
79+
bean.getBaseUri());
7780

7881
}
7982

80-
private void load(Class<?> config,
81-
String... environment) {
83+
private void load(Class<?> config, String... environment) {
8284
AnnotationConfigWebApplicationContext applicationContext = new AnnotationConfigWebApplicationContext();
8385
applicationContext.setServletContext(new MockServletContext());
84-
applicationContext.register(config,
85-
EmbeddedDataSourceConfiguration.class,
86+
applicationContext.register(config, EmbeddedDataSourceConfiguration.class,
8687
HibernateJpaAutoConfiguration.class,
8788
JpaRepositoriesAutoConfiguration.class,
8889
PropertyPlaceholderAutoConfiguration.class,
@@ -99,7 +100,7 @@ protected static class TestConfiguration {
99100

100101
}
101102

102-
@Import({TestConfiguration.class, RepositoryRestMvcConfiguration.class})
103+
@Import({ TestConfiguration.class, RepositoryRestMvcConfiguration.class })
103104
protected static class TestConfigurationWithRestMvcConfig {
104105

105106
}

spring-boot-cli/samples/jms.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@ class JmsExample implements CommandLineRunner {
2828
log.info "Received ${message}"
2929
latch.countDown()
3030
}
31-
}
31+
32+
}
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import org.codehaus.groovy.ast.ClassNode;
2020
import org.codehaus.groovy.control.CompilationFailedException;
2121
import org.codehaus.groovy.control.customizers.ImportCustomizer;
22-
2322
import org.springframework.boot.cli.compiler.AstUtils;
2423
import org.springframework.boot.cli.compiler.CompilerAutoConfiguration;
2524
import org.springframework.boot.cli.compiler.DependencyCustomizer;
@@ -30,7 +29,7 @@
3029
* @author Stephane Nicoll
3130
* @since 1.2.0
3231
*/
33-
public class CachingAutoConfiguration extends CompilerAutoConfiguration {
32+
public class CachingCompilerAutoConfiguration extends CompilerAutoConfiguration {
3433

3534
@Override
3635
public boolean matches(ClassNode classNode) {
@@ -41,13 +40,13 @@ public boolean matches(ClassNode classNode) {
4140
public void applyDependencies(DependencyCustomizer dependencies)
4241
throws CompilationFailedException {
4342
dependencies.add("spring-context-support");
44-
4543
}
4644

4745
@Override
4846
public void applyImports(ImportCustomizer imports) throws CompilationFailedException {
4947
imports.addStarImports("org.springframework.cache",
50-
"org.springframework.cache.annotation", "org.springframework.cache.concurrent");
48+
"org.springframework.cache.annotation",
49+
"org.springframework.cache.concurrent");
5150
}
5251

5352
}

spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/JmsCompilerAutoConfiguration.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import org.springframework.boot.cli.compiler.AstUtils;
2323
import org.springframework.boot.cli.compiler.CompilerAutoConfiguration;
2424
import org.springframework.boot.cli.compiler.DependencyCustomizer;
25-
import org.springframework.boot.groovy.EnableJmsMessaging;
2625

2726
/**
2827
* {@link CompilerAutoConfiguration} for Spring JMS.
@@ -34,26 +33,25 @@ public class JmsCompilerAutoConfiguration extends CompilerAutoConfiguration {
3433

3534
@Override
3635
public boolean matches(ClassNode classNode) {
37-
return AstUtils.hasAtLeastOneAnnotation(classNode, "EnableJms") ||
38-
AstUtils.hasAtLeastOneAnnotation(classNode, "EnableJmsMessaging");
36+
return AstUtils.hasAtLeastOneAnnotation(classNode, "EnableJms")
37+
|| AstUtils.hasAtLeastOneAnnotation(classNode, "EnableJmsMessaging");
3938
}
4039

4140
@Override
4241
public void applyDependencies(DependencyCustomizer dependencies)
4342
throws CompilationFailedException {
4443
dependencies.add("spring-jms", "jms-api");
45-
4644
}
4745

4846
@Override
47+
@SuppressWarnings("deprecation")
4948
public void applyImports(ImportCustomizer imports) throws CompilationFailedException {
50-
imports.addStarImports("javax.jms",
51-
"org.springframework.jms.annotation",
52-
"org.springframework.jms.config",
53-
"org.springframework.jms.core",
49+
imports.addStarImports("javax.jms", "org.springframework.jms.annotation",
50+
"org.springframework.jms.config", "org.springframework.jms.core",
5451
"org.springframework.jms.listener",
55-
"org.springframework.jms.listener.adapter")
56-
.addImports(EnableJmsMessaging.class.getCanonicalName());
52+
"org.springframework.jms.listener.adapter").addImports(
53+
org.springframework.boot.groovy.EnableJmsMessaging.class
54+
.getCanonicalName());
5755
}
5856

5957
}

spring-boot-cli/src/main/resources/META-INF/services/org.springframework.boot.cli.compiler.CompilerAutoConfiguration

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ org.springframework.boot.cli.compiler.autoconfigure.SpringMvcCompilerAutoConfigu
44
org.springframework.boot.cli.compiler.autoconfigure.SpringBatchCompilerAutoConfiguration
55
org.springframework.boot.cli.compiler.autoconfigure.RabbitCompilerAutoConfiguration
66
org.springframework.boot.cli.compiler.autoconfigure.ReactorCompilerAutoConfiguration
7-
org.springframework.boot.cli.compiler.autoconfigure.CachingAutoConfiguration
7+
org.springframework.boot.cli.compiler.autoconfigure.CachingCompilerAutoConfiguration
88
org.springframework.boot.cli.compiler.autoconfigure.JdbcCompilerAutoConfiguration
99
org.springframework.boot.cli.compiler.autoconfigure.JmsCompilerAutoConfiguration
1010
org.springframework.boot.cli.compiler.autoconfigure.JUnitCompilerAutoConfiguration
@@ -17,4 +17,4 @@ org.springframework.boot.cli.compiler.autoconfigure.SpringSocialFacebookCompiler
1717
org.springframework.boot.cli.compiler.autoconfigure.SpringSocialLinkedInCompilerAutoConfiguration
1818
org.springframework.boot.cli.compiler.autoconfigure.SpringSocialTwitterCompilerAutoConfiguration
1919
org.springframework.boot.cli.compiler.autoconfigure.SpringTestCompilerAutoConfiguration
20-
org.springframework.boot.cli.compiler.autoconfigure.SpringWebsocketCompilerAutoConfiguration
20+
org.springframework.boot.cli.compiler.autoconfigure.SpringWebsocketCompilerAutoConfiguration

spring-boot-cli/src/test/java/org/springframework/boot/cli/GrabCommandIntegrationTests.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
import org.springframework.boot.cli.command.grab.GrabCommand;
2828
import org.springframework.util.FileSystemUtils;
2929

30+
import static org.hamcrest.Matchers.containsString;
31+
import static org.junit.Assert.assertThat;
3032
import static org.junit.Assert.assertTrue;
3133
import static org.junit.Assert.fail;
3234

@@ -68,8 +70,9 @@ public void duplicateGrabMetadataAnnotationsProducesAnError() throws Exception {
6870
this.cli.grab("duplicateGrabMetadata.groovy");
6971
fail();
7072
}
71-
catch (Exception e) {
72-
assertTrue(e.getMessage().contains("Duplicate @GrabMetadata annotation"));
73+
catch (Exception ex) {
74+
assertThat(ex.getMessage(),
75+
containsString("Duplicate @GrabMetadata annotation"));
7376
}
7477
}
7578

spring-boot-cli/src/test/java/org/springframework/boot/cli/ReproIntegrationTests.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,4 @@ public void jmsListener() throws Exception {
7979
assertThat(this.cli.getOutput(), containsString("Hello World"));
8080
}
8181

82-
@Test
83-
public void caching() throws Exception {
84-
this.cli.run("caching.groovy");
85-
assertThat(this.cli.getOutput(), containsString("Hello World"));
86-
}
8782
}

spring-boot-cli/src/test/java/org/springframework/boot/cli/SampleIntegrationTests.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
import org.junit.Rule;
2525
import org.junit.Test;
2626

27+
import static org.hamcrest.Matchers.containsString;
2728
import static org.junit.Assert.assertEquals;
29+
import static org.junit.Assert.assertThat;
2830
import static org.junit.Assert.assertTrue;
2931

3032
/**
@@ -156,4 +158,10 @@ public void deviceSample() throws Exception {
156158
assertEquals("Hello Normal Device!", this.cli.getHttpOutput());
157159
}
158160

161+
@Test
162+
public void caching() throws Exception {
163+
this.cli.run("caching.groovy");
164+
assertThat(this.cli.getOutput(), containsString("Hello World"));
165+
}
166+
159167
}

0 commit comments

Comments
 (0)