Skip to content

Commit e14afd6

Browse files
committed
Polish
1 parent d8b6d9a commit e14afd6

File tree

9 files changed

+121
-20
lines changed

9 files changed

+121
-20
lines changed

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/RedisSessionConfiguration.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
@Conditional(SessionCondition.class)
4646
class RedisSessionConfiguration {
4747

48-
private static final Logger logger = LoggerFactory.getLogger(RedisSessionConfiguration.class);
48+
private static final Logger logger = LoggerFactory
49+
.getLogger(RedisSessionConfiguration.class);
4950

5051
@Configuration
5152
public static class SpringBootRedisHttpSessionConfiguration
@@ -68,8 +69,8 @@ public void customize(SessionProperties sessionProperties) {
6869
@PostConstruct
6970
public void validate() {
7071
if (this.sessionProperties.getStoreType() == null) {
71-
logger.warn("Spring Session store type is mandatory: set " +
72-
"'spring.session.store-type=redis' in your configuration");
72+
logger.warn("Spring Session store type is mandatory: set "
73+
+ "'spring.session.store-type=redis' in your configuration");
7374
}
7475
}
7576

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/SessionAutoConfiguration.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
@EnableConfigurationProperties(SessionProperties.class)
5656
@AutoConfigureAfter({ DataSourceAutoConfiguration.class, HazelcastAutoConfiguration.class,
5757
MongoAutoConfiguration.class, RedisAutoConfiguration.class })
58-
@Import({ SessionConfigurationImportSelector.class, SessionRepositoryValidator.class})
58+
@Import({ SessionConfigurationImportSelector.class, SessionRepositoryValidator.class })
5959
public class SessionAutoConfiguration {
6060

6161
/**
@@ -82,6 +82,7 @@ public String[] selectImports(AnnotationMetadata importingClassMetadata) {
8282
static class SessionRepositoryValidator {
8383

8484
private SessionProperties sessionProperties;
85+
8586
private ObjectProvider<SessionRepository<?>> sessionRepositoryProvider;
8687

8788
SessionRepositoryValidator(SessionProperties sessionProperties,
@@ -95,9 +96,9 @@ public void checkSessionRepository() {
9596
StoreType storeType = this.sessionProperties.getStoreType();
9697
if (storeType != StoreType.NONE) {
9798
Assert.notNull(this.sessionRepositoryProvider.getIfAvailable(),
98-
"No session repository could "
99-
+ "be auto-configured, check your configuration (session "
100-
+ "store type is '" + storeType + "')");
99+
"No session repository could be auto-configured, check your "
100+
+ "configuration (session store type is '" + storeType
101+
+ "')");
101102
}
102103
}
103104

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/SessionCondition.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
class SessionCondition extends SpringBootCondition {
3333

3434
private static final boolean redisPresent = ClassUtils.isPresent(
35-
"org.springframework.data.redis.core.RedisTemplate", SessionCondition.class.getClassLoader());
35+
"org.springframework.data.redis.core.RedisTemplate",
36+
SessionCondition.class.getClassLoader());
3637

3738
@Override
3839
public ConditionOutcome getMatchOutcome(ConditionContext context,
@@ -43,11 +44,10 @@ public ConditionOutcome getMatchOutcome(ConditionContext context,
4344
.getType(((AnnotationMetadata) metadata).getClassName());
4445
if (!resolver.containsProperty("store-type")) {
4546
if (sessionStoreType == StoreType.REDIS && redisPresent) {
46-
return ConditionOutcome.match("Session store type default to redis (deprecated)");
47-
}
48-
else {
49-
return ConditionOutcome.noMatch("Session store type not set");
47+
return ConditionOutcome
48+
.match("Session store type default to redis (deprecated)");
5049
}
50+
return ConditionOutcome.noMatch("Session store type not set");
5151
}
5252
String value = resolver.getProperty("store-type").replace("-", "_").toUpperCase();
5353
if (value.equals(sessionStoreType.name())) {

spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/sso/CustomRestTemplateBasicOAuth2SsoConfigurationTests.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,18 @@
3939
import static org.mockito.Mockito.verifyZeroInteractions;
4040

4141
/**
42-
* Test to validate that a custom {@link RestTemplate} can be defined
43-
* with OAuth2 SSO.
42+
* Test to validate that a custom {@link RestTemplate} can be defined with OAuth2 SSO.
4443
*
4544
* @author Stephane Nicoll
4645
*/
4746
@RunWith(SpringRunner.class)
4847
@DirtiesContext
4948
@SpringBootTest
50-
@TestPropertySource(properties = {"security.oauth2.client.clientId=client",
49+
@TestPropertySource(properties = { "security.oauth2.client.clientId=client",
5150
"security.oauth2.client.clientSecret=secret",
5251
"security.oauth2.client.userAuthorizationUri=http://example.com/oauth/authorize",
5352
"security.oauth2.client.accessTokenUri=http://example.com/oauth/token",
54-
"security.oauth2.resource.jwt.keyValue=SSSSHHH"})
53+
"security.oauth2.resource.jwt.keyValue=SSSSHHH" })
5554
public class CustomRestTemplateBasicOAuth2SsoConfigurationTests {
5655

5756
@Autowired
@@ -82,5 +81,3 @@ public RestTemplate myRestTemplate() {
8281
}
8382

8483
}
85-
86-

spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationTests.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ public void contextFailsIfStoreTypeNotSet() {
6464
this.thrown.expect(BeanCreationException.class);
6565
this.thrown.expectMessage("No session repository could be auto-configured");
6666
this.thrown.expectMessage("session store type is 'null'");
67-
6867
load();
6968
}
7069

spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/TriggerFileFilterTests.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,10 @@ public void doesNotAcceptNameMismatch() throws Exception {
5757
assertThat(new TriggerFileFilter("thefile.txt").accept(file)).isFalse();
5858
}
5959

60+
@Test
61+
public void testName() throws Exception {
62+
File file = this.temp.newFile(".triggerfile").getAbsoluteFile();
63+
assertThat(new TriggerFileFilter(".triggerfile").accept(file)).isTrue();
64+
}
65+
6066
}

spring-boot-samples/spring-boot-sample-hibernate4/src/main/java/sample/hibernate4/domain/Review.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public class Review implements Serializable {
5151
@Enumerated(EnumType.ORDINAL)
5252
private Rating rating;
5353

54-
@Column(name= "CHECK_IN_DATE", nullable = false)
54+
@Column(name = "CHECK_IN_DATE", nullable = false)
5555
@Temporal(TemporalType.DATE)
5656
private Date checkInDate;
5757

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Copyright 2012-2016 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package sample.test;
18+
19+
import org.junit.Test;
20+
21+
import org.springframework.beans.factory.annotation.Autowired;
22+
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
23+
import org.springframework.context.annotation.Bean;
24+
import org.springframework.context.annotation.Configuration;
25+
import org.springframework.context.annotation.Import;
26+
import org.springframework.stereotype.Service;
27+
28+
public class SampleTest {
29+
30+
@Test
31+
public void injection() throws Exception {
32+
new AnnotationConfigApplicationContext(Config.class).close();
33+
}
34+
35+
@Configuration
36+
@Import(BeanC.class)
37+
static class Config {
38+
39+
@Bean
40+
public BeanA beanA() {
41+
return new BeanA();
42+
}
43+
44+
@Bean
45+
public BeanB beanB() {
46+
return new BeanB();
47+
}
48+
49+
@Bean
50+
public BeanC beanC() {
51+
return new BeanC();
52+
}
53+
54+
}
55+
56+
static class BeanA {
57+
58+
}
59+
60+
static class BeanB extends BeanA {
61+
62+
}
63+
64+
@Service
65+
static class BeanC {
66+
67+
@Autowired
68+
public void setBeanA(BeanA xxx) {
69+
}
70+
71+
}
72+
73+
}

spring-boot-samples/spring-boot-sample-test/src/test/java/sample/test/SampleTestApplicationWebIntegrationTests.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@
2929
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
3030
import org.springframework.boot.test.mock.mockito.MockBean;
3131
import org.springframework.boot.test.web.client.TestRestTemplate;
32+
import org.springframework.context.annotation.Bean;
33+
import org.springframework.context.annotation.Configuration;
34+
import org.springframework.context.annotation.Import;
35+
import org.springframework.stereotype.Service;
3236
import org.springframework.test.context.junit4.SpringRunner;
37+
import org.springframework.web.client.RestTemplate;
3338

3439
import static org.mockito.BDDMockito.given;
3540

@@ -63,4 +68,23 @@ public void test() {
6368
this.restTemplate.getForEntity("/{username}/vehicle", String.class, "sframework");
6469
}
6570

71+
@Configuration
72+
@Import({ SampleTestApplication.class, MyService.class })
73+
static class Config {
74+
75+
@Bean
76+
public RestTemplate restTemplate() {
77+
return new RestTemplate();
78+
}
79+
80+
}
81+
82+
@Service
83+
static class MyService {
84+
85+
public MyService(RestTemplate xxx) {
86+
}
87+
88+
}
89+
6690
}

0 commit comments

Comments
 (0)