Polish
This commit is contained in:
parent
a1ac934bee
commit
6cdbdf9ad3
|
|
@ -45,7 +45,8 @@ import org.springframework.session.data.redis.config.annotation.web.http.RedisHt
|
|||
@Conditional(SessionCondition.class)
|
||||
class RedisSessionConfiguration {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(RedisSessionConfiguration.class);
|
||||
private static final Logger logger = LoggerFactory
|
||||
.getLogger(RedisSessionConfiguration.class);
|
||||
|
||||
@Configuration
|
||||
public static class SpringBootRedisHttpSessionConfiguration
|
||||
|
|
@ -68,8 +69,8 @@ class RedisSessionConfiguration {
|
|||
@PostConstruct
|
||||
public void validate() {
|
||||
if (this.sessionProperties.getStoreType() == null) {
|
||||
logger.warn("Spring Session store type is mandatory: set " +
|
||||
"'spring.session.store-type=redis' in your configuration");
|
||||
logger.warn("Spring Session store type is mandatory: set "
|
||||
+ "'spring.session.store-type=redis' in your configuration");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ import org.springframework.util.Assert;
|
|||
@EnableConfigurationProperties(SessionProperties.class)
|
||||
@AutoConfigureAfter({ DataSourceAutoConfiguration.class, HazelcastAutoConfiguration.class,
|
||||
MongoAutoConfiguration.class, RedisAutoConfiguration.class })
|
||||
@Import({ SessionConfigurationImportSelector.class, SessionRepositoryValidator.class})
|
||||
@Import({ SessionConfigurationImportSelector.class, SessionRepositoryValidator.class })
|
||||
public class SessionAutoConfiguration {
|
||||
|
||||
/**
|
||||
|
|
@ -82,6 +82,7 @@ public class SessionAutoConfiguration {
|
|||
static class SessionRepositoryValidator {
|
||||
|
||||
private SessionProperties sessionProperties;
|
||||
|
||||
private ObjectProvider<SessionRepository<?>> sessionRepositoryProvider;
|
||||
|
||||
SessionRepositoryValidator(SessionProperties sessionProperties,
|
||||
|
|
@ -95,9 +96,9 @@ public class SessionAutoConfiguration {
|
|||
StoreType storeType = this.sessionProperties.getStoreType();
|
||||
if (storeType != StoreType.NONE) {
|
||||
Assert.notNull(this.sessionRepositoryProvider.getIfAvailable(),
|
||||
"No session repository could "
|
||||
+ "be auto-configured, check your configuration (session "
|
||||
+ "store type is '" + storeType + "')");
|
||||
"No session repository could be auto-configured, check your "
|
||||
+ "configuration (session store type is '" + storeType
|
||||
+ "')");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,8 @@ import org.springframework.util.ClassUtils;
|
|||
class SessionCondition extends SpringBootCondition {
|
||||
|
||||
private static final boolean redisPresent = ClassUtils.isPresent(
|
||||
"org.springframework.data.redis.core.RedisTemplate", SessionCondition.class.getClassLoader());
|
||||
"org.springframework.data.redis.core.RedisTemplate",
|
||||
SessionCondition.class.getClassLoader());
|
||||
|
||||
@Override
|
||||
public ConditionOutcome getMatchOutcome(ConditionContext context,
|
||||
|
|
@ -43,11 +44,10 @@ class SessionCondition extends SpringBootCondition {
|
|||
.getType(((AnnotationMetadata) metadata).getClassName());
|
||||
if (!resolver.containsProperty("store-type")) {
|
||||
if (sessionStoreType == StoreType.REDIS && redisPresent) {
|
||||
return ConditionOutcome.match("Session store type default to redis (deprecated)");
|
||||
}
|
||||
else {
|
||||
return ConditionOutcome.noMatch("Session store type not set");
|
||||
return ConditionOutcome
|
||||
.match("Session store type default to redis (deprecated)");
|
||||
}
|
||||
return ConditionOutcome.noMatch("Session store type not set");
|
||||
}
|
||||
String value = resolver.getProperty("store-type").replace("-", "_").toUpperCase();
|
||||
if (value.equals(sessionStoreType.name())) {
|
||||
|
|
|
|||
|
|
@ -39,19 +39,18 @@ import static org.mockito.Mockito.mock;
|
|||
import static org.mockito.Mockito.verifyZeroInteractions;
|
||||
|
||||
/**
|
||||
* Test to validate that a custom {@link RestTemplate} can be defined
|
||||
* with OAuth2 SSO.
|
||||
* Test to validate that a custom {@link RestTemplate} can be defined with OAuth2 SSO.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@DirtiesContext
|
||||
@SpringBootTest
|
||||
@TestPropertySource(properties = {"security.oauth2.client.clientId=client",
|
||||
@TestPropertySource(properties = { "security.oauth2.client.clientId=client",
|
||||
"security.oauth2.client.clientSecret=secret",
|
||||
"security.oauth2.client.userAuthorizationUri=http://example.com/oauth/authorize",
|
||||
"security.oauth2.client.accessTokenUri=http://example.com/oauth/token",
|
||||
"security.oauth2.resource.jwt.keyValue=SSSSHHH"})
|
||||
"security.oauth2.resource.jwt.keyValue=SSSSHHH" })
|
||||
public class CustomRestTemplateBasicOAuth2SsoConfigurationTests {
|
||||
|
||||
@Autowired
|
||||
|
|
@ -82,5 +81,3 @@ public class CustomRestTemplateBasicOAuth2SsoConfigurationTests {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,6 @@ public class SessionAutoConfigurationTests extends AbstractSessionAutoConfigurat
|
|||
this.thrown.expect(BeanCreationException.class);
|
||||
this.thrown.expectMessage("No session repository could be auto-configured");
|
||||
this.thrown.expectMessage("session store type is 'null'");
|
||||
|
||||
load();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,4 +57,10 @@ public class TriggerFileFilterTests {
|
|||
assertThat(new TriggerFileFilter("thefile.txt").accept(file)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testName() throws Exception {
|
||||
File file = this.temp.newFile(".triggerfile").getAbsoluteFile();
|
||||
assertThat(new TriggerFileFilter(".triggerfile").accept(file)).isTrue();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ public class Review implements Serializable {
|
|||
@Enumerated(EnumType.ORDINAL)
|
||||
private Rating rating;
|
||||
|
||||
@Column(name= "CHECK_IN_DATE", nullable = false)
|
||||
@Column(name = "CHECK_IN_DATE", nullable = false)
|
||||
@Temporal(TemporalType.DATE)
|
||||
private Date checkInDate;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package sample.test;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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.stereotype.Service;
|
||||
|
||||
public class SampleTest {
|
||||
|
||||
@Test
|
||||
public void injection() throws Exception {
|
||||
new AnnotationConfigApplicationContext(Config.class).close();
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@Import(BeanC.class)
|
||||
static class Config {
|
||||
|
||||
@Bean
|
||||
public BeanA beanA() {
|
||||
return new BeanA();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public BeanB beanB() {
|
||||
return new BeanB();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public BeanC beanC() {
|
||||
return new BeanC();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static class BeanA {
|
||||
|
||||
}
|
||||
|
||||
static class BeanB extends BeanA {
|
||||
|
||||
}
|
||||
|
||||
@Service
|
||||
static class BeanC {
|
||||
|
||||
@Autowired
|
||||
public void setBeanA(BeanA xxx) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue