Reformat code using Eclipse Mars
This commit is contained in:
@@ -42,8 +42,8 @@ import org.springframework.util.StringUtils;
|
||||
* @since 1.3.0
|
||||
* @see BeanDefinition#setDependsOn(String[])
|
||||
*/
|
||||
public abstract class AbstractDependsOnBeanFactoryPostProcessor implements
|
||||
BeanFactoryPostProcessor {
|
||||
public abstract class AbstractDependsOnBeanFactoryPostProcessor
|
||||
implements BeanFactoryPostProcessor {
|
||||
|
||||
private final Class<?> beanClass;
|
||||
|
||||
@@ -74,9 +74,8 @@ public abstract class AbstractDependsOnBeanFactoryPostProcessor implements
|
||||
Set<String> names = new HashSet<String>();
|
||||
names.addAll(Arrays.asList(BeanFactoryUtils.beanNamesForTypeIncludingAncestors(
|
||||
beanFactory, this.beanClass, true, false)));
|
||||
for (String factoryBeanName : BeanFactoryUtils
|
||||
.beanNamesForTypeIncludingAncestors(beanFactory, this.factoryBeanClass,
|
||||
true, false)) {
|
||||
for (String factoryBeanName : BeanFactoryUtils.beanNamesForTypeIncludingAncestors(
|
||||
beanFactory, this.factoryBeanClass, true, false)) {
|
||||
names.add(BeanFactoryUtils.transformedBeanName(factoryBeanName));
|
||||
}
|
||||
return names;
|
||||
|
||||
@@ -71,7 +71,8 @@ public class EnableAutoConfigurationImportSelector implements DeferredImportSele
|
||||
public String[] selectImports(AnnotationMetadata metadata) {
|
||||
try {
|
||||
AnnotationAttributes attributes = getAttributes(metadata);
|
||||
List<String> configurations = getCandidateConfigurations(metadata, attributes);
|
||||
List<String> configurations = getCandidateConfigurations(metadata,
|
||||
attributes);
|
||||
configurations = removeDuplicates(configurations);
|
||||
Set<String> exclusions = getExclusions(metadata, attributes);
|
||||
configurations.removeAll(exclusions);
|
||||
@@ -93,8 +94,8 @@ public class EnableAutoConfigurationImportSelector implements DeferredImportSele
|
||||
*/
|
||||
protected AnnotationAttributes getAttributes(AnnotationMetadata metadata) {
|
||||
String name = getAnnotationClass().getName();
|
||||
AnnotationAttributes attributes = AnnotationAttributes.fromMap(metadata
|
||||
.getAnnotationAttributes(name, true));
|
||||
AnnotationAttributes attributes = AnnotationAttributes
|
||||
.fromMap(metadata.getAnnotationAttributes(name, true));
|
||||
Assert.notNull(attributes,
|
||||
"No auto-configuration attributes found. Is " + metadata.getClassName()
|
||||
+ " annotated with " + ClassUtils.getShortName(name) + "?");
|
||||
|
||||
@@ -87,9 +87,8 @@ public class MessageSourceAutoConfiguration {
|
||||
public MessageSource messageSource() {
|
||||
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
|
||||
if (StringUtils.hasText(this.basename)) {
|
||||
messageSource.setBasenames(StringUtils
|
||||
.commaDelimitedListToStringArray(StringUtils
|
||||
.trimAllWhitespace(this.basename)));
|
||||
messageSource.setBasenames(StringUtils.commaDelimitedListToStringArray(
|
||||
StringUtils.trimAllWhitespace(this.basename)));
|
||||
}
|
||||
if (this.encoding != null) {
|
||||
messageSource.setDefaultEncoding(this.encoding.name());
|
||||
@@ -138,8 +137,8 @@ public class MessageSourceAutoConfiguration {
|
||||
@Override
|
||||
public ConditionOutcome getMatchOutcome(ConditionContext context,
|
||||
AnnotatedTypeMetadata metadata) {
|
||||
String basename = context.getEnvironment().getProperty(
|
||||
"spring.messages.basename", "messages");
|
||||
String basename = context.getEnvironment()
|
||||
.getProperty("spring.messages.basename", "messages");
|
||||
ConditionOutcome outcome = cache.get(basename);
|
||||
if (outcome == null) {
|
||||
outcome = getMatchOutcomeForBasename(context, basename);
|
||||
@@ -150,8 +149,8 @@ public class MessageSourceAutoConfiguration {
|
||||
|
||||
private ConditionOutcome getMatchOutcomeForBasename(ConditionContext context,
|
||||
String basename) {
|
||||
for (String name : StringUtils.commaDelimitedListToStringArray(StringUtils
|
||||
.trimAllWhitespace(basename))) {
|
||||
for (String name : StringUtils.commaDelimitedListToStringArray(
|
||||
StringUtils.trimAllWhitespace(basename))) {
|
||||
for (Resource resource : getResources(context.getClassLoader(), name)) {
|
||||
if (resource.exists()) {
|
||||
return ConditionOutcome.match("Bundle found for "
|
||||
@@ -159,8 +158,8 @@ public class MessageSourceAutoConfiguration {
|
||||
}
|
||||
}
|
||||
}
|
||||
return ConditionOutcome.noMatch("No bundle found for "
|
||||
+ "spring.messages.basename: " + basename);
|
||||
return ConditionOutcome.noMatch(
|
||||
"No bundle found for " + "spring.messages.basename: " + basename);
|
||||
}
|
||||
|
||||
private Resource[] getResources(ClassLoader classLoader, String name) {
|
||||
@@ -179,10 +178,11 @@ public class MessageSourceAutoConfiguration {
|
||||
* {@link PathMatchingResourcePatternResolver} that skips well known JARs that don't
|
||||
* contain messages.properties.
|
||||
*/
|
||||
private static class SkipPatternPathMatchingResourcePatternResolver extends
|
||||
PathMatchingResourcePatternResolver {
|
||||
private static class SkipPatternPathMatchingResourcePatternResolver
|
||||
extends PathMatchingResourcePatternResolver {
|
||||
|
||||
private static final ClassLoader ROOT_CLASSLOADER;
|
||||
|
||||
static {
|
||||
ClassLoader classLoader = null;
|
||||
try {
|
||||
@@ -223,7 +223,8 @@ public class MessageSourceAutoConfiguration {
|
||||
protected Set<Resource> doFindAllClassPathResources(String path)
|
||||
throws IOException {
|
||||
Set<Resource> resources = super.doFindAllClassPathResources(path);
|
||||
for (Iterator<Resource> iterator = resources.iterator(); iterator.hasNext();) {
|
||||
for (Iterator<Resource> iterator = resources.iterator(); iterator
|
||||
.hasNext();) {
|
||||
Resource resource = iterator.next();
|
||||
for (String skipped : SKIPPED) {
|
||||
if (resource.getFilename().startsWith(skipped)) {
|
||||
|
||||
@@ -62,8 +62,8 @@ public class SpringApplicationAdminJmxAutoConfiguration {
|
||||
@Bean
|
||||
public SpringApplicationAdminMXBeanRegistrar springApplicationAdminRegistrar()
|
||||
throws MalformedObjectNameException {
|
||||
String jmxName = this.environment
|
||||
.getProperty(JMX_NAME_PROPERTY, DEFAULT_JMX_NAME);
|
||||
String jmxName = this.environment.getProperty(JMX_NAME_PROPERTY,
|
||||
DEFAULT_JMX_NAME);
|
||||
if (this.mbeanExporter != null) { // Make sure to not register that MBean twice
|
||||
this.mbeanExporter.addExcludedBean(jmxName);
|
||||
}
|
||||
|
||||
@@ -112,9 +112,9 @@ public class BatchAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(JobOperator.class)
|
||||
public SimpleJobOperator jobOperator(JobExplorer jobExplorer,
|
||||
JobLauncher jobLauncher, ListableJobLocator jobRegistry,
|
||||
JobRepository jobRepository) throws Exception {
|
||||
public SimpleJobOperator jobOperator(JobExplorer jobExplorer, JobLauncher jobLauncher,
|
||||
ListableJobLocator jobRegistry, JobRepository jobRepository)
|
||||
throws Exception {
|
||||
SimpleJobOperator factory = new SimpleJobOperator();
|
||||
factory.setJobExplorer(jobExplorer);
|
||||
factory.setJobLauncher(jobLauncher);
|
||||
|
||||
@@ -87,8 +87,8 @@ public class CacheAutoConfiguration {
|
||||
for (String name : beanFactory.getBeanNamesForType(CacheAspectSupport.class,
|
||||
false, false)) {
|
||||
BeanDefinition definition = beanFactory.getBeanDefinition(name);
|
||||
definition.setDependsOn(append(definition.getDependsOn(),
|
||||
VALIDATOR_BEAN_NAME));
|
||||
definition.setDependsOn(
|
||||
append(definition.getDependsOn(), VALIDATOR_BEAN_NAME));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,9 +116,10 @@ public class CacheAutoConfiguration {
|
||||
|
||||
@PostConstruct
|
||||
public void checkHasCacheManager() {
|
||||
Assert.notNull(this.cacheManager, "No cache manager could "
|
||||
+ "be auto-configured, check your configuration (caching "
|
||||
+ "type is '" + this.cacheProperties.getType() + "')");
|
||||
Assert.notNull(this.cacheManager,
|
||||
"No cache manager could "
|
||||
+ "be auto-configured, check your configuration (caching "
|
||||
+ "type is '" + this.cacheProperties.getType() + "')");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,8 +40,8 @@ class CacheCondition extends SpringBootCondition {
|
||||
if (!resolver.containsProperty("type")) {
|
||||
return ConditionOutcome.match("Automatic cache type");
|
||||
}
|
||||
CacheType cacheType = CacheConfigurations.getType(((AnnotationMetadata) metadata)
|
||||
.getClassName());
|
||||
CacheType cacheType = CacheConfigurations
|
||||
.getType(((AnnotationMetadata) metadata).getClassName());
|
||||
String value = resolver.getProperty("type").replace("-", "_").toUpperCase();
|
||||
if (value.equals(cacheType.name())) {
|
||||
return ConditionOutcome.match("Cache type " + cacheType);
|
||||
|
||||
@@ -33,6 +33,7 @@ final class CacheConfigurations {
|
||||
}
|
||||
|
||||
private static final Map<CacheType, Class<?>> MAPPINGS;
|
||||
|
||||
static {
|
||||
Map<CacheType, Class<?>> mappings = new HashMap<CacheType, Class<?>>();
|
||||
mappings.put(CacheType.GENERIC, GenericCacheConfiguration.class);
|
||||
@@ -59,8 +60,8 @@ final class CacheConfigurations {
|
||||
return entry.getKey();
|
||||
}
|
||||
}
|
||||
throw new IllegalStateException("Unknown configuration class "
|
||||
+ configurationClassName);
|
||||
throw new IllegalStateException(
|
||||
"Unknown configuration class " + configurationClassName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -89,8 +89,8 @@ class JCacheCacheConfiguration {
|
||||
}
|
||||
|
||||
private CacheManager createCacheManager() throws IOException {
|
||||
CachingProvider cachingProvider = getCachingProvider(this.cacheProperties
|
||||
.getJcache().getProvider());
|
||||
CachingProvider cachingProvider = getCachingProvider(
|
||||
this.cacheProperties.getJcache().getProvider());
|
||||
Resource configLocation = this.cacheProperties
|
||||
.resolveConfigLocation(this.cacheProperties.getJcache().getConfig());
|
||||
if (configLocation != null) {
|
||||
@@ -112,8 +112,8 @@ class JCacheCacheConfiguration {
|
||||
throws IOException {
|
||||
Properties properties = new Properties();
|
||||
// Hazelcast does not use the URI as a mean to specify a custom config.
|
||||
properties.setProperty("hazelcast.config.location", configLocation.getURI()
|
||||
.toString());
|
||||
properties.setProperty("hazelcast.config.location",
|
||||
configLocation.getURI().toString());
|
||||
return properties;
|
||||
}
|
||||
|
||||
@@ -178,8 +178,8 @@ class JCacheCacheConfiguration {
|
||||
}
|
||||
providers.next();
|
||||
if (providers.hasNext()) {
|
||||
return ConditionOutcome.noMatch("Multiple default JSR-107 compliant "
|
||||
+ "providers found");
|
||||
return ConditionOutcome.noMatch(
|
||||
"Multiple default JSR-107 compliant " + "providers found");
|
||||
|
||||
}
|
||||
return ConditionOutcome.match("Default JSR-107 compliant provider found.");
|
||||
|
||||
@@ -42,8 +42,8 @@ import org.springframework.util.StringUtils;
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
abstract class AbstractNestedCondition extends SpringBootCondition implements
|
||||
ConfigurationCondition {
|
||||
abstract class AbstractNestedCondition extends SpringBootCondition
|
||||
implements ConfigurationCondition {
|
||||
|
||||
private final ConfigurationPhase configurationPhase;
|
||||
|
||||
|
||||
@@ -47,10 +47,11 @@ public abstract class AllNestedConditions extends AbstractNestedCondition {
|
||||
|
||||
@Override
|
||||
protected ConditionOutcome getFinalMatchOutcome(MemberMatchOutcomes memberOutcomes) {
|
||||
return new ConditionOutcome(memberOutcomes.getMatches().size() == memberOutcomes
|
||||
.getAll().size(), "nested all match resulted in "
|
||||
+ memberOutcomes.getMatches() + " matches and "
|
||||
+ memberOutcomes.getNonMatches() + " non matches");
|
||||
return new ConditionOutcome(
|
||||
memberOutcomes.getMatches().size() == memberOutcomes.getAll().size(),
|
||||
"nested all match resulted in " + memberOutcomes.getMatches()
|
||||
+ " matches and " + memberOutcomes.getNonMatches()
|
||||
+ " non matches");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -84,19 +84,19 @@ class OnBeanCondition extends SpringBootCondition implements ConfigurationCondit
|
||||
ConditionalOnBean.class);
|
||||
List<String> matching = getMatchingBeans(context, spec);
|
||||
if (matching.isEmpty()) {
|
||||
return ConditionOutcome.noMatch("@ConditionalOnBean " + spec
|
||||
+ " found no beans");
|
||||
return ConditionOutcome
|
||||
.noMatch("@ConditionalOnBean " + spec + " found no beans");
|
||||
}
|
||||
matchMessage.append("@ConditionalOnBean " + spec + " found the following "
|
||||
+ matching);
|
||||
matchMessage.append(
|
||||
"@ConditionalOnBean " + spec + " found the following " + matching);
|
||||
}
|
||||
if (metadata.isAnnotated(ConditionalOnSingleCandidate.class.getName())) {
|
||||
BeanSearchSpec spec = new SingleCandidateBeanSearchSpec(context, metadata,
|
||||
ConditionalOnSingleCandidate.class);
|
||||
List<String> matching = getMatchingBeans(context, spec);
|
||||
if (matching.isEmpty()) {
|
||||
return ConditionOutcome.noMatch("@ConditionalOnSingleCandidate " + spec
|
||||
+ " found no beans");
|
||||
return ConditionOutcome.noMatch(
|
||||
"@ConditionalOnSingleCandidate " + spec + " found no beans");
|
||||
}
|
||||
else if (!hasSingleAutowireCandidate(context.getBeanFactory(), matching)) {
|
||||
return ConditionOutcome.noMatch("@ConditionalOnSingleCandidate " + spec
|
||||
@@ -120,7 +120,8 @@ class OnBeanCondition extends SpringBootCondition implements ConfigurationCondit
|
||||
return ConditionOutcome.match(matchMessage.toString());
|
||||
}
|
||||
|
||||
private List<String> getMatchingBeans(ConditionContext context, BeanSearchSpec beans) {
|
||||
private List<String> getMatchingBeans(ConditionContext context,
|
||||
BeanSearchSpec beans) {
|
||||
ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
|
||||
if (beans.getStrategy() == SearchStrategy.PARENTS) {
|
||||
BeanFactory parent = beanFactory.getParentBeanFactory();
|
||||
@@ -163,7 +164,7 @@ class OnBeanCondition extends SpringBootCondition implements ConfigurationCondit
|
||||
|
||||
private Collection<String> getBeanNamesForType(ListableBeanFactory beanFactory,
|
||||
String type, ClassLoader classLoader, boolean considerHierarchy)
|
||||
throws LinkageError {
|
||||
throws LinkageError {
|
||||
try {
|
||||
Set<String> result = new LinkedHashSet<String>();
|
||||
collectBeanNamesForType(result, beanFactory,
|
||||
@@ -198,7 +199,8 @@ class OnBeanCondition extends SpringBootCondition implements ConfigurationCondit
|
||||
.forName(type, classLoader);
|
||||
result = beanFactory.getBeanNamesForAnnotation(typeClass);
|
||||
if (considerHierarchy) {
|
||||
if (beanFactory.getParentBeanFactory() instanceof ConfigurableListableBeanFactory) {
|
||||
if (beanFactory
|
||||
.getParentBeanFactory() instanceof ConfigurableListableBeanFactory) {
|
||||
String[] parentResult = getBeanNamesForAnnotation(
|
||||
(ConfigurableListableBeanFactory) beanFactory
|
||||
.getParentBeanFactory(),
|
||||
@@ -223,7 +225,8 @@ class OnBeanCondition extends SpringBootCondition implements ConfigurationCondit
|
||||
|
||||
private boolean hasSingleAutowireCandidate(
|
||||
ConfigurableListableBeanFactory beanFactory, List<String> beanNames) {
|
||||
return (beanNames.size() == 1 || getPrimaryBeans(beanFactory, beanNames).size() == 1);
|
||||
return (beanNames.size() == 1
|
||||
|| getPrimaryBeans(beanFactory, beanNames).size() == 1);
|
||||
}
|
||||
|
||||
private List<String> getPrimaryBeans(ConfigurableListableBeanFactory beanFactory,
|
||||
@@ -266,8 +269,8 @@ class OnBeanCondition extends SpringBootCondition implements ConfigurationCondit
|
||||
if (this.types.isEmpty() && this.names.isEmpty()) {
|
||||
addDeducedBeanType(context, metadata, this.types);
|
||||
}
|
||||
this.strategy = (SearchStrategy) metadata.getAnnotationAttributes(
|
||||
annotationType.getName()).get("search");
|
||||
this.strategy = (SearchStrategy) metadata
|
||||
.getAnnotationAttributes(annotationType.getName()).get("search");
|
||||
validate();
|
||||
}
|
||||
|
||||
@@ -324,8 +327,8 @@ class OnBeanCondition extends SpringBootCondition implements ConfigurationCondit
|
||||
methodMetadata.getDeclaringClassName(), context.getClassLoader());
|
||||
ReflectionUtils.doWithMethods(configClass, new MethodCallback() {
|
||||
@Override
|
||||
public void doWith(Method method) throws IllegalArgumentException,
|
||||
IllegalAccessException {
|
||||
public void doWith(Method method)
|
||||
throws IllegalArgumentException, IllegalAccessException {
|
||||
if (methodMetadata.getMethodName().equals(method.getName())) {
|
||||
beanTypes.add(method.getReturnType().getName());
|
||||
}
|
||||
@@ -335,10 +338,9 @@ class OnBeanCondition extends SpringBootCondition implements ConfigurationCondit
|
||||
catch (Throwable ex) {
|
||||
// swallow exception and continue
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(
|
||||
"Unable to deduce bean type for "
|
||||
+ methodMetadata.getDeclaringClassName() + "."
|
||||
+ methodMetadata.getMethodName(), ex);
|
||||
logger.debug("Unable to deduce bean type for "
|
||||
+ methodMetadata.getDeclaringClassName() + "."
|
||||
+ methodMetadata.getMethodName(), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,8 +50,10 @@ class OnResourceCondition extends SpringBootCondition {
|
||||
Assert.isTrue(locations.size() > 0,
|
||||
"@ConditionalOnResource annotations must specify at least one resource location");
|
||||
for (String location : locations) {
|
||||
if (!loader.getResource(
|
||||
context.getEnvironment().resolvePlaceholders(location)).exists()) {
|
||||
if (!loader
|
||||
.getResource(
|
||||
context.getEnvironment().resolvePlaceholders(location))
|
||||
.exists()) {
|
||||
return ConditionOutcome.noMatch("resource not found: " + location);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,12 +78,12 @@ public abstract class ResourceCondition extends SpringBootCondition {
|
||||
for (String location : this.resourceLocations) {
|
||||
Resource resource = context.getResourceLoader().getResource(location);
|
||||
if (resource != null && resource.exists()) {
|
||||
return ConditionOutcome.match("Found " + this.name + " config in "
|
||||
+ resource);
|
||||
return ConditionOutcome
|
||||
.match("Found " + this.name + " config in " + resource);
|
||||
}
|
||||
}
|
||||
return ConditionOutcome.noMatch("No specific " + this.name
|
||||
+ " configuration found");
|
||||
return ConditionOutcome
|
||||
.noMatch("No specific " + this.name + " configuration found");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ import org.springframework.data.repository.config.RepositoryConfigurationExtensi
|
||||
* @author Eddú Meléndez
|
||||
* @since 1.3.0
|
||||
*/
|
||||
class CassandraRepositoriesAutoConfigureRegistrar extends
|
||||
AbstractRepositoryConfigurationSourceSupport {
|
||||
class CassandraRepositoriesAutoConfigureRegistrar
|
||||
extends AbstractRepositoryConfigurationSourceSupport {
|
||||
|
||||
@Override
|
||||
protected Class<? extends Annotation> getAnnotation() {
|
||||
|
||||
@@ -56,6 +56,7 @@ import org.springframework.util.StringUtils;
|
||||
public class ElasticsearchAutoConfiguration implements DisposableBean {
|
||||
|
||||
private static final Map<String, String> DEFAULTS;
|
||||
|
||||
static {
|
||||
Map<String, String> defaults = new LinkedHashMap<String, String>();
|
||||
defaults.put("http.enabled", String.valueOf(false));
|
||||
|
||||
@@ -34,8 +34,8 @@ import org.springframework.orm.jpa.AbstractEntityManagerFactoryBean;
|
||||
* @since 1.1.0
|
||||
* @see BeanDefinition#setDependsOn(String[])
|
||||
*/
|
||||
public class EntityManagerFactoryDependsOnPostProcessor extends
|
||||
AbstractDependsOnBeanFactoryPostProcessor {
|
||||
public class EntityManagerFactoryDependsOnPostProcessor
|
||||
extends AbstractDependsOnBeanFactoryPostProcessor {
|
||||
|
||||
public EntityManagerFactoryDependsOnPostProcessor(String... dependsOn) {
|
||||
super(EntityManagerFactory.class, AbstractEntityManagerFactoryBean.class,
|
||||
|
||||
@@ -34,8 +34,8 @@ import com.mongodb.MongoClient;
|
||||
* @since 1.3.0
|
||||
*/
|
||||
@Order(Ordered.LOWEST_PRECEDENCE)
|
||||
public class MongoClientDependsOnBeanFactoryPostProcessor extends
|
||||
AbstractDependsOnBeanFactoryPostProcessor {
|
||||
public class MongoClientDependsOnBeanFactoryPostProcessor
|
||||
extends AbstractDependsOnBeanFactoryPostProcessor {
|
||||
|
||||
public MongoClientDependsOnBeanFactoryPostProcessor(String... dependsOn) {
|
||||
super(MongoClient.class, MongoClientFactoryBean.class, dependsOn);
|
||||
|
||||
@@ -142,8 +142,8 @@ public class MongoDataAutoConfiguration implements BeanClassLoaderAware {
|
||||
context.setInitialEntitySet(getInitialEntitySet(beanFactory));
|
||||
Class<?> strategyClass = this.properties.getFieldNamingStrategy();
|
||||
if (strategyClass != null) {
|
||||
context.setFieldNamingStrategy((FieldNamingStrategy) BeanUtils
|
||||
.instantiate(strategyClass));
|
||||
context.setFieldNamingStrategy(
|
||||
(FieldNamingStrategy) BeanUtils.instantiate(strategyClass));
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
@@ -114,8 +114,8 @@ public class RedisAutoConfiguration {
|
||||
sentinels.add(new RedisNode(parts[0], Integer.valueOf(parts[1])));
|
||||
}
|
||||
catch (RuntimeException ex) {
|
||||
throw new IllegalStateException("Invalid redis sentinel "
|
||||
+ "property '" + node + "'", ex);
|
||||
throw new IllegalStateException(
|
||||
"Invalid redis sentinel " + "property '" + node + "'", ex);
|
||||
}
|
||||
}
|
||||
return sentinels;
|
||||
@@ -128,8 +128,8 @@ public class RedisAutoConfiguration {
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnMissingClass("org.apache.commons.pool2.impl.GenericObjectPool")
|
||||
protected static class RedisConnectionConfiguration extends
|
||||
AbstractRedisConfiguration {
|
||||
protected static class RedisConnectionConfiguration
|
||||
extends AbstractRedisConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(RedisConnectionFactory.class)
|
||||
@@ -145,8 +145,8 @@ public class RedisAutoConfiguration {
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnClass(GenericObjectPool.class)
|
||||
protected static class RedisPooledConnectionConfiguration extends
|
||||
AbstractRedisConfiguration {
|
||||
protected static class RedisPooledConnectionConfiguration
|
||||
extends AbstractRedisConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(RedisConnectionFactory.class)
|
||||
@@ -184,7 +184,7 @@ public class RedisAutoConfiguration {
|
||||
@ConditionalOnMissingBean(name = "redisTemplate")
|
||||
public RedisTemplate<Object, Object> redisTemplate(
|
||||
RedisConnectionFactory redisConnectionFactory)
|
||||
throws UnknownHostException {
|
||||
throws UnknownHostException {
|
||||
RedisTemplate<Object, Object> template = new RedisTemplate<Object, Object>();
|
||||
template.setConnectionFactory(redisConnectionFactory);
|
||||
return template;
|
||||
@@ -194,7 +194,7 @@ public class RedisAutoConfiguration {
|
||||
@ConditionalOnMissingBean(StringRedisTemplate.class)
|
||||
public StringRedisTemplate stringRedisTemplate(
|
||||
RedisConnectionFactory redisConnectionFactory)
|
||||
throws UnknownHostException {
|
||||
throws UnknownHostException {
|
||||
StringRedisTemplate template = new StringRedisTemplate();
|
||||
template.setConnectionFactory(redisConnectionFactory);
|
||||
return template;
|
||||
|
||||
@@ -130,8 +130,8 @@ public class FlywayAutoConfiguration {
|
||||
@Configuration
|
||||
@ConditionalOnClass(LocalContainerEntityManagerFactoryBean.class)
|
||||
@ConditionalOnBean(AbstractEntityManagerFactoryBean.class)
|
||||
protected static class FlywayInitializerJpaDependencyConfiguration extends
|
||||
EntityManagerFactoryDependsOnPostProcessor {
|
||||
protected static class FlywayInitializerJpaDependencyConfiguration
|
||||
extends EntityManagerFactoryDependsOnPostProcessor {
|
||||
|
||||
public FlywayInitializerJpaDependencyConfiguration() {
|
||||
super("flywayInitializer");
|
||||
|
||||
@@ -72,8 +72,8 @@ public class H2ConsoleAutoConfiguration {
|
||||
}
|
||||
|
||||
@Order(SecurityProperties.BASIC_AUTH_ORDER - 10)
|
||||
private static class H2ConsoleSecurityConfigurer extends
|
||||
WebSecurityConfigurerAdapter {
|
||||
private static class H2ConsoleSecurityConfigurer
|
||||
extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Autowired
|
||||
private H2ConsoleProperties console;
|
||||
|
||||
@@ -56,8 +56,8 @@ public class HypermediaHttpMessageConverterConfiguration {
|
||||
* {@code Jackson2ModuleRegisteringBeanPostProcessor} has registered the converter and
|
||||
* it is unordered.
|
||||
*/
|
||||
private static class HalMessageConverterSupportedMediaTypesCustomizer implements
|
||||
BeanFactoryAware {
|
||||
private static class HalMessageConverterSupportedMediaTypesCustomizer
|
||||
implements BeanFactoryAware {
|
||||
|
||||
private volatile BeanFactory beanFactory;
|
||||
|
||||
@@ -73,9 +73,9 @@ public class HypermediaHttpMessageConverterConfiguration {
|
||||
.getMessageConverters()) {
|
||||
if (converter instanceof TypeConstrainedMappingJackson2HttpMessageConverter) {
|
||||
((TypeConstrainedMappingJackson2HttpMessageConverter) converter)
|
||||
.setSupportedMediaTypes(Arrays.asList(
|
||||
MediaTypes.HAL_JSON,
|
||||
MediaType.APPLICATION_JSON));
|
||||
.setSupportedMediaTypes(
|
||||
Arrays.asList(MediaTypes.HAL_JSON,
|
||||
MediaType.APPLICATION_JSON));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,8 +43,8 @@ public abstract class HazelcastConfigResourceCondition extends ResourceCondition
|
||||
protected ConditionOutcome getResourceOutcome(ConditionContext context,
|
||||
AnnotatedTypeMetadata metadata) {
|
||||
if (System.getProperty(CONFIG_SYSTEM_PROPERTY) != null) {
|
||||
return ConditionOutcome.match("System property '" + CONFIG_SYSTEM_PROPERTY
|
||||
+ "' is set.");
|
||||
return ConditionOutcome
|
||||
.match("System property '" + CONFIG_SYSTEM_PROPERTY + "' is set.");
|
||||
}
|
||||
return super.getResourceOutcome(context, metadata);
|
||||
}
|
||||
|
||||
@@ -103,21 +103,23 @@ public class JacksonAutoConfiguration {
|
||||
SimpleModule module = new SimpleModule();
|
||||
JacksonJodaDateFormat jacksonJodaFormat = getJacksonJodaDateFormat();
|
||||
if (jacksonJodaFormat != null) {
|
||||
module.addSerializer(DateTime.class, new DateTimeSerializer(
|
||||
jacksonJodaFormat));
|
||||
module.addSerializer(DateTime.class,
|
||||
new DateTimeSerializer(jacksonJodaFormat));
|
||||
}
|
||||
return module;
|
||||
}
|
||||
|
||||
private JacksonJodaDateFormat getJacksonJodaDateFormat() {
|
||||
if (this.jacksonProperties.getJodaDateTimeFormat() != null) {
|
||||
return new JacksonJodaDateFormat(DateTimeFormat.forPattern(
|
||||
this.jacksonProperties.getJodaDateTimeFormat()).withZoneUTC());
|
||||
return new JacksonJodaDateFormat(DateTimeFormat
|
||||
.forPattern(this.jacksonProperties.getJodaDateTimeFormat())
|
||||
.withZoneUTC());
|
||||
}
|
||||
if (this.jacksonProperties.getDateFormat() != null) {
|
||||
try {
|
||||
return new JacksonJodaDateFormat(DateTimeFormat.forPattern(
|
||||
this.jacksonProperties.getDateFormat()).withZoneUTC());
|
||||
return new JacksonJodaDateFormat(DateTimeFormat
|
||||
.forPattern(this.jacksonProperties.getDateFormat())
|
||||
.withZoneUTC());
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
if (this.log.isWarnEnabled()) {
|
||||
@@ -163,8 +165,8 @@ public class JacksonAutoConfiguration {
|
||||
Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
|
||||
builder.applicationContext(this.applicationContext);
|
||||
if (this.jacksonProperties.getSerializationInclusion() != null) {
|
||||
builder.serializationInclusion(this.jacksonProperties
|
||||
.getSerializationInclusion());
|
||||
builder.serializationInclusion(
|
||||
this.jacksonProperties.getSerializationInclusion());
|
||||
}
|
||||
if (this.jacksonProperties.getTimeZone() != null) {
|
||||
builder.timeZone(this.jacksonProperties.getTimeZone());
|
||||
@@ -200,8 +202,8 @@ public class JacksonAutoConfiguration {
|
||||
if (dateFormat != null) {
|
||||
try {
|
||||
Class<?> dateFormatClass = ClassUtils.forName(dateFormat, null);
|
||||
builder.dateFormat((DateFormat) BeanUtils
|
||||
.instantiateClass(dateFormatClass));
|
||||
builder.dateFormat(
|
||||
(DateFormat) BeanUtils.instantiateClass(dateFormatClass));
|
||||
}
|
||||
catch (ClassNotFoundException ex) {
|
||||
builder.dateFormat(new SimpleDateFormat(dateFormat));
|
||||
@@ -209,7 +211,8 @@ public class JacksonAutoConfiguration {
|
||||
}
|
||||
}
|
||||
|
||||
private void configurePropertyNamingStrategy(Jackson2ObjectMapperBuilder builder) {
|
||||
private void configurePropertyNamingStrategy(
|
||||
Jackson2ObjectMapperBuilder builder) {
|
||||
// We support a fully qualified class name extending Jackson's
|
||||
// PropertyNamingStrategy or a string value corresponding to the constant
|
||||
// names in PropertyNamingStrategy which hold default provided implementations
|
||||
@@ -226,7 +229,8 @@ public class JacksonAutoConfiguration {
|
||||
}
|
||||
|
||||
private void configurePropertyNamingStrategyClass(
|
||||
Jackson2ObjectMapperBuilder builder, Class<?> propertyNamingStrategyClass) {
|
||||
Jackson2ObjectMapperBuilder builder,
|
||||
Class<?> propertyNamingStrategyClass) {
|
||||
builder.propertyNamingStrategy((PropertyNamingStrategy) BeanUtils
|
||||
.instantiateClass(propertyNamingStrategyClass));
|
||||
}
|
||||
|
||||
@@ -43,8 +43,8 @@ import org.springframework.util.StringUtils;
|
||||
* @since 1.1.0
|
||||
*/
|
||||
@ConfigurationProperties(prefix = DataSourceProperties.PREFIX)
|
||||
public class DataSourceProperties implements BeanClassLoaderAware, EnvironmentAware,
|
||||
InitializingBean {
|
||||
public class DataSourceProperties
|
||||
implements BeanClassLoaderAware, EnvironmentAware, InitializingBean {
|
||||
|
||||
public static final String PREFIX = "spring.datasource";
|
||||
|
||||
@@ -162,8 +162,8 @@ public class DataSourceProperties implements BeanClassLoaderAware, EnvironmentAw
|
||||
|
||||
public String getDriverClassName() {
|
||||
if (StringUtils.hasText(this.driverClassName)) {
|
||||
Assert.state(driverClassIsLoadable(), "Cannot load driver class: "
|
||||
+ this.driverClassName);
|
||||
Assert.state(driverClassIsLoadable(),
|
||||
"Cannot load driver class: " + this.driverClassName);
|
||||
return this.driverClassName;
|
||||
}
|
||||
String driverClassName = null;
|
||||
@@ -383,8 +383,9 @@ public class DataSourceProperties implements BeanClassLoaderAware, EnvironmentAw
|
||||
}
|
||||
else {
|
||||
message.append(" (the profiles \""
|
||||
+ StringUtils.arrayToCommaDelimitedString(environment
|
||||
.getActiveProfiles()) + "\" are currently active)");
|
||||
+ StringUtils.arrayToCommaDelimitedString(
|
||||
environment.getActiveProfiles())
|
||||
+ "\" are currently active)");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,8 @@ public enum EmbeddedDatabaseConnection {
|
||||
|
||||
private final String url;
|
||||
|
||||
EmbeddedDatabaseConnection(EmbeddedDatabaseType type, String driverClass, String url) {
|
||||
EmbeddedDatabaseConnection(EmbeddedDatabaseType type, String driverClass,
|
||||
String url) {
|
||||
this.type = type;
|
||||
this.driverClass = driverClass;
|
||||
this.url = url;
|
||||
|
||||
@@ -41,8 +41,8 @@ public class DataSourcePoolMetadataProviders implements DataSourcePoolMetadataPr
|
||||
*/
|
||||
public DataSourcePoolMetadataProviders(
|
||||
Collection<? extends DataSourcePoolMetadataProvider> providers) {
|
||||
this.providers = (providers == null ? Collections
|
||||
.<DataSourcePoolMetadataProvider>emptyList()
|
||||
this.providers = (providers == null
|
||||
? Collections.<DataSourcePoolMetadataProvider>emptyList()
|
||||
: new ArrayList<DataSourcePoolMetadataProvider>(providers));
|
||||
}
|
||||
|
||||
|
||||
@@ -120,8 +120,9 @@ public class JmsProperties {
|
||||
if (this.concurrency == null) {
|
||||
return (this.maxConcurrency != null ? "1-" + this.maxConcurrency : null);
|
||||
}
|
||||
return (this.maxConcurrency != null ? this.concurrency + "-"
|
||||
+ this.maxConcurrency : String.valueOf(this.concurrency));
|
||||
return (this.maxConcurrency != null
|
||||
? this.concurrency + "-" + this.maxConcurrency
|
||||
: String.valueOf(this.concurrency));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,8 +35,8 @@ import org.springframework.context.annotation.Configuration;
|
||||
class ArtemisConnectionFactoryConfiguration {
|
||||
|
||||
@Bean
|
||||
public ActiveMQConnectionFactory jmsConnectionFactory(
|
||||
ListableBeanFactory beanFactory, ArtemisProperties properties) {
|
||||
public ActiveMQConnectionFactory jmsConnectionFactory(ListableBeanFactory beanFactory,
|
||||
ArtemisProperties properties) {
|
||||
return new ArtemisConnectionFactoryFactory(beanFactory, properties)
|
||||
.createConnectionFactory(ActiveMQConnectionFactory.class);
|
||||
}
|
||||
|
||||
@@ -62,8 +62,8 @@ class ArtemisConnectionFactoryFactory {
|
||||
return doCreateConnectionFactory(factoryClass);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new IllegalStateException("Unable to create "
|
||||
+ "ActiveMQConnectionFactory", ex);
|
||||
throw new IllegalStateException(
|
||||
"Unable to create " + "ActiveMQConnectionFactory", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,12 +106,12 @@ class ArtemisConnectionFactoryFactory {
|
||||
Class<T> factoryClass) throws Exception {
|
||||
try {
|
||||
TransportConfiguration transportConfiguration = new TransportConfiguration(
|
||||
InVMConnectorFactory.class.getName(), this.properties.getEmbedded()
|
||||
.generateTransportParameters());
|
||||
InVMConnectorFactory.class.getName(),
|
||||
this.properties.getEmbedded().generateTransportParameters());
|
||||
ServerLocator serviceLocator = ActiveMQClient
|
||||
.createServerLocatorWithoutHA(transportConfiguration);
|
||||
return factoryClass.getConstructor(ServerLocator.class).newInstance(
|
||||
serviceLocator);
|
||||
return factoryClass.getConstructor(ServerLocator.class)
|
||||
.newInstance(serviceLocator);
|
||||
}
|
||||
catch (NoClassDefFoundError ex) {
|
||||
throw new IllegalStateException("Unable to create InVM "
|
||||
|
||||
@@ -46,10 +46,10 @@ class ArtemisXAConnectionFactoryConfiguration {
|
||||
@Bean(name = { "jmsConnectionFactory", "xaJmsConnectionFactory" })
|
||||
public ConnectionFactory jmsConnectionFactory(ListableBeanFactory beanFactory,
|
||||
ArtemisProperties properties, XAConnectionFactoryWrapper wrapper)
|
||||
throws Exception {
|
||||
return wrapper.wrapConnectionFactory(new ArtemisConnectionFactoryFactory(
|
||||
beanFactory, properties)
|
||||
.createConnectionFactory(ActiveMQXAConnectionFactory.class));
|
||||
throws Exception {
|
||||
return wrapper.wrapConnectionFactory(
|
||||
new ArtemisConnectionFactoryFactory(beanFactory, properties)
|
||||
.createConnectionFactory(ActiveMQXAConnectionFactory.class));
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -57,9 +57,10 @@ public class JooqAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(DataSourceConnectionProvider.class)
|
||||
public DataSourceConnectionProvider dataSourceConnectionProvider(DataSource dataSource) {
|
||||
return new DataSourceConnectionProvider(new TransactionAwareDataSourceProxy(
|
||||
dataSource));
|
||||
public DataSourceConnectionProvider dataSourceConnectionProvider(
|
||||
DataSource dataSource) {
|
||||
return new DataSourceConnectionProvider(
|
||||
new TransactionAwareDataSourceProxy(dataSource));
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -64,8 +64,8 @@ class JooqExceptionTranslator extends DefaultExecuteListener {
|
||||
|
||||
/**
|
||||
* Handle a single exception in the chain. SQLExceptions might be nested multiple
|
||||
* levels deep. The outermost exception is usually the least interesting one
|
||||
* ("Call getNextException to see the cause."). Therefore the innermost exception is
|
||||
* levels deep. The outermost exception is usually the least interesting one (
|
||||
* "Call getNextException to see the cause."). Therefore the innermost exception is
|
||||
* propagated and all other exceptions are logged.
|
||||
* @param context the execute context
|
||||
* @param translator the exception translator
|
||||
|
||||
@@ -55,8 +55,8 @@ import org.springframework.util.StringUtils;
|
||||
* @author Phillip Webb
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class AutoConfigurationReportLoggingInitializer implements
|
||||
ApplicationContextInitializer<ConfigurableApplicationContext> {
|
||||
public class AutoConfigurationReportLoggingInitializer
|
||||
implements ApplicationContextInitializer<ConfigurableApplicationContext> {
|
||||
|
||||
private final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
@@ -70,20 +70,22 @@ public class AutoConfigurationReportLoggingInitializer implements
|
||||
applicationContext.addApplicationListener(new AutoConfigurationReportListener());
|
||||
if (applicationContext instanceof GenericApplicationContext) {
|
||||
// Get the report early in case the context fails to load
|
||||
this.report = ConditionEvaluationReport.get(this.applicationContext
|
||||
.getBeanFactory());
|
||||
this.report = ConditionEvaluationReport
|
||||
.get(this.applicationContext.getBeanFactory());
|
||||
}
|
||||
}
|
||||
|
||||
protected void onApplicationEvent(ApplicationEvent event) {
|
||||
ConfigurableApplicationContext initializerApplicationContext = AutoConfigurationReportLoggingInitializer.this.applicationContext;
|
||||
if (event instanceof ContextRefreshedEvent) {
|
||||
if (((ApplicationContextEvent) event).getApplicationContext() == initializerApplicationContext) {
|
||||
if (((ApplicationContextEvent) event)
|
||||
.getApplicationContext() == initializerApplicationContext) {
|
||||
logAutoConfigurationReport();
|
||||
}
|
||||
}
|
||||
else if (event instanceof ApplicationFailedEvent) {
|
||||
if (((ApplicationFailedEvent) event).getApplicationContext() == initializerApplicationContext) {
|
||||
if (((ApplicationFailedEvent) event)
|
||||
.getApplicationContext() == initializerApplicationContext) {
|
||||
logAutoConfigurationReport(true);
|
||||
}
|
||||
}
|
||||
@@ -100,8 +102,8 @@ public class AutoConfigurationReportLoggingInitializer implements
|
||||
+ "due to missing ApplicationContext");
|
||||
return;
|
||||
}
|
||||
this.report = ConditionEvaluationReport.get(this.applicationContext
|
||||
.getBeanFactory());
|
||||
this.report = ConditionEvaluationReport
|
||||
.get(this.applicationContext.getBeanFactory());
|
||||
}
|
||||
if (this.report.getConditionAndOutcomesBySource().size() > 0) {
|
||||
if (isCrashReport && this.logger.isInfoEnabled()
|
||||
@@ -124,8 +126,8 @@ public class AutoConfigurationReportLoggingInitializer implements
|
||||
message.append("=========================\n\n\n");
|
||||
message.append("Positive matches:\n");
|
||||
message.append("-----------------\n");
|
||||
Map<String, ConditionAndOutcomes> shortOutcomes = orderByName(report
|
||||
.getConditionAndOutcomesBySource());
|
||||
Map<String, ConditionAndOutcomes> shortOutcomes = orderByName(
|
||||
report.getConditionAndOutcomesBySource());
|
||||
for (Map.Entry<String, ConditionAndOutcomes> entry : shortOutcomes.entrySet()) {
|
||||
if (entry.getValue().isFullMatch()) {
|
||||
addLogMessage(message, entry.getKey(), entry.getValue());
|
||||
@@ -185,8 +187,8 @@ public class AutoConfigurationReportLoggingInitializer implements
|
||||
private void addLogMessage(StringBuilder message, String source,
|
||||
ConditionAndOutcomes conditionAndOutcomes) {
|
||||
message.append("\n " + source);
|
||||
message.append(conditionAndOutcomes.isFullMatch() ? " matched\n"
|
||||
: " did not match\n");
|
||||
message.append(
|
||||
conditionAndOutcomes.isFullMatch() ? " matched\n" : " did not match\n");
|
||||
for (ConditionAndOutcome conditionAndOutcome : conditionAndOutcomes) {
|
||||
message.append(" - ");
|
||||
if (StringUtils.hasLength(conditionAndOutcome.getOutcome().getMessage())) {
|
||||
@@ -197,8 +199,8 @@ public class AutoConfigurationReportLoggingInitializer implements
|
||||
: "did not match");
|
||||
}
|
||||
message.append(" (");
|
||||
message.append(ClassUtils.getShortName(conditionAndOutcome.getCondition()
|
||||
.getClass()));
|
||||
message.append(ClassUtils
|
||||
.getShortName(conditionAndOutcome.getCondition().getClass()));
|
||||
message.append(")\n");
|
||||
}
|
||||
|
||||
|
||||
@@ -51,8 +51,9 @@ class JndiSessionConfiguration {
|
||||
return new JndiLocatorDelegate().lookup(jndiName, Session.class);
|
||||
}
|
||||
catch (NamingException ex) {
|
||||
throw new IllegalStateException(String.format(
|
||||
"Unable to find Session in JNDI location %s", jndiName), ex);
|
||||
throw new IllegalStateException(
|
||||
String.format("Unable to find Session in JNDI location %s", jndiName),
|
||||
ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -93,20 +93,20 @@ public class EmbeddedMongoAutoConfiguration {
|
||||
@ConditionalOnMissingBean
|
||||
@ConditionalOnClass(Logger.class)
|
||||
public IRuntimeConfig embeddedMongoRuntimeConfig() {
|
||||
Logger logger = LoggerFactory.getLogger(getClass().getPackage().getName()
|
||||
+ ".EmbeddedMongo");
|
||||
Logger logger = LoggerFactory
|
||||
.getLogger(getClass().getPackage().getName() + ".EmbeddedMongo");
|
||||
ProcessOutput processOutput = new ProcessOutput(
|
||||
Processors.logTo(logger, Slf4jLevel.INFO),
|
||||
Processors.logTo(logger, Slf4jLevel.ERROR),
|
||||
Processors.named("[console>]", Processors.logTo(logger, Slf4jLevel.DEBUG)));
|
||||
Processors.logTo(logger, Slf4jLevel.ERROR), Processors.named("[console>]",
|
||||
Processors.logTo(logger, Slf4jLevel.DEBUG)));
|
||||
return new RuntimeConfigBuilder().defaultsWithLogger(Command.MongoD, logger)
|
||||
.processOutput(processOutput).artifactStore(getArtifactStore(logger))
|
||||
.build();
|
||||
}
|
||||
|
||||
private ArtifactStoreBuilder getArtifactStore(Logger logger) {
|
||||
return new ExtractedArtifactStoreBuilder().defaults(Command.MongoD).download(
|
||||
new DownloadConfigBuilder().defaultsForCommand(Command.MongoD)
|
||||
return new ExtractedArtifactStoreBuilder().defaults(Command.MongoD)
|
||||
.download(new DownloadConfigBuilder().defaultsForCommand(Command.MongoD)
|
||||
.progressListener(new Slf4jProgressListener(logger)));
|
||||
}
|
||||
|
||||
@@ -181,8 +181,8 @@ public class EmbeddedMongoAutoConfiguration {
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnClass(MongoClient.class)
|
||||
protected static class EmbeddedMongoDependencyConfiguration extends
|
||||
MongoClientDependsOnBeanFactoryPostProcessor {
|
||||
protected static class EmbeddedMongoDependencyConfiguration
|
||||
extends MongoClientDependsOnBeanFactoryPostProcessor {
|
||||
|
||||
public EmbeddedMongoDependencyConfiguration() {
|
||||
super("embeddedMongoServer");
|
||||
@@ -194,14 +194,15 @@ public class EmbeddedMongoAutoConfiguration {
|
||||
* A workaround for the lack of a {@code toString} implementation on
|
||||
* {@code GenericFeatureAwareVersion}.
|
||||
*/
|
||||
private final static class ToStringFriendlyFeatureAwareVersion implements
|
||||
IFeatureAwareVersion {
|
||||
private final static class ToStringFriendlyFeatureAwareVersion
|
||||
implements IFeatureAwareVersion {
|
||||
|
||||
private final String version;
|
||||
|
||||
private final Set<Feature> features;
|
||||
|
||||
private ToStringFriendlyFeatureAwareVersion(String version, Set<Feature> features) {
|
||||
private ToStringFriendlyFeatureAwareVersion(String version,
|
||||
Set<Feature> features) {
|
||||
Assert.notNull(version, "version must not be null");
|
||||
this.version = version;
|
||||
this.features = (features == null ? Collections.<Feature>emptySet()
|
||||
|
||||
@@ -66,8 +66,8 @@ public class EntityManagerFactoryBuilder {
|
||||
* @param callback the entity manager factory bean callback
|
||||
*/
|
||||
public void setCallback(final EntityManagerFactoryBeanCallback callback) {
|
||||
this.delegate
|
||||
.setCallback(new org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder.EntityManagerFactoryBeanCallback() {
|
||||
this.delegate.setCallback(
|
||||
new org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder.EntityManagerFactoryBeanCallback() {
|
||||
|
||||
@Override
|
||||
public void execute(LocalContainerEntityManagerFactoryBean factory) {
|
||||
@@ -169,8 +169,8 @@ public class EntityManagerFactoryBuilder {
|
||||
|
||||
}
|
||||
|
||||
private static class Delegate extends
|
||||
org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder {
|
||||
private static class Delegate
|
||||
extends org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder {
|
||||
|
||||
Delegate(JpaVendorAdapter jpaVendorAdapter, Map<String, ?> jpaProperties,
|
||||
PersistenceUnitManager persistenceUnitManager) {
|
||||
|
||||
@@ -152,7 +152,8 @@ public class AuthenticationManagerConfiguration {
|
||||
|
||||
private final SecurityProperties securityProperties;
|
||||
|
||||
DefaultInMemoryUserDetailsManagerConfigurer(SecurityProperties securityProperties) {
|
||||
DefaultInMemoryUserDetailsManagerConfigurer(
|
||||
SecurityProperties securityProperties) {
|
||||
this.securityProperties = securityProperties;
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,8 @@ public class SecurityProperties implements SecurityPrerequisite {
|
||||
* other filters registered with the container). There is no connection between this
|
||||
* and the <code>@Order</code> on a WebSecurityConfigurer.
|
||||
*/
|
||||
public static final int DEFAULT_FILTER_ORDER = FilterRegistrationBean.REQUEST_WRAPPER_FILTER_MAX_ORDER - 100;
|
||||
public static final int DEFAULT_FILTER_ORDER = FilterRegistrationBean.REQUEST_WRAPPER_FILTER_MAX_ORDER
|
||||
- 100;
|
||||
|
||||
/**
|
||||
* Enable secure channel for all requests.
|
||||
|
||||
@@ -60,8 +60,8 @@ import org.springframework.security.oauth2.provider.token.TokenStore;
|
||||
@ConditionalOnMissingBean(AuthorizationServerConfigurer.class)
|
||||
@ConditionalOnBean(AuthorizationServerEndpointsConfiguration.class)
|
||||
@EnableConfigurationProperties
|
||||
public class OAuth2AuthorizationServerConfiguration extends
|
||||
AuthorizationServerConfigurerAdapter {
|
||||
public class OAuth2AuthorizationServerConfiguration
|
||||
extends AuthorizationServerConfigurerAdapter {
|
||||
|
||||
private static final Log logger = LogFactory
|
||||
.getLog(OAuth2AuthorizationServerConfiguration.class);
|
||||
@@ -88,8 +88,8 @@ public class OAuth2AuthorizationServerConfiguration extends
|
||||
.toArray(new String[0]))
|
||||
.scopes(this.details.getScope().toArray(new String[0]));
|
||||
if (this.details.getRegisteredRedirectUri() != null) {
|
||||
builder.redirectUris(this.details.getRegisteredRedirectUri().toArray(
|
||||
new String[0]));
|
||||
builder.redirectUris(
|
||||
this.details.getRegisteredRedirectUri().toArray(new String[0]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,8 +140,8 @@ public class OAuth2AuthorizationServerConfiguration extends
|
||||
details.setClientSecret(this.client.getClientSecret());
|
||||
details.setAuthorizedGrantTypes(Arrays.asList("authorization_code",
|
||||
"password", "client_credentials", "implicit", "refresh_token"));
|
||||
details.setAuthorities(AuthorityUtils
|
||||
.commaSeparatedStringToAuthorityList("ROLE_USER"));
|
||||
details.setAuthorities(
|
||||
AuthorityUtils.commaSeparatedStringToAuthorityList("ROLE_USER"));
|
||||
details.setRegisteredRedirectUri(Collections.<String>emptySet());
|
||||
return details;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,8 @@ public class OAuth2RestOperationsConfiguration {
|
||||
@Primary
|
||||
public OAuth2RestTemplate oauth2RestTemplate(OAuth2ClientContext oauth2ClientContext,
|
||||
OAuth2ProtectedResourceDetails details) {
|
||||
OAuth2RestTemplate template = new OAuth2RestTemplate(details, oauth2ClientContext);
|
||||
OAuth2RestTemplate template = new OAuth2RestTemplate(details,
|
||||
oauth2ClientContext);
|
||||
return template;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,8 +49,8 @@ import org.springframework.util.ReflectionUtils;
|
||||
*/
|
||||
@Configuration
|
||||
@Conditional(WebSecurityEnhancerCondition.class)
|
||||
public class OAuth2SsoCustomConfiguration implements ImportAware, BeanPostProcessor,
|
||||
BeanFactoryAware {
|
||||
public class OAuth2SsoCustomConfiguration
|
||||
implements ImportAware, BeanPostProcessor, BeanFactoryAware {
|
||||
|
||||
private Class<?> configType;
|
||||
|
||||
@@ -63,8 +63,8 @@ public class OAuth2SsoCustomConfiguration implements ImportAware, BeanPostProces
|
||||
|
||||
@Override
|
||||
public void setImportMetadata(AnnotationMetadata importMetadata) {
|
||||
this.configType = ClassUtils
|
||||
.resolveClassName(importMetadata.getClassName(), null);
|
||||
this.configType = ClassUtils.resolveClassName(importMetadata.getClassName(),
|
||||
null);
|
||||
|
||||
}
|
||||
|
||||
@@ -98,8 +98,8 @@ public class OAuth2SsoCustomConfiguration implements ImportAware, BeanPostProces
|
||||
@Override
|
||||
public Object invoke(MethodInvocation invocation) throws Throwable {
|
||||
if (invocation.getMethod().getName().equals("init")) {
|
||||
Method method = ReflectionUtils.findMethod(
|
||||
WebSecurityConfigurerAdapter.class, "getHttp");
|
||||
Method method = ReflectionUtils
|
||||
.findMethod(WebSecurityConfigurerAdapter.class, "getHttp");
|
||||
ReflectionUtils.makeAccessible(method);
|
||||
HttpSecurity http = (HttpSecurity) ReflectionUtils.invokeMethod(method,
|
||||
invocation.getThis());
|
||||
@@ -115,17 +115,17 @@ public class OAuth2SsoCustomConfiguration implements ImportAware, BeanPostProces
|
||||
@Override
|
||||
public ConditionOutcome getMatchOutcome(ConditionContext context,
|
||||
AnnotatedTypeMetadata metadata) {
|
||||
String[] enablers = context.getBeanFactory().getBeanNamesForAnnotation(
|
||||
EnableOAuth2Sso.class);
|
||||
String[] enablers = context.getBeanFactory()
|
||||
.getBeanNamesForAnnotation(EnableOAuth2Sso.class);
|
||||
for (String name : enablers) {
|
||||
if (context.getBeanFactory().isTypeMatch(name,
|
||||
WebSecurityConfigurerAdapter.class)) {
|
||||
return ConditionOutcome
|
||||
.match("found @EnableOAuth2Sso on a WebSecurityConfigurerAdapter");
|
||||
return ConditionOutcome.match(
|
||||
"found @EnableOAuth2Sso on a WebSecurityConfigurerAdapter");
|
||||
}
|
||||
}
|
||||
return ConditionOutcome
|
||||
.noMatch("found no @EnableOAuth2Sso on a WebSecurityConfigurerAdapter");
|
||||
return ConditionOutcome.noMatch(
|
||||
"found no @EnableOAuth2Sso on a WebSecurityConfigurerAdapter");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -42,8 +42,8 @@ import org.springframework.util.ClassUtils;
|
||||
*/
|
||||
@Configuration
|
||||
@Conditional(NeedsWebSecurityCondition.class)
|
||||
public class OAuth2SsoDefaultConfiguration extends WebSecurityConfigurerAdapter implements
|
||||
Ordered {
|
||||
public class OAuth2SsoDefaultConfiguration extends WebSecurityConfigurerAdapter
|
||||
implements Ordered {
|
||||
|
||||
@Autowired
|
||||
BeanFactory beanFactory;
|
||||
@@ -62,10 +62,9 @@ public class OAuth2SsoDefaultConfiguration extends WebSecurityConfigurerAdapter
|
||||
if (this.sso.getFilterOrder() != null) {
|
||||
return this.sso.getFilterOrder();
|
||||
}
|
||||
if (ClassUtils
|
||||
.isPresent(
|
||||
"org.springframework.boot.actuate.autoconfigure.ManagementServerProperties",
|
||||
null)) {
|
||||
if (ClassUtils.isPresent(
|
||||
"org.springframework.boot.actuate.autoconfigure.ManagementServerProperties",
|
||||
null)) {
|
||||
// If > BASIC_AUTH_ORDER then the existing rules for the actuator
|
||||
// endpoints will take precedence. This value is < BASIC_AUTH_ORDER.
|
||||
return SecurityProperties.ACCESS_OVERRIDE_ORDER - 5;
|
||||
@@ -78,13 +77,13 @@ public class OAuth2SsoDefaultConfiguration extends WebSecurityConfigurerAdapter
|
||||
@Override
|
||||
public ConditionOutcome getMatchOutcome(ConditionContext context,
|
||||
AnnotatedTypeMetadata metadata) {
|
||||
String[] enablers = context.getBeanFactory().getBeanNamesForAnnotation(
|
||||
EnableOAuth2Sso.class);
|
||||
String[] enablers = context.getBeanFactory()
|
||||
.getBeanNamesForAnnotation(EnableOAuth2Sso.class);
|
||||
for (String name : enablers) {
|
||||
if (context.getBeanFactory().isTypeMatch(name,
|
||||
WebSecurityConfigurerAdapter.class)) {
|
||||
return ConditionOutcome
|
||||
.noMatch("found @EnableOAuth2Sso on a WebSecurityConfigurerAdapter");
|
||||
return ConditionOutcome.noMatch(
|
||||
"found @EnableOAuth2Sso on a WebSecurityConfigurerAdapter");
|
||||
}
|
||||
}
|
||||
return ConditionOutcome
|
||||
|
||||
@@ -57,8 +57,8 @@ class SsoSecurityConfigurer {
|
||||
return filter;
|
||||
}
|
||||
|
||||
private static class OAuth2ClientAuthenticationConfigurer extends
|
||||
SecurityConfigurerAdapter<DefaultSecurityFilterChain, HttpSecurity> {
|
||||
private static class OAuth2ClientAuthenticationConfigurer
|
||||
extends SecurityConfigurerAdapter<DefaultSecurityFilterChain, HttpSecurity> {
|
||||
|
||||
private OAuth2ClientAuthenticationProcessingFilter filter;
|
||||
|
||||
@@ -70,8 +70,8 @@ class SsoSecurityConfigurer {
|
||||
@Override
|
||||
public void configure(HttpSecurity builder) throws Exception {
|
||||
OAuth2ClientAuthenticationProcessingFilter ssoFilter = this.filter;
|
||||
ssoFilter.setSessionAuthenticationStrategy(builder
|
||||
.getSharedObject(SessionAuthenticationStrategy.class));
|
||||
ssoFilter.setSessionAuthenticationStrategy(
|
||||
builder.getSharedObject(SessionAuthenticationStrategy.class));
|
||||
builder.addFilterAfter(ssoFilter,
|
||||
AbstractPreAuthenticatedProcessingFilter.class);
|
||||
}
|
||||
|
||||
@@ -44,8 +44,8 @@ import org.springframework.security.oauth2.provider.expression.OAuth2MethodSecur
|
||||
@Configuration
|
||||
@ConditionalOnClass({ OAuth2AccessToken.class })
|
||||
@ConditionalOnBean(GlobalMethodSecurityConfiguration.class)
|
||||
public class OAuth2MethodSecurityConfiguration implements BeanFactoryPostProcessor,
|
||||
ApplicationContextAware {
|
||||
public class OAuth2MethodSecurityConfiguration
|
||||
implements BeanFactoryPostProcessor, ApplicationContextAware {
|
||||
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@@ -63,8 +63,8 @@ public class OAuth2MethodSecurityConfiguration implements BeanFactoryPostProcess
|
||||
beanFactory.addBeanPostProcessor(processor);
|
||||
}
|
||||
|
||||
private static class OAuth2ExpressionHandlerInjectionPostProcessor implements
|
||||
BeanPostProcessor {
|
||||
private static class OAuth2ExpressionHandlerInjectionPostProcessor
|
||||
implements BeanPostProcessor {
|
||||
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@@ -84,7 +84,8 @@ public class OAuth2MethodSecurityConfiguration implements BeanFactoryPostProcess
|
||||
throws BeansException {
|
||||
if (bean instanceof DefaultMethodSecurityExpressionHandler
|
||||
&& !(bean instanceof OAuth2MethodSecurityExpressionHandler)) {
|
||||
return getExpressionHandler((DefaultMethodSecurityExpressionHandler) bean);
|
||||
return getExpressionHandler(
|
||||
(DefaultMethodSecurityExpressionHandler) bean);
|
||||
}
|
||||
return bean;
|
||||
}
|
||||
@@ -93,7 +94,8 @@ public class OAuth2MethodSecurityConfiguration implements BeanFactoryPostProcess
|
||||
DefaultMethodSecurityExpressionHandler bean) {
|
||||
OAuth2MethodSecurityExpressionHandler handler = new OAuth2MethodSecurityExpressionHandler();
|
||||
handler.setApplicationContext(this.applicationContext);
|
||||
AuthenticationTrustResolver trustResolver = findInContext(AuthenticationTrustResolver.class);
|
||||
AuthenticationTrustResolver trustResolver = findInContext(
|
||||
AuthenticationTrustResolver.class);
|
||||
if (trustResolver != null) {
|
||||
handler.setTrustResolver(trustResolver);
|
||||
}
|
||||
|
||||
@@ -73,8 +73,8 @@ public class OAuth2ResourceServerConfiguration {
|
||||
return new ResourceSecurityConfigurer(this.resource);
|
||||
}
|
||||
|
||||
protected static class ResourceSecurityConfigurer extends
|
||||
ResourceServerConfigurerAdapter {
|
||||
protected static class ResourceSecurityConfigurer
|
||||
extends ResourceServerConfigurerAdapter {
|
||||
|
||||
private ResourceServerProperties resource;
|
||||
|
||||
@@ -96,8 +96,8 @@ public class OAuth2ResourceServerConfiguration {
|
||||
|
||||
}
|
||||
|
||||
protected static class ResourceServerCondition extends SpringBootCondition implements
|
||||
ConfigurationCondition {
|
||||
protected static class ResourceServerCondition extends SpringBootCondition
|
||||
implements ConfigurationCondition {
|
||||
|
||||
private static final String AUTHORIZATION_ANNOTATION = "org.springframework."
|
||||
+ "security.oauth2.config.annotation.web.configuration."
|
||||
@@ -123,14 +123,14 @@ public class OAuth2ResourceServerConfiguration {
|
||||
return ConditionOutcome.match("found JWT resource configuration");
|
||||
}
|
||||
if (StringUtils.hasText(resolver.getProperty("user-info-uri"))) {
|
||||
return ConditionOutcome.match("found UserInfo "
|
||||
+ "URI resource configuration");
|
||||
return ConditionOutcome
|
||||
.match("found UserInfo " + "URI resource configuration");
|
||||
}
|
||||
if (ClassUtils.isPresent(AUTHORIZATION_ANNOTATION, null)) {
|
||||
if (AuthorizationServerEndpointsConfigurationBeanCondition
|
||||
.matches(context)) {
|
||||
return ConditionOutcome.match("found authorization "
|
||||
+ "server endpoints configuration");
|
||||
return ConditionOutcome.match(
|
||||
"found authorization " + "server endpoints configuration");
|
||||
}
|
||||
}
|
||||
return ConditionOutcome.noMatch("found neither client id nor "
|
||||
|
||||
@@ -203,8 +203,8 @@ public class ResourceServerProperties implements Validator, BeanFactoryAware {
|
||||
}
|
||||
|
||||
private int countBeans(Class<?> type) {
|
||||
return BeanFactoryUtils.beanNamesForTypeIncludingAncestors(this.beanFactory,
|
||||
type, true, false).length;
|
||||
return BeanFactoryUtils.beanNamesForTypeIncludingAncestors(this.beanFactory, type,
|
||||
true, false).length;
|
||||
}
|
||||
|
||||
public class Jwt {
|
||||
|
||||
@@ -91,10 +91,10 @@ public class ResourceServerTokenServicesConfiguration {
|
||||
|
||||
static {
|
||||
DEFAULT_RESOURCE_DETAILS.setClientId("<N/A>");
|
||||
DEFAULT_RESOURCE_DETAILS.setUserAuthorizationUri("Not a URI "
|
||||
+ "because there is no client");
|
||||
DEFAULT_RESOURCE_DETAILS.setAccessTokenUri("Not a URI "
|
||||
+ "because there is no client");
|
||||
DEFAULT_RESOURCE_DETAILS
|
||||
.setUserAuthorizationUri("Not a URI " + "because there is no client");
|
||||
DEFAULT_RESOURCE_DETAILS
|
||||
.setAccessTokenUri("Not a URI " + "because there is no client");
|
||||
}
|
||||
|
||||
@Autowired(required = false)
|
||||
@@ -113,8 +113,8 @@ public class ResourceServerTokenServicesConfiguration {
|
||||
this.details = DEFAULT_RESOURCE_DETAILS;
|
||||
}
|
||||
OAuth2RestTemplate template = getTemplate();
|
||||
template.setInterceptors(Arrays
|
||||
.<ClientHttpRequestInterceptor>asList(new AcceptJsonRequestInterceptor()));
|
||||
template.setInterceptors(Arrays.<ClientHttpRequestInterceptor>asList(
|
||||
new AcceptJsonRequestInterceptor()));
|
||||
AuthorizationCodeAccessTokenProvider accessTokenProvider = new AuthorizationCodeAccessTokenProvider();
|
||||
accessTokenProvider.setTokenRequestEnhancer(new AcceptJsonRequestEnhancer());
|
||||
template.setAccessTokenProvider(accessTokenProvider);
|
||||
@@ -298,8 +298,9 @@ public class ResourceServerTokenServicesConfiguration {
|
||||
Boolean preferTokenInfo = resolver.getProperty("prefer-token-info",
|
||||
Boolean.class);
|
||||
if (preferTokenInfo == null) {
|
||||
preferTokenInfo = environment.resolvePlaceholders(
|
||||
"${OAUTH2_RESOURCE_PREFERTOKENINFO:true}").equals("true");
|
||||
preferTokenInfo = environment
|
||||
.resolvePlaceholders("${OAUTH2_RESOURCE_PREFERTOKENINFO:true}")
|
||||
.equals("true");
|
||||
}
|
||||
String tokenInfoUri = resolver.getProperty("token-info-uri");
|
||||
String userInfoUri = resolver.getProperty("user-info-uri");
|
||||
@@ -307,8 +308,8 @@ public class ResourceServerTokenServicesConfiguration {
|
||||
return ConditionOutcome.match("No user info provided");
|
||||
}
|
||||
if (StringUtils.hasLength(tokenInfoUri) && preferTokenInfo) {
|
||||
return ConditionOutcome.match("Token info endpoint "
|
||||
+ "is preferred and user info provided");
|
||||
return ConditionOutcome.match(
|
||||
"Token info endpoint " + "is preferred and user info provided");
|
||||
}
|
||||
return ConditionOutcome.noMatch("Token info endpoint is not provided");
|
||||
}
|
||||
@@ -339,8 +340,8 @@ public class ResourceServerTokenServicesConfiguration {
|
||||
@Override
|
||||
public ConditionOutcome getMatchOutcome(ConditionContext context,
|
||||
AnnotatedTypeMetadata metadata) {
|
||||
return ConditionOutcome.inverse(this.tokenInfoCondition.getMatchOutcome(
|
||||
context, metadata));
|
||||
return ConditionOutcome
|
||||
.inverse(this.tokenInfoCondition.getMatchOutcome(context, metadata));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -352,14 +353,14 @@ public class ResourceServerTokenServicesConfiguration {
|
||||
@Override
|
||||
public ConditionOutcome getMatchOutcome(ConditionContext context,
|
||||
AnnotatedTypeMetadata metadata) {
|
||||
return ConditionOutcome.inverse(this.jwtTokenCondition.getMatchOutcome(
|
||||
context, metadata));
|
||||
return ConditionOutcome
|
||||
.inverse(this.jwtTokenCondition.getMatchOutcome(context, metadata));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class AcceptJsonRequestInterceptor implements
|
||||
ClientHttpRequestInterceptor {
|
||||
private static class AcceptJsonRequestInterceptor
|
||||
implements ClientHttpRequestInterceptor {
|
||||
|
||||
@Override
|
||||
public ClientHttpResponse intercept(HttpRequest request, byte[] body,
|
||||
|
||||
@@ -69,8 +69,8 @@ public class SpringSocialTokenServices implements ResourceServerTokenServices {
|
||||
.commaSeparatedStringToAuthorityList("ROLE_USER");
|
||||
OAuth2Request request = new OAuth2Request(null, this.clientId, null, true, null,
|
||||
null, null, null, null);
|
||||
return new OAuth2Authentication(request, new UsernamePasswordAuthenticationToken(
|
||||
principal, "N/A", authorities));
|
||||
return new OAuth2Authentication(request,
|
||||
new UsernamePasswordAuthenticationToken(principal, "N/A", authorities));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,7 +30,8 @@ import org.springframework.core.type.AnnotationMetadata;
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
class ImportAutoConfigurationImportSelector extends EnableAutoConfigurationImportSelector {
|
||||
class ImportAutoConfigurationImportSelector
|
||||
extends EnableAutoConfigurationImportSelector {
|
||||
|
||||
@Override
|
||||
protected Class<?> getAnnotationClass() {
|
||||
|
||||
@@ -100,7 +100,8 @@ public class BasicErrorController extends AbstractErrorController {
|
||||
* @param produces the media type produced (or {@code MediaType.ALL})
|
||||
* @return if the stacktrace attribute should be included
|
||||
*/
|
||||
protected boolean isIncludeStackTrace(HttpServletRequest request, MediaType produces) {
|
||||
protected boolean isIncludeStackTrace(HttpServletRequest request,
|
||||
MediaType produces) {
|
||||
IncludeStacktrace include = getErrorProperties().getIncludeStacktrace();
|
||||
if (include == IncludeStacktrace.ALWAYS) {
|
||||
return true;
|
||||
|
||||
@@ -122,9 +122,10 @@ public class DispatcherServletAutoConfiguration {
|
||||
return checkServletRegistrations(beanFactory);
|
||||
}
|
||||
|
||||
private ConditionOutcome checkServlets(ConfigurableListableBeanFactory beanFactory) {
|
||||
List<String> servlets = Arrays.asList(beanFactory.getBeanNamesForType(
|
||||
DispatcherServlet.class, false, false));
|
||||
private ConditionOutcome checkServlets(
|
||||
ConfigurableListableBeanFactory beanFactory) {
|
||||
List<String> servlets = Arrays.asList(beanFactory
|
||||
.getBeanNamesForType(DispatcherServlet.class, false, false));
|
||||
boolean containsDispatcherBean = beanFactory
|
||||
.containsBean(DEFAULT_DISPATCHER_SERVLET_BEAN_NAME);
|
||||
if (servlets.isEmpty()) {
|
||||
@@ -149,8 +150,8 @@ public class DispatcherServletAutoConfiguration {
|
||||
|
||||
private ConditionOutcome checkServletRegistrations(
|
||||
ConfigurableListableBeanFactory beanFactory) {
|
||||
List<String> registrations = Arrays.asList(beanFactory.getBeanNamesForType(
|
||||
ServletRegistrationBean.class, false, false));
|
||||
List<String> registrations = Arrays.asList(beanFactory
|
||||
.getBeanNamesForType(ServletRegistrationBean.class, false, false));
|
||||
boolean containsDispatcherRegistrationBean = beanFactory
|
||||
.containsBean(DEFAULT_DISPATCHER_SERVLET_REGISTRATION_BEAN_NAME);
|
||||
if (registrations.isEmpty()) {
|
||||
@@ -161,14 +162,14 @@ public class DispatcherServletAutoConfiguration {
|
||||
}
|
||||
return ConditionOutcome.match("no ServletRegistrationBean found");
|
||||
}
|
||||
if (registrations.contains(DEFAULT_DISPATCHER_SERVLET_REGISTRATION_BEAN_NAME)) {
|
||||
if (registrations
|
||||
.contains(DEFAULT_DISPATCHER_SERVLET_REGISTRATION_BEAN_NAME)) {
|
||||
return ConditionOutcome.noMatch("found ServletRegistrationBean named "
|
||||
+ DEFAULT_DISPATCHER_SERVLET_REGISTRATION_BEAN_NAME);
|
||||
}
|
||||
if (containsDispatcherRegistrationBean) {
|
||||
return ConditionOutcome
|
||||
.noMatch("found non-ServletRegistrationBean named "
|
||||
+ DEFAULT_DISPATCHER_SERVLET_REGISTRATION_BEAN_NAME);
|
||||
return ConditionOutcome.noMatch("found non-ServletRegistrationBean named "
|
||||
+ DEFAULT_DISPATCHER_SERVLET_REGISTRATION_BEAN_NAME);
|
||||
}
|
||||
return ConditionOutcome
|
||||
.match("one or more ServletRegistrationBeans is found and none is named "
|
||||
|
||||
@@ -220,8 +220,8 @@ public class ErrorMvcAutoConfiguration {
|
||||
* {@link EmbeddedServletContainerCustomizer} that configures the container's error
|
||||
* pages.
|
||||
*/
|
||||
private static class ErrorPageCustomizer implements
|
||||
EmbeddedServletContainerCustomizer, Ordered {
|
||||
private static class ErrorPageCustomizer
|
||||
implements EmbeddedServletContainerCustomizer, Ordered {
|
||||
|
||||
private final ServerProperties properties;
|
||||
|
||||
|
||||
@@ -64,8 +64,8 @@ class JacksonHttpMessageConvertersConfiguration {
|
||||
@ConditionalOnMissingBean
|
||||
public MappingJackson2XmlHttpMessageConverter mappingJackson2XmlHttpMessageConverter(
|
||||
Jackson2ObjectMapperBuilder builder) {
|
||||
return new MappingJackson2XmlHttpMessageConverter(builder.createXmlMapper(
|
||||
true).build());
|
||||
return new MappingJackson2XmlHttpMessageConverter(
|
||||
builder.createXmlMapper(true).build());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -42,8 +42,8 @@ class OnEnabledResourceChainCondition extends SpringBootCondition {
|
||||
RelaxedDataBinder binder = new RelaxedDataBinder(properties, "spring.resources");
|
||||
binder.bind(new PropertySourcesPropertyValues(environment.getPropertySources()));
|
||||
Boolean match = properties.getChain().getEnabled();
|
||||
return new ConditionOutcome(match, "Resource chain is "
|
||||
+ (match ? "enabled" : "disabled"));
|
||||
return new ConditionOutcome(match,
|
||||
"Resource chain is " + (match ? "enabled" : "disabled"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ public class ResourceProperties implements ResourceLoaderAware {
|
||||
"classpath:/static/", "classpath:/public/" };
|
||||
|
||||
private static final String[] RESOURCE_LOCATIONS;
|
||||
|
||||
static {
|
||||
RESOURCE_LOCATIONS = new String[CLASSPATH_RESOURCE_LOCATIONS.length
|
||||
+ SERVLET_RESOURCE_LOCATIONS.length];
|
||||
|
||||
@@ -73,8 +73,8 @@ import org.springframework.util.StringUtils;
|
||||
* @author Marcos Barbero
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "server", ignoreUnknownFields = true)
|
||||
public class ServerProperties implements EmbeddedServletContainerCustomizer,
|
||||
EnvironmentAware, Ordered {
|
||||
public class ServerProperties
|
||||
implements EmbeddedServletContainerCustomizer, EnvironmentAware, Ordered {
|
||||
|
||||
/**
|
||||
* Server HTTP port.
|
||||
@@ -735,7 +735,8 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer,
|
||||
|
||||
@Override
|
||||
public void customize(Context context) {
|
||||
context.setBackgroundProcessorDelay(Tomcat.this.backgroundProcessorDelay);
|
||||
context.setBackgroundProcessorDelay(
|
||||
Tomcat.this.backgroundProcessorDelay);
|
||||
}
|
||||
|
||||
});
|
||||
@@ -746,12 +747,11 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer,
|
||||
String protocolHeader = getProtocolHeader();
|
||||
String remoteIpHeader = getRemoteIpHeader();
|
||||
// For back compatibility the valve is also enabled if protocol-header is set
|
||||
if (StringUtils.hasText(protocolHeader)
|
||||
|| StringUtils.hasText(remoteIpHeader)
|
||||
if (StringUtils.hasText(protocolHeader) || StringUtils.hasText(remoteIpHeader)
|
||||
|| properties.getOrDeduceUseForwardHeaders()) {
|
||||
RemoteIpValve valve = new RemoteIpValve();
|
||||
valve.setProtocolHeader(StringUtils.hasLength(protocolHeader) ? protocolHeader
|
||||
: "X-Forwarded-Proto");
|
||||
valve.setProtocolHeader(StringUtils.hasLength(protocolHeader)
|
||||
? protocolHeader : "X-Forwarded-Proto");
|
||||
if (StringUtils.hasLength(remoteIpHeader)) {
|
||||
valve.setRemoteIpHeader(remoteIpHeader);
|
||||
}
|
||||
@@ -1085,8 +1085,8 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer,
|
||||
* {@link ServletContextInitializer} to apply appropriate parts of the {@link Session}
|
||||
* configuration.
|
||||
*/
|
||||
private static class SessionConfiguringInitializer implements
|
||||
ServletContextInitializer {
|
||||
private static class SessionConfiguringInitializer
|
||||
implements ServletContextInitializer {
|
||||
|
||||
private final Session session;
|
||||
|
||||
|
||||
@@ -81,11 +81,9 @@ public class ServerPropertiesAutoConfiguration {
|
||||
// a single bean
|
||||
String[] serverPropertiesBeans = this.applicationContext
|
||||
.getBeanNamesForType(ServerProperties.class);
|
||||
Assert.state(
|
||||
serverPropertiesBeans.length == 1,
|
||||
"Multiple ServerProperties beans registered "
|
||||
+ StringUtils
|
||||
.arrayToCommaDelimitedString(serverPropertiesBeans));
|
||||
Assert.state(serverPropertiesBeans.length == 1,
|
||||
"Multiple ServerProperties beans registered " + StringUtils
|
||||
.arrayToCommaDelimitedString(serverPropertiesBeans));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -180,8 +180,8 @@ public class WebMvcAutoConfiguration {
|
||||
@ConditionalOnMissingBean(name = "viewResolver", value = ContentNegotiatingViewResolver.class)
|
||||
public ContentNegotiatingViewResolver viewResolver(BeanFactory beanFactory) {
|
||||
ContentNegotiatingViewResolver resolver = new ContentNegotiatingViewResolver();
|
||||
resolver.setContentNegotiationManager(beanFactory
|
||||
.getBean(ContentNegotiationManager.class));
|
||||
resolver.setContentNegotiationManager(
|
||||
beanFactory.getBean(ContentNegotiationManager.class));
|
||||
// ContentNegotiatingViewResolver uses all the other view resolvers to locate
|
||||
// a view so it should have a high precedence
|
||||
resolver.setOrder(Ordered.HIGHEST_PRECEDENCE);
|
||||
@@ -205,8 +205,8 @@ public class WebMvcAutoConfiguration {
|
||||
public MessageCodesResolver getMessageCodesResolver() {
|
||||
if (this.mvcProperties.getMessageCodesResolverFormat() != null) {
|
||||
DefaultMessageCodesResolver resolver = new DefaultMessageCodesResolver();
|
||||
resolver.setMessageCodeFormatter(this.mvcProperties
|
||||
.getMessageCodesResolverFormat());
|
||||
resolver.setMessageCodeFormatter(
|
||||
this.mvcProperties.getMessageCodesResolverFormat());
|
||||
return resolver;
|
||||
}
|
||||
return null;
|
||||
@@ -242,8 +242,7 @@ public class WebMvcAutoConfiguration {
|
||||
.setCachePeriod(cachePeriod));
|
||||
}
|
||||
if (!registry.hasMappingForPattern("/**")) {
|
||||
registerResourceChain(registry
|
||||
.addResourceHandler("/**")
|
||||
registerResourceChain(registry.addResourceHandler("/**")
|
||||
.addResourceLocations(
|
||||
this.resourceProperties.getStaticLocations())
|
||||
.setCachePeriod(cachePeriod));
|
||||
|
||||
@@ -53,8 +53,8 @@ public class WebSocketMessagingAutoConfiguration {
|
||||
@ConditionalOnBean({ DelegatingWebSocketMessageBrokerConfiguration.class,
|
||||
ObjectMapper.class })
|
||||
@ConditionalOnClass({ ObjectMapper.class, AbstractMessageBrokerConfiguration.class })
|
||||
static class WebSocketMessageConverterConfiguration extends
|
||||
AbstractWebSocketMessageBrokerConfigurer {
|
||||
static class WebSocketMessageConverterConfiguration
|
||||
extends AbstractWebSocketMessageBrokerConfigurer {
|
||||
|
||||
@Autowired
|
||||
private ObjectMapper objectMapper;
|
||||
@@ -65,7 +65,8 @@ public class WebSocketMessagingAutoConfiguration {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean configureMessageConverters(List<MessageConverter> messageConverters) {
|
||||
public boolean configureMessageConverters(
|
||||
List<MessageConverter> messageConverters) {
|
||||
MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter();
|
||||
converter.setObjectMapper(this.objectMapper);
|
||||
DefaultContentTypeResolver resolver = new DefaultContentTypeResolver();
|
||||
|
||||
@@ -76,10 +76,10 @@ public class EnableAutoConfigurationImportSelectorTests {
|
||||
public void importsAreSelected() {
|
||||
configureExclusions(new String[0], new String[0], new String[0]);
|
||||
String[] imports = this.importSelector.selectImports(this.annotationMetadata);
|
||||
assertThat(
|
||||
imports.length,
|
||||
is(equalTo(SpringFactoriesLoader.loadFactoryNames(
|
||||
EnableAutoConfiguration.class, getClass().getClassLoader())
|
||||
assertThat(imports.length,
|
||||
is(equalTo(SpringFactoriesLoader
|
||||
.loadFactoryNames(EnableAutoConfiguration.class,
|
||||
getClass().getClassLoader())
|
||||
.size())));
|
||||
assertThat(ConditionEvaluationReport.get(this.beanFactory).getExclusions(),
|
||||
hasSize(0));
|
||||
@@ -99,7 +99,8 @@ public class EnableAutoConfigurationImportSelectorTests {
|
||||
@Test
|
||||
public void classNamesExclusionsAreApplied() {
|
||||
configureExclusions(new String[0],
|
||||
new String[] { VelocityAutoConfiguration.class.getName() }, new String[0]);
|
||||
new String[] { VelocityAutoConfiguration.class.getName() },
|
||||
new String[0]);
|
||||
String[] imports = this.importSelector.selectImports(this.annotationMetadata);
|
||||
assertThat(imports.length,
|
||||
is(equalTo(getAutoConfigurationClassNames().size() - 1)));
|
||||
@@ -120,15 +121,14 @@ public class EnableAutoConfigurationImportSelectorTests {
|
||||
|
||||
@Test
|
||||
public void severalPropertyExclusionsAreApplied() {
|
||||
configureExclusions(new String[0], new String[0], new String[] {
|
||||
FreeMarkerAutoConfiguration.class.getName(),
|
||||
VelocityAutoConfiguration.class.getName() });
|
||||
configureExclusions(new String[0], new String[0],
|
||||
new String[] { FreeMarkerAutoConfiguration.class.getName(),
|
||||
VelocityAutoConfiguration.class.getName() });
|
||||
|
||||
String[] imports = this.importSelector.selectImports(this.annotationMetadata);
|
||||
assertThat(imports.length,
|
||||
is(equalTo(getAutoConfigurationClassNames().size() - 2)));
|
||||
assertThat(
|
||||
ConditionEvaluationReport.get(this.beanFactory).getExclusions(),
|
||||
assertThat(ConditionEvaluationReport.get(this.beanFactory).getExclusions(),
|
||||
containsInAnyOrder(FreeMarkerAutoConfiguration.class.getName(),
|
||||
VelocityAutoConfiguration.class.getName()));
|
||||
}
|
||||
@@ -141,8 +141,7 @@ public class EnableAutoConfigurationImportSelectorTests {
|
||||
String[] imports = this.importSelector.selectImports(this.annotationMetadata);
|
||||
assertThat(imports.length,
|
||||
is(equalTo(getAutoConfigurationClassNames().size() - 3)));
|
||||
assertThat(
|
||||
ConditionEvaluationReport.get(this.beanFactory).getExclusions(),
|
||||
assertThat(ConditionEvaluationReport.get(this.beanFactory).getExclusions(),
|
||||
containsInAnyOrder(FreeMarkerAutoConfiguration.class.getName(),
|
||||
VelocityAutoConfiguration.class.getName(),
|
||||
ThymeleafAutoConfiguration.class.getName()));
|
||||
@@ -150,14 +149,13 @@ public class EnableAutoConfigurationImportSelectorTests {
|
||||
|
||||
private void configureExclusions(String[] classExclusion, String[] nameExclusion,
|
||||
String[] propertyExclusion) {
|
||||
given(
|
||||
this.annotationMetadata.getAnnotationAttributes(
|
||||
EnableAutoConfiguration.class.getName(), true)).willReturn(
|
||||
this.annotationAttributes);
|
||||
given(this.annotationAttributes.getStringArray("exclude")).willReturn(
|
||||
classExclusion);
|
||||
given(this.annotationAttributes.getStringArray("excludeName")).willReturn(
|
||||
nameExclusion);
|
||||
given(this.annotationMetadata
|
||||
.getAnnotationAttributes(EnableAutoConfiguration.class.getName(), true))
|
||||
.willReturn(this.annotationAttributes);
|
||||
given(this.annotationAttributes.getStringArray("exclude"))
|
||||
.willReturn(classExclusion);
|
||||
given(this.annotationAttributes.getStringArray("excludeName"))
|
||||
.willReturn(nameExclusion);
|
||||
if (propertyExclusion.length > 0) {
|
||||
String value = StringUtils.arrayToCommaDelimitedString(propertyExclusion);
|
||||
this.environment.setProperty("spring.autoconfigure.exclude", value);
|
||||
|
||||
@@ -77,8 +77,8 @@ public class SpringApplicationAdminJmxAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void notRegisteredByDefault() throws MalformedObjectNameException,
|
||||
InstanceNotFoundException {
|
||||
public void notRegisteredByDefault()
|
||||
throws MalformedObjectNameException, InstanceNotFoundException {
|
||||
load();
|
||||
this.thrown.expect(InstanceNotFoundException.class);
|
||||
this.mBeanServer.getObjectInstance(createDefaultObjectName());
|
||||
@@ -114,12 +114,13 @@ public class SpringApplicationAdminJmxAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void registerWithSimpleWebApp() throws Exception {
|
||||
this.context = new SpringApplicationBuilder().sources(
|
||||
EmbeddedServletContainerAutoConfiguration.class,
|
||||
ServerPropertiesAutoConfiguration.class,
|
||||
DispatcherServletAutoConfiguration.class, JmxAutoConfiguration.class,
|
||||
SpringApplicationAdminJmxAutoConfiguration.class).run(
|
||||
"--" + ENABLE_ADMIN_PROP, "--server.port=0");
|
||||
this.context = new SpringApplicationBuilder()
|
||||
.sources(EmbeddedServletContainerAutoConfiguration.class,
|
||||
ServerPropertiesAutoConfiguration.class,
|
||||
DispatcherServletAutoConfiguration.class,
|
||||
JmxAutoConfiguration.class,
|
||||
SpringApplicationAdminJmxAutoConfiguration.class)
|
||||
.run("--" + ENABLE_ADMIN_PROP, "--server.port=0");
|
||||
assertTrue(this.context instanceof EmbeddedWebApplicationContext);
|
||||
assertEquals(true, this.mBeanServer.getAttribute(createDefaultObjectName(),
|
||||
"EmbeddedWebApplication"));
|
||||
|
||||
@@ -112,7 +112,8 @@ public class CacheAutoConfigurationTests {
|
||||
@Test
|
||||
public void cacheManagerBackOff() {
|
||||
load(CustomCacheManagerConfiguration.class);
|
||||
ConcurrentMapCacheManager cacheManager = validateCacheManager(ConcurrentMapCacheManager.class);
|
||||
ConcurrentMapCacheManager cacheManager = validateCacheManager(
|
||||
ConcurrentMapCacheManager.class);
|
||||
assertThat(cacheManager.getCacheNames(), contains("custom1"));
|
||||
assertThat(cacheManager.getCacheNames(), hasSize(1));
|
||||
}
|
||||
@@ -120,7 +121,8 @@ public class CacheAutoConfigurationTests {
|
||||
@Test
|
||||
public void cacheManagerFromSupportBackOff() {
|
||||
load(CustomCacheManagerFromSupportConfiguration.class);
|
||||
ConcurrentMapCacheManager cacheManager = validateCacheManager(ConcurrentMapCacheManager.class);
|
||||
ConcurrentMapCacheManager cacheManager = validateCacheManager(
|
||||
ConcurrentMapCacheManager.class);
|
||||
assertThat(cacheManager.getCacheNames(), contains("custom1"));
|
||||
assertThat(cacheManager.getCacheNames(), hasSize(1));
|
||||
}
|
||||
@@ -143,7 +145,8 @@ public class CacheAutoConfigurationTests {
|
||||
@Test
|
||||
public void simpleCacheExplicit() {
|
||||
load(DefaultCacheConfiguration.class, "spring.cache.type=simple");
|
||||
ConcurrentMapCacheManager cacheManager = validateCacheManager(ConcurrentMapCacheManager.class);
|
||||
ConcurrentMapCacheManager cacheManager = validateCacheManager(
|
||||
ConcurrentMapCacheManager.class);
|
||||
assertThat(cacheManager.getCacheNames(), empty());
|
||||
}
|
||||
|
||||
@@ -151,7 +154,8 @@ public class CacheAutoConfigurationTests {
|
||||
public void simpleCacheExplicitWithCacheNames() {
|
||||
load(DefaultCacheConfiguration.class, "spring.cache.type=simple",
|
||||
"spring.cache.cacheNames[0]=foo", "spring.cache.cacheNames[1]=bar");
|
||||
ConcurrentMapCacheManager cacheManager = validateCacheManager(ConcurrentMapCacheManager.class);
|
||||
ConcurrentMapCacheManager cacheManager = validateCacheManager(
|
||||
ConcurrentMapCacheManager.class);
|
||||
assertThat(cacheManager.getCacheNames(), containsInAnyOrder("foo", "bar"));
|
||||
assertThat(cacheManager.getCacheNames(), hasSize(2));
|
||||
}
|
||||
@@ -302,7 +306,8 @@ public class CacheAutoConfigurationTests {
|
||||
@Test
|
||||
public void ehCacheCacheWithCaches() {
|
||||
load(DefaultCacheConfiguration.class, "spring.cache.type=ehcache");
|
||||
EhCacheCacheManager cacheManager = validateCacheManager(EhCacheCacheManager.class);
|
||||
EhCacheCacheManager cacheManager = validateCacheManager(
|
||||
EhCacheCacheManager.class);
|
||||
assertThat(cacheManager.getCacheNames(),
|
||||
containsInAnyOrder("cacheTest1", "cacheTest2"));
|
||||
assertThat(cacheManager.getCacheNames(), hasSize(2));
|
||||
@@ -314,7 +319,8 @@ public class CacheAutoConfigurationTests {
|
||||
public void ehCacheCacheWithConfig() {
|
||||
load(DefaultCacheConfiguration.class, "spring.cache.type=ehcache",
|
||||
"spring.cache.ehcache.config=cache/ehcache-override.xml");
|
||||
EhCacheCacheManager cacheManager = validateCacheManager(EhCacheCacheManager.class);
|
||||
EhCacheCacheManager cacheManager = validateCacheManager(
|
||||
EhCacheCacheManager.class);
|
||||
assertThat(cacheManager.getCacheNames(),
|
||||
containsInAnyOrder("cacheOverrideTest1", "cacheOverrideTest2"));
|
||||
assertThat(cacheManager.getCacheNames(), hasSize(2));
|
||||
@@ -323,7 +329,8 @@ public class CacheAutoConfigurationTests {
|
||||
@Test
|
||||
public void ehCacheCacheWithExistingCacheManager() {
|
||||
load(EhCacheCustomCacheManager.class, "spring.cache.type=ehcache");
|
||||
EhCacheCacheManager cacheManager = validateCacheManager(EhCacheCacheManager.class);
|
||||
EhCacheCacheManager cacheManager = validateCacheManager(
|
||||
EhCacheCacheManager.class);
|
||||
assertThat(cacheManager.getCacheManager(),
|
||||
equalTo(this.context.getBean("customEhCacheCacheManager")));
|
||||
}
|
||||
@@ -331,7 +338,8 @@ public class CacheAutoConfigurationTests {
|
||||
@Test
|
||||
public void hazelcastCacheExplicit() {
|
||||
load(DefaultCacheConfiguration.class, "spring.cache.type=hazelcast");
|
||||
HazelcastCacheManager cacheManager = validateCacheManager(HazelcastCacheManager.class);
|
||||
HazelcastCacheManager cacheManager = validateCacheManager(
|
||||
HazelcastCacheManager.class);
|
||||
// NOTE: the hazelcast implementation knows about a cache in a lazy manner.
|
||||
cacheManager.getCache("defaultCache");
|
||||
assertThat(cacheManager.getCacheNames(), containsInAnyOrder("defaultCache"));
|
||||
@@ -343,10 +351,10 @@ public class CacheAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void hazelcastCacheWithConfig() {
|
||||
load(DefaultCacheConfiguration.class,
|
||||
"spring.cache.type=hazelcast",
|
||||
load(DefaultCacheConfiguration.class, "spring.cache.type=hazelcast",
|
||||
"spring.cache.hazelcast.config=org/springframework/boot/autoconfigure/cache/hazelcast-specific.xml");
|
||||
HazelcastCacheManager cacheManager = validateCacheManager(HazelcastCacheManager.class);
|
||||
HazelcastCacheManager cacheManager = validateCacheManager(
|
||||
HazelcastCacheManager.class);
|
||||
cacheManager.getCache("foobar");
|
||||
assertThat(cacheManager.getCacheNames(), containsInAnyOrder("foobar"));
|
||||
assertThat(cacheManager.getCacheNames(), hasSize(1));
|
||||
@@ -363,7 +371,8 @@ public class CacheAutoConfigurationTests {
|
||||
@Test
|
||||
public void hazelcastCacheWithExistingHazelcastInstance() {
|
||||
load(HazelcastCustomHazelcastInstance.class, "spring.cache.type=hazelcast");
|
||||
HazelcastCacheManager cacheManager = validateCacheManager(HazelcastCacheManager.class);
|
||||
HazelcastCacheManager cacheManager = validateCacheManager(
|
||||
HazelcastCacheManager.class);
|
||||
assertThat(
|
||||
new DirectFieldAccessor(cacheManager)
|
||||
.getPropertyValue("hazelcastInstance"),
|
||||
@@ -376,15 +385,14 @@ public class CacheAutoConfigurationTests {
|
||||
configs.add(DefaultCacheConfiguration.class);
|
||||
configs.add(HazelcastAutoConfiguration.class);
|
||||
String mainConfig = "org/springframework/boot/autoconfigure/hazelcast/hazelcast-specific.xml";
|
||||
doLoad(configs, "spring.cache.type=hazelcast", "spring.hazelcast.config="
|
||||
+ mainConfig);
|
||||
HazelcastCacheManager cacheManager = validateCacheManager(HazelcastCacheManager.class);
|
||||
doLoad(configs, "spring.cache.type=hazelcast",
|
||||
"spring.hazelcast.config=" + mainConfig);
|
||||
HazelcastCacheManager cacheManager = validateCacheManager(
|
||||
HazelcastCacheManager.class);
|
||||
HazelcastInstance hazelcastInstance = this.context
|
||||
.getBean(HazelcastInstance.class);
|
||||
assertThat(
|
||||
new DirectFieldAccessor(cacheManager)
|
||||
.getPropertyValue("hazelcastInstance"),
|
||||
equalTo((Object) hazelcastInstance));
|
||||
assertThat(new DirectFieldAccessor(cacheManager).getPropertyValue(
|
||||
"hazelcastInstance"), equalTo((Object) hazelcastInstance));
|
||||
assertThat(hazelcastInstance.getConfig().getConfigurationFile(),
|
||||
equalTo(new ClassPathResource(mainConfig).getFile()));
|
||||
}
|
||||
@@ -397,11 +405,13 @@ public class CacheAutoConfigurationTests {
|
||||
configs.add(HazelcastAutoConfiguration.class);
|
||||
String mainConfig = "org/springframework/boot/autoconfigure/hazelcast/hazelcast-specific.xml";
|
||||
String cacheConfig = "org/springframework/boot/autoconfigure/cache/hazelcast-specific.xml";
|
||||
doLoad(configs, "spring.cache.type=hazelcast", "spring.cache.hazelcast.config="
|
||||
+ cacheConfig, "spring.hazelcast.config=" + mainConfig);
|
||||
doLoad(configs, "spring.cache.type=hazelcast",
|
||||
"spring.cache.hazelcast.config=" + cacheConfig,
|
||||
"spring.hazelcast.config=" + mainConfig);
|
||||
HazelcastInstance hazelcastInstance = this.context
|
||||
.getBean(HazelcastInstance.class);
|
||||
HazelcastCacheManager cacheManager = validateCacheManager(HazelcastCacheManager.class);
|
||||
HazelcastCacheManager cacheManager = validateCacheManager(
|
||||
HazelcastCacheManager.class);
|
||||
HazelcastInstance cacheHazelcastInstance = (HazelcastInstance) new DirectFieldAccessor(
|
||||
cacheManager).getPropertyValue("hazelcastInstance");
|
||||
assertThat(cacheHazelcastInstance, not(hazelcastInstance)); // Our custom
|
||||
@@ -440,7 +450,8 @@ public class CacheAutoConfigurationTests {
|
||||
public void infinispanCacheWithConfig() {
|
||||
load(DefaultCacheConfiguration.class, "spring.cache.type=infinispan",
|
||||
"spring.cache.infinispan.config=infinispan.xml");
|
||||
SpringEmbeddedCacheManager cacheManager = validateCacheManager(SpringEmbeddedCacheManager.class);
|
||||
SpringEmbeddedCacheManager cacheManager = validateCacheManager(
|
||||
SpringEmbeddedCacheManager.class);
|
||||
assertThat(cacheManager.getCacheNames(), containsInAnyOrder("foo", "bar"));
|
||||
}
|
||||
|
||||
@@ -448,7 +459,8 @@ public class CacheAutoConfigurationTests {
|
||||
public void infinispanCacheWithCaches() {
|
||||
load(DefaultCacheConfiguration.class, "spring.cache.type=infinispan",
|
||||
"spring.cache.cacheNames[0]=foo", "spring.cache.cacheNames[1]=bar");
|
||||
SpringEmbeddedCacheManager cacheManager = validateCacheManager(SpringEmbeddedCacheManager.class);
|
||||
SpringEmbeddedCacheManager cacheManager = validateCacheManager(
|
||||
SpringEmbeddedCacheManager.class);
|
||||
assertThat(cacheManager.getCacheNames(), containsInAnyOrder("foo", "bar"));
|
||||
assertThat(cacheManager.getCacheNames(), hasSize(2));
|
||||
}
|
||||
@@ -457,7 +469,8 @@ public class CacheAutoConfigurationTests {
|
||||
public void infinispanCacheWithCachesAndCustomConfig() {
|
||||
load(InfinispanCustomConfiguration.class, "spring.cache.type=infinispan",
|
||||
"spring.cache.cacheNames[0]=foo", "spring.cache.cacheNames[1]=bar");
|
||||
SpringEmbeddedCacheManager cacheManager = validateCacheManager(SpringEmbeddedCacheManager.class);
|
||||
SpringEmbeddedCacheManager cacheManager = validateCacheManager(
|
||||
SpringEmbeddedCacheManager.class);
|
||||
assertThat(cacheManager.getCacheNames(), containsInAnyOrder("foo", "bar"));
|
||||
assertThat(cacheManager.getCacheNames(), hasSize(2));
|
||||
|
||||
@@ -617,8 +630,8 @@ public class CacheAutoConfigurationTests {
|
||||
@Bean
|
||||
public javax.cache.CacheManager customJCacheCacheManager() {
|
||||
javax.cache.CacheManager cacheManager = mock(javax.cache.CacheManager.class);
|
||||
given(cacheManager.getCacheNames()).willReturn(
|
||||
Collections.<String>emptyList());
|
||||
given(cacheManager.getCacheNames())
|
||||
.willReturn(Collections.<String>emptyList());
|
||||
return cacheManager;
|
||||
}
|
||||
|
||||
@@ -634,8 +647,8 @@ public class CacheAutoConfigurationTests {
|
||||
@Override
|
||||
public void customize(javax.cache.CacheManager cacheManager) {
|
||||
MutableConfiguration<?, ?> config = new MutableConfiguration<Object, Object>();
|
||||
config.setExpiryPolicyFactory(CreatedExpiryPolicy
|
||||
.factoryOf(Duration.TEN_MINUTES));
|
||||
config.setExpiryPolicyFactory(
|
||||
CreatedExpiryPolicy.factoryOf(Duration.TEN_MINUTES));
|
||||
config.setStatisticsEnabled(true);
|
||||
cacheManager.createCache("custom1", config);
|
||||
cacheManager.destroyCache("bar");
|
||||
@@ -651,7 +664,8 @@ public class CacheAutoConfigurationTests {
|
||||
|
||||
@Bean
|
||||
public net.sf.ehcache.CacheManager customEhCacheCacheManager() {
|
||||
net.sf.ehcache.CacheManager cacheManager = mock(net.sf.ehcache.CacheManager.class);
|
||||
net.sf.ehcache.CacheManager cacheManager = mock(
|
||||
net.sf.ehcache.CacheManager.class);
|
||||
given(cacheManager.getStatus()).willReturn(Status.STATUS_ALIVE);
|
||||
given(cacheManager.getCacheNames()).willReturn(new String[0]);
|
||||
return cacheManager;
|
||||
@@ -696,8 +710,8 @@ public class CacheAutoConfigurationTests {
|
||||
|
||||
@Configuration
|
||||
@Import({ GenericCacheConfiguration.class, RedisCacheConfiguration.class })
|
||||
static class CustomCacheManagerFromSupportConfiguration extends
|
||||
CachingConfigurerSupport {
|
||||
static class CustomCacheManagerFromSupportConfiguration
|
||||
extends CachingConfigurerSupport {
|
||||
|
||||
@Override
|
||||
@Bean
|
||||
|
||||
@@ -59,8 +59,8 @@ public class MockCachingProvider implements CachingProvider {
|
||||
return caches.get(cacheName);
|
||||
}
|
||||
});
|
||||
given(cacheManager.createCache(anyString(), any(Configuration.class))).will(
|
||||
new Answer<Cache>() {
|
||||
given(cacheManager.createCache(anyString(), any(Configuration.class)))
|
||||
.will(new Answer<Cache>() {
|
||||
@Override
|
||||
public Cache answer(InvocationOnMock invocationOnMock)
|
||||
throws Throwable {
|
||||
|
||||
@@ -88,8 +88,8 @@ public class ConditionalOnSingleCandidateTests {
|
||||
public void invalidAnnotationTwoTypes() {
|
||||
this.thrown.expect(IllegalStateException.class);
|
||||
this.thrown.expectCause(isA(IllegalArgumentException.class));
|
||||
this.thrown.expectMessage(OnBeanSingleCandidateTwoTypesConfiguration.class
|
||||
.getName());
|
||||
this.thrown.expectMessage(
|
||||
OnBeanSingleCandidateTwoTypesConfiguration.class.getName());
|
||||
load(OnBeanSingleCandidateTwoTypesConfiguration.class);
|
||||
}
|
||||
|
||||
@@ -97,8 +97,8 @@ public class ConditionalOnSingleCandidateTests {
|
||||
public void invalidAnnotationNoType() {
|
||||
this.thrown.expect(IllegalStateException.class);
|
||||
this.thrown.expectCause(isA(IllegalArgumentException.class));
|
||||
this.thrown.expectMessage(OnBeanSingleCandidateNoTypeConfiguration.class
|
||||
.getName());
|
||||
this.thrown
|
||||
.expectMessage(OnBeanSingleCandidateNoTypeConfiguration.class.getName());
|
||||
load(OnBeanSingleCandidateNoTypeConfiguration.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -98,8 +98,8 @@ public class ResourceConditionTests {
|
||||
}
|
||||
}
|
||||
|
||||
private static class UnknownDefaultLocationResourceCondition extends
|
||||
ResourceCondition {
|
||||
private static class UnknownDefaultLocationResourceCondition
|
||||
extends ResourceCondition {
|
||||
|
||||
UnknownDefaultLocationResourceCondition() {
|
||||
super("test", "spring.foo.test", "config",
|
||||
|
||||
@@ -59,7 +59,8 @@ public class CassandraDataAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@ComponentScan(excludeFilters = @ComponentScan.Filter(classes = { Session.class }, type = FilterType.ASSIGNABLE_TYPE))
|
||||
@ComponentScan(excludeFilters = @ComponentScan.Filter(classes = {
|
||||
Session.class }, type = FilterType.ASSIGNABLE_TYPE) )
|
||||
static class TestExcludeConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@@ -111,7 +111,8 @@ public class CassandraRepositoriesAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@ComponentScan(excludeFilters = @ComponentScan.Filter(classes = { Session.class }, type = FilterType.ASSIGNABLE_TYPE))
|
||||
@ComponentScan(excludeFilters = @ComponentScan.Filter(classes = {
|
||||
Session.class }, type = FilterType.ASSIGNABLE_TYPE) )
|
||||
static class TestExcludeConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@@ -70,26 +70,27 @@ public class RedisAutoConfigurationTests {
|
||||
@Test
|
||||
public void testOverrideRedisConfiguration() throws Exception {
|
||||
load("spring.redis.host:foo", "spring.redis.database:1");
|
||||
assertEquals("foo", this.context.getBean(JedisConnectionFactory.class)
|
||||
.getHostName());
|
||||
assertEquals("foo",
|
||||
this.context.getBean(JedisConnectionFactory.class).getHostName());
|
||||
assertEquals(1, this.context.getBean(JedisConnectionFactory.class).getDatabase());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRedisConfigurationWithPool() throws Exception {
|
||||
load("spring.redis.host:foo", "spring.redis.pool.max-idle:1");
|
||||
assertEquals("foo", this.context.getBean(JedisConnectionFactory.class)
|
||||
.getHostName());
|
||||
assertEquals(1, this.context.getBean(JedisConnectionFactory.class)
|
||||
.getPoolConfig().getMaxIdle());
|
||||
assertEquals("foo",
|
||||
this.context.getBean(JedisConnectionFactory.class).getHostName());
|
||||
assertEquals(1, this.context.getBean(JedisConnectionFactory.class).getPoolConfig()
|
||||
.getMaxIdle());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRedisConfigurationWithTimeout() throws Exception {
|
||||
load("spring.redis.host:foo", "spring.redis.timeout:100");
|
||||
assertEquals("foo", this.context.getBean(JedisConnectionFactory.class)
|
||||
.getHostName());
|
||||
assertEquals(100, this.context.getBean(JedisConnectionFactory.class).getTimeout());
|
||||
assertEquals("foo",
|
||||
this.context.getBean(JedisConnectionFactory.class).getHostName());
|
||||
assertEquals(100,
|
||||
this.context.getBean(JedisConnectionFactory.class).getTimeout());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -170,8 +170,7 @@ public class FlywayAutoConfigurationTests {
|
||||
@Test
|
||||
public void customFlywayMigrationStrategy() throws Exception {
|
||||
registerAndRefresh(EmbeddedDataSourceConfiguration.class,
|
||||
FlywayAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class,
|
||||
FlywayAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class,
|
||||
MockFlywayMigrationStrategy.class);
|
||||
assertNotNull(this.context.getBean(Flyway.class));
|
||||
this.context.getBean(MockFlywayMigrationStrategy.class).assertCalled();
|
||||
@@ -248,7 +247,8 @@ public class FlywayAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Component
|
||||
protected static class MockFlywayMigrationStrategy implements FlywayMigrationStrategy {
|
||||
protected static class MockFlywayMigrationStrategy
|
||||
implements FlywayMigrationStrategy {
|
||||
|
||||
private boolean called = false;
|
||||
|
||||
|
||||
@@ -148,7 +148,8 @@ public class GroovyTemplateAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void customTemplateLoaderPath() throws Exception {
|
||||
registerAndRefreshContext("spring.groovy.template.resource-loader-path:classpath:/custom-templates/");
|
||||
registerAndRefreshContext(
|
||||
"spring.groovy.template.resource-loader-path:classpath:/custom-templates/");
|
||||
MockHttpServletResponse response = render("custom");
|
||||
String result = response.getContentAsString();
|
||||
assertThat(result, containsString("custom"));
|
||||
@@ -168,14 +169,16 @@ public class GroovyTemplateAutoConfigurationTests {
|
||||
MarkupTemplateEngine engine = config.getTemplateEngine();
|
||||
Writer writer = new StringWriter();
|
||||
engine.createTemplate(new ClassPathResource("templates/message.tpl").getFile())
|
||||
.make(new HashMap<String, Object>(Collections.singletonMap("greeting",
|
||||
"Hello World"))).writeTo(writer);
|
||||
.make(new HashMap<String, Object>(
|
||||
Collections.singletonMap("greeting", "Hello World")))
|
||||
.writeTo(writer);
|
||||
assertThat(writer.toString(), containsString("Hello World"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customConfiguration() throws Exception {
|
||||
registerAndRefreshContext("spring.groovy.template.configuration.auto-indent:true");
|
||||
registerAndRefreshContext(
|
||||
"spring.groovy.template.configuration.auto-indent:true");
|
||||
assertThat(this.context.getBean(GroovyMarkupConfigurer.class).isAutoIndent(),
|
||||
is(true));
|
||||
}
|
||||
|
||||
@@ -74,8 +74,8 @@ public class H2ConsoleAutoConfigurationIntegrationTests {
|
||||
public void someOtherPrincipal() throws Exception {
|
||||
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
|
||||
.apply(springSecurity()).build();
|
||||
mockMvc.perform(get("/h2-console/").with(user("test").roles("FOO"))).andExpect(
|
||||
status().isForbidden());
|
||||
mockMvc.perform(get("/h2-console/").with(user("test").roles("FOO")))
|
||||
.andExpect(status().isForbidden());
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
||||
@@ -98,9 +98,8 @@ public class HypermediaAutoConfigurationTests {
|
||||
this.context.refresh();
|
||||
ObjectMapper objectMapper = this.context.getBean("_halObjectMapper",
|
||||
ObjectMapper.class);
|
||||
assertThat(
|
||||
objectMapper.getSerializationConfig().isEnabled(
|
||||
SerializationFeature.INDENT_OUTPUT), is(false));
|
||||
assertThat(objectMapper.getSerializationConfig()
|
||||
.isEnabled(SerializationFeature.INDENT_OUTPUT), is(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -127,10 +126,8 @@ public class HypermediaAutoConfigurationTests {
|
||||
.getBean(RequestMappingHandlerAdapter.class);
|
||||
for (HttpMessageConverter<?> converter : handlerAdapter.getMessageConverters()) {
|
||||
if (converter instanceof TypeConstrainedMappingJackson2HttpMessageConverter) {
|
||||
assertThat(
|
||||
converter.getSupportedMediaTypes(),
|
||||
containsInAnyOrder(MediaType.APPLICATION_JSON,
|
||||
MediaTypes.HAL_JSON));
|
||||
assertThat(converter.getSupportedMediaTypes(), containsInAnyOrder(
|
||||
MediaType.APPLICATION_JSON, MediaTypes.HAL_JSON));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,10 +155,8 @@ public class JacksonAutoConfigurationTests {
|
||||
@Test
|
||||
public void customDateFormatClass() throws Exception {
|
||||
this.context.register(JacksonAutoConfiguration.class);
|
||||
EnvironmentTestUtils
|
||||
.addEnvironment(
|
||||
this.context,
|
||||
"spring.jackson.date-format:org.springframework.boot.autoconfigure.jackson.JacksonAutoConfigurationTests.MyDateFormat");
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
"spring.jackson.date-format:org.springframework.boot.autoconfigure.jackson.JacksonAutoConfigurationTests.MyDateFormat");
|
||||
this.context.refresh();
|
||||
ObjectMapper mapper = this.context.getBean(ObjectMapper.class);
|
||||
assertThat(mapper.getDateFormat(), is(instanceOf(MyDateFormat.class)));
|
||||
@@ -175,9 +173,8 @@ public class JacksonAutoConfigurationTests {
|
||||
@Test
|
||||
public void customPropertyNamingStrategyField() throws Exception {
|
||||
this.context.register(JacksonAutoConfiguration.class);
|
||||
EnvironmentTestUtils
|
||||
.addEnvironment(this.context,
|
||||
"spring.jackson.property-naming-strategy:CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES");
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
"spring.jackson.property-naming-strategy:CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES");
|
||||
this.context.refresh();
|
||||
ObjectMapper mapper = this.context.getBean(ObjectMapper.class);
|
||||
assertThat(mapper.getPropertyNamingStrategy(),
|
||||
@@ -187,10 +184,8 @@ public class JacksonAutoConfigurationTests {
|
||||
@Test
|
||||
public void customPropertyNamingStrategyClass() throws Exception {
|
||||
this.context.register(JacksonAutoConfiguration.class);
|
||||
EnvironmentTestUtils
|
||||
.addEnvironment(
|
||||
this.context,
|
||||
"spring.jackson.property-naming-strategy:com.fasterxml.jackson.databind.PropertyNamingStrategy.LowerCaseWithUnderscoresStrategy");
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
"spring.jackson.property-naming-strategy:com.fasterxml.jackson.databind.PropertyNamingStrategy.LowerCaseWithUnderscoresStrategy");
|
||||
this.context.refresh();
|
||||
ObjectMapper mapper = this.context.getBean(ObjectMapper.class);
|
||||
assertThat(mapper.getPropertyNamingStrategy(),
|
||||
@@ -205,8 +200,8 @@ public class JacksonAutoConfigurationTests {
|
||||
this.context.refresh();
|
||||
ObjectMapper mapper = this.context.getBean(ObjectMapper.class);
|
||||
assertFalse(SerializationFeature.INDENT_OUTPUT.enabledByDefault());
|
||||
assertTrue(mapper.getSerializationConfig().hasSerializationFeatures(
|
||||
SerializationFeature.INDENT_OUTPUT.getMask()));
|
||||
assertTrue(mapper.getSerializationConfig()
|
||||
.hasSerializationFeatures(SerializationFeature.INDENT_OUTPUT.getMask()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -253,10 +248,10 @@ public class JacksonAutoConfigurationTests {
|
||||
this.context.refresh();
|
||||
ObjectMapper mapper = this.context.getBean(ObjectMapper.class);
|
||||
assertFalse(MapperFeature.REQUIRE_SETTERS_FOR_GETTERS.enabledByDefault());
|
||||
assertTrue(mapper.getSerializationConfig().hasMapperFeatures(
|
||||
MapperFeature.REQUIRE_SETTERS_FOR_GETTERS.getMask()));
|
||||
assertTrue(mapper.getDeserializationConfig().hasMapperFeatures(
|
||||
MapperFeature.REQUIRE_SETTERS_FOR_GETTERS.getMask()));
|
||||
assertTrue(mapper.getSerializationConfig()
|
||||
.hasMapperFeatures(MapperFeature.REQUIRE_SETTERS_FOR_GETTERS.getMask()));
|
||||
assertTrue(mapper.getDeserializationConfig()
|
||||
.hasMapperFeatures(MapperFeature.REQUIRE_SETTERS_FOR_GETTERS.getMask()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -267,10 +262,10 @@ public class JacksonAutoConfigurationTests {
|
||||
this.context.refresh();
|
||||
ObjectMapper mapper = this.context.getBean(ObjectMapper.class);
|
||||
assertTrue(MapperFeature.USE_ANNOTATIONS.enabledByDefault());
|
||||
assertFalse(mapper.getDeserializationConfig().hasMapperFeatures(
|
||||
MapperFeature.USE_ANNOTATIONS.getMask()));
|
||||
assertFalse(mapper.getSerializationConfig().hasMapperFeatures(
|
||||
MapperFeature.USE_ANNOTATIONS.getMask()));
|
||||
assertFalse(mapper.getDeserializationConfig()
|
||||
.hasMapperFeatures(MapperFeature.USE_ANNOTATIONS.getMask()));
|
||||
assertFalse(mapper.getSerializationConfig()
|
||||
.hasMapperFeatures(MapperFeature.USE_ANNOTATIONS.getMask()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -303,8 +298,8 @@ public class JacksonAutoConfigurationTests {
|
||||
this.context.refresh();
|
||||
ObjectMapper mapper = this.context.getBean(ObjectMapper.class);
|
||||
assertFalse(JsonGenerator.Feature.WRITE_NUMBERS_AS_STRINGS.enabledByDefault());
|
||||
assertTrue(mapper.getFactory().isEnabled(
|
||||
JsonGenerator.Feature.WRITE_NUMBERS_AS_STRINGS));
|
||||
assertTrue(mapper.getFactory()
|
||||
.isEnabled(JsonGenerator.Feature.WRITE_NUMBERS_AS_STRINGS));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -315,8 +310,8 @@ public class JacksonAutoConfigurationTests {
|
||||
this.context.refresh();
|
||||
ObjectMapper mapper = this.context.getBean(ObjectMapper.class);
|
||||
assertTrue(JsonGenerator.Feature.AUTO_CLOSE_TARGET.enabledByDefault());
|
||||
assertFalse(mapper.getFactory()
|
||||
.isEnabled(JsonGenerator.Feature.AUTO_CLOSE_TARGET));
|
||||
assertFalse(
|
||||
mapper.getFactory().isEnabled(JsonGenerator.Feature.AUTO_CLOSE_TARGET));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -327,24 +322,24 @@ public class JacksonAutoConfigurationTests {
|
||||
.getBean(Jackson2ObjectMapperBuilder.class);
|
||||
ObjectMapper mapper = builder.build();
|
||||
assertTrue(MapperFeature.DEFAULT_VIEW_INCLUSION.enabledByDefault());
|
||||
assertFalse(mapper.getDeserializationConfig().isEnabled(
|
||||
MapperFeature.DEFAULT_VIEW_INCLUSION));
|
||||
assertFalse(mapper.getDeserializationConfig()
|
||||
.isEnabled(MapperFeature.DEFAULT_VIEW_INCLUSION));
|
||||
assertTrue(MapperFeature.DEFAULT_VIEW_INCLUSION.enabledByDefault());
|
||||
assertFalse(mapper.getDeserializationConfig().isEnabled(
|
||||
MapperFeature.DEFAULT_VIEW_INCLUSION));
|
||||
assertFalse(mapper.getSerializationConfig().isEnabled(
|
||||
MapperFeature.DEFAULT_VIEW_INCLUSION));
|
||||
assertFalse(mapper.getDeserializationConfig()
|
||||
.isEnabled(MapperFeature.DEFAULT_VIEW_INCLUSION));
|
||||
assertFalse(mapper.getSerializationConfig()
|
||||
.isEnabled(MapperFeature.DEFAULT_VIEW_INCLUSION));
|
||||
assertTrue(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES.enabledByDefault());
|
||||
assertFalse(mapper.getDeserializationConfig().isEnabled(
|
||||
DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));
|
||||
assertFalse(mapper.getDeserializationConfig()
|
||||
.isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void moduleBeansAndWellKnownModulesAreRegisteredWithTheObjectMapperBuilder() {
|
||||
this.context.register(ModuleConfig.class, JacksonAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
ObjectMapper objectMapper = this.context.getBean(
|
||||
Jackson2ObjectMapperBuilder.class).build();
|
||||
ObjectMapper objectMapper = this.context
|
||||
.getBean(Jackson2ObjectMapperBuilder.class).build();
|
||||
assertThat(this.context.getBean(CustomModule.class).getOwners(),
|
||||
hasItem((ObjectCodec) objectMapper));
|
||||
assertThat(objectMapper.canSerialize(LocalDateTime.class), is(true));
|
||||
@@ -354,8 +349,8 @@ public class JacksonAutoConfigurationTests {
|
||||
public void defaultSerializationInclusion() {
|
||||
this.context.register(JacksonAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
ObjectMapper objectMapper = this.context.getBean(
|
||||
Jackson2ObjectMapperBuilder.class).build();
|
||||
ObjectMapper objectMapper = this.context
|
||||
.getBean(Jackson2ObjectMapperBuilder.class).build();
|
||||
assertThat(objectMapper.getSerializationConfig().getSerializationInclusion(),
|
||||
is(JsonInclude.Include.ALWAYS));
|
||||
}
|
||||
@@ -366,8 +361,8 @@ public class JacksonAutoConfigurationTests {
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
"spring.jackson.serialization-inclusion:non_null");
|
||||
this.context.refresh();
|
||||
ObjectMapper objectMapper = this.context.getBean(
|
||||
Jackson2ObjectMapperBuilder.class).build();
|
||||
ObjectMapper objectMapper = this.context
|
||||
.getBean(Jackson2ObjectMapperBuilder.class).build();
|
||||
assertThat(objectMapper.getSerializationConfig().getSerializationInclusion(),
|
||||
is(JsonInclude.Include.NON_NULL));
|
||||
}
|
||||
@@ -381,8 +376,8 @@ public class JacksonAutoConfigurationTests {
|
||||
"spring.jackson.date-format:zzzz");
|
||||
EnvironmentTestUtils.addEnvironment(this.context, "spring.jackson.locale:en");
|
||||
this.context.refresh();
|
||||
ObjectMapper objectMapper = this.context.getBean(
|
||||
Jackson2ObjectMapperBuilder.class).build();
|
||||
ObjectMapper objectMapper = this.context
|
||||
.getBean(Jackson2ObjectMapperBuilder.class).build();
|
||||
DateTime dateTime = new DateTime(1436966242231L, DateTimeZone.UTC);
|
||||
assertEquals("\"Pacific Daylight Time\"",
|
||||
objectMapper.writeValueAsString(dateTime));
|
||||
@@ -395,8 +390,8 @@ public class JacksonAutoConfigurationTests {
|
||||
"spring.jackson.time-zone:GMT+10");
|
||||
EnvironmentTestUtils.addEnvironment(this.context, "spring.jackson.date-format:z");
|
||||
this.context.refresh();
|
||||
ObjectMapper objectMapper = this.context.getBean(
|
||||
Jackson2ObjectMapperBuilder.class).build();
|
||||
ObjectMapper objectMapper = this.context
|
||||
.getBean(Jackson2ObjectMapperBuilder.class).build();
|
||||
Date date = new Date(1436966242231L);
|
||||
assertEquals("\"GMT+10:00\"", objectMapper.writeValueAsString(date));
|
||||
}
|
||||
@@ -408,8 +403,8 @@ public class JacksonAutoConfigurationTests {
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
"spring.jackson.date-format:zzzz");
|
||||
this.context.refresh();
|
||||
ObjectMapper objectMapper = this.context.getBean(
|
||||
Jackson2ObjectMapperBuilder.class).build();
|
||||
ObjectMapper objectMapper = this.context
|
||||
.getBean(Jackson2ObjectMapperBuilder.class).build();
|
||||
|
||||
DateTime dateTime = new DateTime(1436966242231L, DateTimeZone.UTC);
|
||||
assertEquals("\"Koordinierte Universalzeit\"",
|
||||
@@ -475,8 +470,8 @@ public class JacksonAutoConfigurationTests {
|
||||
|
||||
@Override
|
||||
public void serialize(Foo value, JsonGenerator jgen,
|
||||
SerializerProvider provider) throws IOException,
|
||||
JsonProcessingException {
|
||||
SerializerProvider provider)
|
||||
throws IOException, JsonProcessingException {
|
||||
jgen.writeStartObject();
|
||||
jgen.writeStringField("foo", "bar");
|
||||
jgen.writeEndObject();
|
||||
|
||||
@@ -159,8 +159,8 @@ public class DataSourceAutoConfigurationTests {
|
||||
public void explicitType() {
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
"spring.datasource.driverClassName:org.hsqldb.jdbcDriver",
|
||||
"spring.datasource.url:jdbc:hsqldb:mem:testdb", "spring.datasource.type:"
|
||||
+ HikariDataSource.class.getName());
|
||||
"spring.datasource.url:jdbc:hsqldb:mem:testdb",
|
||||
"spring.datasource.type:" + HikariDataSource.class.getName());
|
||||
this.context.register(DataSourceAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
|
||||
@@ -78,8 +78,8 @@ public class DataSourceTransactionManagerAutoConfigurationTests {
|
||||
EmbeddedDataSourceConfiguration.class,
|
||||
DataSourceTransactionManagerAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
assertEquals("No transaction manager should be been created", 1, this.context
|
||||
.getBeansOfType(PlatformTransactionManager.class).size());
|
||||
assertEquals("No transaction manager should be been created", 1,
|
||||
this.context.getBeansOfType(PlatformTransactionManager.class).size());
|
||||
assertEquals("Wrong transaction manager",
|
||||
this.context.getBean("myTransactionManager"),
|
||||
this.context.getBean(PlatformTransactionManager.class));
|
||||
|
||||
@@ -150,8 +150,8 @@ public class JmsAutoConfigurationTests {
|
||||
"spring.jms.listener.acknowledgeMode=client",
|
||||
"spring.jms.listener.concurrency=2",
|
||||
"spring.jms.listener.maxConcurrency=10");
|
||||
JmsListenerContainerFactory<?> jmsListenerContainerFactory = this.context
|
||||
.getBean("jmsListenerContainerFactory", JmsListenerContainerFactory.class);
|
||||
JmsListenerContainerFactory<?> jmsListenerContainerFactory = this.context.getBean(
|
||||
"jmsListenerContainerFactory", JmsListenerContainerFactory.class);
|
||||
assertEquals(DefaultJmsListenerContainerFactory.class,
|
||||
jmsListenerContainerFactory.getClass());
|
||||
DefaultMessageListenerContainer listenerContainer = ((DefaultJmsListenerContainerFactory) jmsListenerContainerFactory)
|
||||
|
||||
@@ -176,7 +176,8 @@ public class ArtemisAutoConfigurationTests {
|
||||
@Test
|
||||
public void embeddedServiceWithCustomJmsConfiguration() {
|
||||
// Ignored with custom config
|
||||
load(CustomJmsConfiguration.class, "spring.artemis.embedded.queues=Queue1,Queue2");
|
||||
load(CustomJmsConfiguration.class,
|
||||
"spring.artemis.embedded.queues=Queue1,Queue2");
|
||||
DestinationChecker checker = new DestinationChecker(this.context);
|
||||
checker.checkQueue("custom", true); // See CustomJmsConfiguration
|
||||
checker.checkQueue("Queue1", true);
|
||||
@@ -270,7 +271,8 @@ public class ArtemisAutoConfigurationTests {
|
||||
|
||||
private TransportConfiguration assertInVmConnectionFactory(
|
||||
ActiveMQConnectionFactory connectionFactory) {
|
||||
TransportConfiguration transportConfig = getSingleTransportConfiguration(connectionFactory);
|
||||
TransportConfiguration transportConfig = getSingleTransportConfiguration(
|
||||
connectionFactory);
|
||||
assertEquals(InVMConnectorFactory.class.getName(),
|
||||
transportConfig.getFactoryClassName());
|
||||
return transportConfig;
|
||||
@@ -278,7 +280,8 @@ public class ArtemisAutoConfigurationTests {
|
||||
|
||||
private TransportConfiguration assertNettyConnectionFactory(
|
||||
ActiveMQConnectionFactory connectionFactory, String host, int port) {
|
||||
TransportConfiguration transportConfig = getSingleTransportConfiguration(connectionFactory);
|
||||
TransportConfiguration transportConfig = getSingleTransportConfiguration(
|
||||
connectionFactory);
|
||||
assertEquals(NettyConnectorFactory.class.getName(),
|
||||
transportConfig.getFactoryClassName());
|
||||
assertEquals(host, transportConfig.getParams().get("host"));
|
||||
|
||||
@@ -92,21 +92,22 @@ public class JooqAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void jooqWithoutTx() throws Exception {
|
||||
registerAndRefresh(JooqDataSourceConfiguration.class,
|
||||
JooqAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
|
||||
registerAndRefresh(JooqDataSourceConfiguration.class, JooqAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
assertThat(getBeanNames(PlatformTransactionManager.class), equalTo(NO_BEANS));
|
||||
assertThat(getBeanNames(SpringTransactionProvider.class), equalTo(NO_BEANS));
|
||||
DSLContext dsl = this.context.getBean(DSLContext.class);
|
||||
dsl.execute("create table jooqtest (name varchar(255) primary key);");
|
||||
dsl.transaction(new AssertFetch(dsl, "select count(*) as total from jooqtest;",
|
||||
equalTo("0")));
|
||||
dsl.transaction(new ExecuteSql(dsl, "insert into jooqtest (name) values ('foo');"));
|
||||
dsl.transaction(
|
||||
new ExecuteSql(dsl, "insert into jooqtest (name) values ('foo');"));
|
||||
dsl.transaction(new AssertFetch(dsl, "select count(*) as total from jooqtest;",
|
||||
equalTo("1")));
|
||||
try {
|
||||
dsl.transaction(new ExecuteSql(dsl,
|
||||
"insert into jooqtest (name) values ('bar');",
|
||||
"insert into jooqtest (name) values ('foo');"));
|
||||
dsl.transaction(
|
||||
new ExecuteSql(dsl, "insert into jooqtest (name) values ('bar');",
|
||||
"insert into jooqtest (name) values ('foo');"));
|
||||
fail("An DataIntegrityViolationException should have been thrown.");
|
||||
}
|
||||
catch (DataIntegrityViolationException ex) {
|
||||
@@ -125,23 +126,23 @@ public class JooqAutoConfigurationTests {
|
||||
DSLContext dsl = this.context.getBean(DSLContext.class);
|
||||
assertEquals(SQLDialect.H2, dsl.configuration().dialect());
|
||||
dsl.execute("create table jooqtest_tx (name varchar(255) primary key);");
|
||||
dsl.transaction(new AssertFetch(dsl,
|
||||
"select count(*) as total from jooqtest_tx;", equalTo("0")));
|
||||
dsl.transaction(new ExecuteSql(dsl,
|
||||
"insert into jooqtest_tx (name) values ('foo');"));
|
||||
dsl.transaction(new AssertFetch(dsl,
|
||||
"select count(*) as total from jooqtest_tx;", equalTo("1")));
|
||||
dsl.transaction(new AssertFetch(dsl, "select count(*) as total from jooqtest_tx;",
|
||||
equalTo("0")));
|
||||
dsl.transaction(
|
||||
new ExecuteSql(dsl, "insert into jooqtest_tx (name) values ('foo');"));
|
||||
dsl.transaction(new AssertFetch(dsl, "select count(*) as total from jooqtest_tx;",
|
||||
equalTo("1")));
|
||||
try {
|
||||
dsl.transaction(new ExecuteSql(dsl,
|
||||
"insert into jooqtest (name) values ('bar');",
|
||||
"insert into jooqtest (name) values ('foo');"));
|
||||
dsl.transaction(
|
||||
new ExecuteSql(dsl, "insert into jooqtest (name) values ('bar');",
|
||||
"insert into jooqtest (name) values ('foo');"));
|
||||
fail("A DataIntegrityViolationException should have been thrown.");
|
||||
}
|
||||
catch (DataIntegrityViolationException ex) {
|
||||
// Ignore
|
||||
}
|
||||
dsl.transaction(new AssertFetch(dsl,
|
||||
"select count(*) as total from jooqtest_tx;", equalTo("1")));
|
||||
dsl.transaction(new AssertFetch(dsl, "select count(*) as total from jooqtest_tx;",
|
||||
equalTo("1")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -152,8 +153,8 @@ public class JooqAutoConfigurationTests {
|
||||
TestExecuteListenerProvider.class, TestVisitListenerProvider.class,
|
||||
JooqAutoConfiguration.class);
|
||||
DSLContext dsl = this.context.getBean(DSLContext.class);
|
||||
assertEquals(TestRecordMapperProvider.class, dsl.configuration()
|
||||
.recordMapperProvider().getClass());
|
||||
assertEquals(TestRecordMapperProvider.class,
|
||||
dsl.configuration().recordMapperProvider().getClass());
|
||||
assertThat(dsl.configuration().recordListenerProviders().length, equalTo(1));
|
||||
assertThat(dsl.configuration().executeListenerProviders().length, equalTo(2));
|
||||
assertThat(dsl.configuration().visitListenerProviders().length, equalTo(1));
|
||||
@@ -163,7 +164,8 @@ public class JooqAutoConfigurationTests {
|
||||
public void relaxedBindingOfSqlDialect() {
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
"spring.jooq.sql-dialect:PoSTGrES");
|
||||
registerAndRefresh(JooqDataSourceConfiguration.class, JooqAutoConfiguration.class);
|
||||
registerAndRefresh(JooqDataSourceConfiguration.class,
|
||||
JooqAutoConfiguration.class);
|
||||
assertThat(this.context.getBean(org.jooq.Configuration.class).dialect(),
|
||||
is(equalTo(SQLDialect.POSTGRES)));
|
||||
}
|
||||
@@ -258,7 +260,8 @@ public class JooqAutoConfigurationTests {
|
||||
|
||||
}
|
||||
|
||||
protected static class TestExecuteListenerProvider implements ExecuteListenerProvider {
|
||||
protected static class TestExecuteListenerProvider
|
||||
implements ExecuteListenerProvider {
|
||||
|
||||
@Override
|
||||
public ExecuteListener provide() {
|
||||
|
||||
@@ -163,8 +163,8 @@ public class AutoConfigurationReportLoggingInitializerTests {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
this.initializer.initialize(context);
|
||||
context.register(Config.class);
|
||||
ConditionEvaluationReport.get(context.getBeanFactory()).recordExclusions(
|
||||
Arrays.asList("com.foo.Bar"));
|
||||
ConditionEvaluationReport.get(context.getBeanFactory())
|
||||
.recordExclusions(Arrays.asList("com.foo.Bar"));
|
||||
context.refresh();
|
||||
this.initializer.onApplicationEvent(new ContextRefreshedEvent(context));
|
||||
for (String message : this.debugLog) {
|
||||
|
||||
@@ -151,8 +151,8 @@ public class MailSenderAutoConfigurationTests {
|
||||
load(EmptyConfig.class, "spring.mail.jndi-name:foo");
|
||||
Session sessionBean = this.context.getBean(Session.class);
|
||||
assertEquals(session, sessionBean);
|
||||
assertEquals(sessionBean, this.context.getBean(JavaMailSenderImpl.class)
|
||||
.getSession());
|
||||
assertEquals(sessionBean,
|
||||
this.context.getBean(JavaMailSenderImpl.class).getSession());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -194,8 +194,8 @@ public class MailSenderAutoConfigurationTests {
|
||||
verify(mailSender, never()).testConnection();
|
||||
}
|
||||
|
||||
private Session configureJndiSession(String name) throws IllegalStateException,
|
||||
NamingException {
|
||||
private Session configureJndiSession(String name)
|
||||
throws IllegalStateException, NamingException {
|
||||
Properties properties = new Properties();
|
||||
Session session = Session.getDefaultInstance(properties);
|
||||
TestableInitialContextFactory.bind(name, session);
|
||||
|
||||
@@ -88,15 +88,16 @@ public class DeviceDelegatingViewResolverAutoConfigurationTests {
|
||||
AbstractDeviceDelegatingViewResolver.class);
|
||||
assertNotNull(internalResourceViewResolver);
|
||||
assertNotNull(deviceDelegatingViewResolver);
|
||||
assertTrue(deviceDelegatingViewResolver.getViewResolver() instanceof InternalResourceViewResolver);
|
||||
assertTrue(deviceDelegatingViewResolver
|
||||
.getViewResolver() instanceof InternalResourceViewResolver);
|
||||
try {
|
||||
this.context.getBean(ThymeleafViewResolver.class);
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException ex) {
|
||||
// expected. ThymeleafViewResolver shouldn't be defined.
|
||||
}
|
||||
assertTrue(deviceDelegatingViewResolver.getOrder() == internalResourceViewResolver
|
||||
.getOrder() - 1);
|
||||
assertTrue(deviceDelegatingViewResolver
|
||||
.getOrder() == internalResourceViewResolver.getOrder() - 1);
|
||||
}
|
||||
|
||||
@Test(expected = NoSuchBeanDefinitionException.class)
|
||||
@@ -138,11 +139,12 @@ public class DeviceDelegatingViewResolverAutoConfigurationTests {
|
||||
AbstractDeviceDelegatingViewResolver.class);
|
||||
assertNotNull(thymeleafViewResolver);
|
||||
assertNotNull(deviceDelegatingViewResolver);
|
||||
assertTrue(deviceDelegatingViewResolver.getViewResolver() instanceof ThymeleafViewResolver);
|
||||
assertTrue(deviceDelegatingViewResolver
|
||||
.getViewResolver() instanceof ThymeleafViewResolver);
|
||||
assertNotNull(this.context.getBean(InternalResourceViewResolver.class));
|
||||
assertNotNull(this.context.getBean(ThymeleafViewResolver.class));
|
||||
assertTrue(deviceDelegatingViewResolver.getOrder() == thymeleafViewResolver
|
||||
.getOrder() - 1);
|
||||
assertTrue(deviceDelegatingViewResolver
|
||||
.getOrder() == thymeleafViewResolver.getOrder() - 1);
|
||||
}
|
||||
|
||||
@Test(expected = NoSuchBeanDefinitionException.class)
|
||||
|
||||
@@ -82,8 +82,8 @@ public class DeviceResolverAutoConfigurationTests {
|
||||
this.context.refresh();
|
||||
RequestMappingHandlerMapping mapping = this.context
|
||||
.getBean(RequestMappingHandlerMapping.class);
|
||||
HandlerInterceptor[] interceptors = mapping.getHandler(
|
||||
new MockHttpServletRequest()).getInterceptors();
|
||||
HandlerInterceptor[] interceptors = mapping
|
||||
.getHandler(new MockHttpServletRequest()).getInterceptors();
|
||||
assertThat(interceptors,
|
||||
hasItemInArray(instanceOf(DeviceResolverHandlerInterceptor.class)));
|
||||
}
|
||||
|
||||
@@ -90,8 +90,8 @@ public class SitePreferenceAutoConfigurationTests {
|
||||
this.context = new AnnotationConfigWebApplicationContext();
|
||||
this.context.register(SitePreferenceAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
assertNotNull(this.context
|
||||
.getBean(SitePreferenceHandlerMethodArgumentResolver.class));
|
||||
assertNotNull(
|
||||
this.context.getBean(SitePreferenceHandlerMethodArgumentResolver.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -101,8 +101,8 @@ public class SitePreferenceAutoConfigurationTests {
|
||||
"spring.mobile.sitepreference.enabled:true");
|
||||
this.context.register(SitePreferenceAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
assertNotNull(this.context
|
||||
.getBean(SitePreferenceHandlerMethodArgumentResolver.class));
|
||||
assertNotNull(
|
||||
this.context.getBean(SitePreferenceHandlerMethodArgumentResolver.class));
|
||||
}
|
||||
|
||||
@Test(expected = NoSuchBeanDefinitionException.class)
|
||||
@@ -126,8 +126,8 @@ public class SitePreferenceAutoConfigurationTests {
|
||||
this.context.refresh();
|
||||
RequestMappingHandlerMapping mapping = this.context
|
||||
.getBean(RequestMappingHandlerMapping.class);
|
||||
HandlerInterceptor[] interceptors = mapping.getHandler(
|
||||
new MockHttpServletRequest()).getInterceptors();
|
||||
HandlerInterceptor[] interceptors = mapping
|
||||
.getHandler(new MockHttpServletRequest()).getInterceptors();
|
||||
assertThat(interceptors,
|
||||
hasItemInArray(instanceOf(SitePreferenceHandlerInterceptor.class)));
|
||||
}
|
||||
|
||||
@@ -90,7 +90,8 @@ public class MongoPropertiesTests {
|
||||
properties.setUsername("user");
|
||||
properties.setPassword("secret".toCharArray());
|
||||
MongoClient client = properties.createMongoClient(null, null);
|
||||
assertMongoCredential(client.getCredentialsList().get(0), "user", "secret", "foo");
|
||||
assertMongoCredential(client.getCredentialsList().get(0), "user", "secret",
|
||||
"foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -100,7 +101,8 @@ public class MongoPropertiesTests {
|
||||
properties.setUsername("user");
|
||||
properties.setPassword("secret".toCharArray());
|
||||
MongoClient client = properties.createMongoClient(null, null);
|
||||
assertMongoCredential(client.getCredentialsList().get(0), "user", "secret", "foo");
|
||||
assertMongoCredential(client.getCredentialsList().get(0), "user", "secret",
|
||||
"foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -36,6 +36,7 @@ import com.mongodb.CommandResult;
|
||||
import com.mongodb.MongoClient;
|
||||
|
||||
import de.flapdoodle.embed.mongo.distribution.Feature;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.hasItems;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
@@ -73,8 +74,9 @@ public class EmbeddedMongoAutoConfigurationTests {
|
||||
public void customFeatures() {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
int mongoPort = SocketUtils.findAvailableTcpPort();
|
||||
EnvironmentTestUtils.addEnvironment(this.context, "spring.data.mongodb.port="
|
||||
+ mongoPort, "spring.mongodb.embedded.features=TEXT_SEARCH, SYNC_DELAY");
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
"spring.data.mongodb.port=" + mongoPort,
|
||||
"spring.mongodb.embedded.features=TEXT_SEARCH, SYNC_DELAY");
|
||||
this.context.register(EmbeddedMongoAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
assertThat(this.context.getBean(EmbeddedMongoProperties.class).getFeatures(),
|
||||
@@ -89,10 +91,9 @@ public class EmbeddedMongoAutoConfigurationTests {
|
||||
MongoClientConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
assertThat(
|
||||
this.context.getBean(MongoClient.class).getAddress().getPort(),
|
||||
equalTo(Integer.valueOf(this.context.getEnvironment().getProperty(
|
||||
"local.mongo.port"))));
|
||||
assertThat(this.context.getBean(MongoClient.class).getAddress().getPort(),
|
||||
equalTo(Integer.valueOf(
|
||||
this.context.getEnvironment().getProperty("local.mongo.port"))));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -120,8 +121,8 @@ public class EmbeddedMongoAutoConfigurationTests {
|
||||
String expectedVersion) {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
int mongoPort = SocketUtils.findAvailableTcpPort();
|
||||
EnvironmentTestUtils.addEnvironment(this.context, "spring.data.mongodb.port="
|
||||
+ mongoPort);
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
"spring.data.mongodb.port=" + mongoPort);
|
||||
if (configuredVersion != null) {
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
"spring.mongodb.embedded.version=" + configuredVersion);
|
||||
|
||||
@@ -102,7 +102,8 @@ public abstract class AbstractJpaAutoConfigurationTests {
|
||||
setupTestConfiguration();
|
||||
this.context.refresh();
|
||||
assertNotNull(this.context.getBean(DataSource.class));
|
||||
assertTrue(this.context.getBean("transactionManager") instanceof JpaTransactionManager);
|
||||
assertTrue(this.context
|
||||
.getBean("transactionManager") instanceof JpaTransactionManager);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -157,7 +158,8 @@ public abstract class AbstractJpaAutoConfigurationTests {
|
||||
public void usesManuallyDefinedLocalContainerEntityManagerFactoryBeanIfAvailable() {
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
"spring.datasource.initialize:false");
|
||||
setupTestConfiguration(TestConfigurationWithLocalContainerEntityManagerFactoryBean.class);
|
||||
setupTestConfiguration(
|
||||
TestConfigurationWithLocalContainerEntityManagerFactoryBean.class);
|
||||
this.context.refresh();
|
||||
LocalContainerEntityManagerFactoryBean factoryBean = this.context
|
||||
.getBean(LocalContainerEntityManagerFactoryBean.class);
|
||||
@@ -251,8 +253,8 @@ public abstract class AbstractJpaAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Configuration
|
||||
protected static class TestConfigurationWithEntityManagerFactory extends
|
||||
TestConfiguration {
|
||||
protected static class TestConfigurationWithEntityManagerFactory
|
||||
extends TestConfiguration {
|
||||
|
||||
@Bean
|
||||
public EntityManagerFactory entityManagerFactory(DataSource dataSource,
|
||||
|
||||
@@ -50,7 +50,8 @@ import static org.junit.Assert.assertThat;
|
||||
* @author Phillip Webb
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class HibernateJpaAutoConfigurationTests extends AbstractJpaAutoConfigurationTests {
|
||||
public class HibernateJpaAutoConfigurationTests
|
||||
extends AbstractJpaAutoConfigurationTests {
|
||||
|
||||
@Override
|
||||
protected Class<?> getAutoConfigureClass() {
|
||||
@@ -66,8 +67,8 @@ public class HibernateJpaAutoConfigurationTests extends AbstractJpaAutoConfigura
|
||||
setupTestConfiguration();
|
||||
this.context.refresh();
|
||||
assertEquals(new Integer(1),
|
||||
new JdbcTemplate(this.context.getBean(DataSource.class)).queryForObject(
|
||||
"SELECT COUNT(*) from CITY", Integer.class));
|
||||
new JdbcTemplate(this.context.getBean(DataSource.class))
|
||||
.queryForObject("SELECT COUNT(*) from CITY", Integer.class));
|
||||
}
|
||||
|
||||
// This can't succeed because the data SQL is executed immediately after the schema
|
||||
@@ -79,8 +80,8 @@ public class HibernateJpaAutoConfigurationTests extends AbstractJpaAutoConfigura
|
||||
setupTestConfiguration();
|
||||
this.context.refresh();
|
||||
assertEquals(new Integer(1),
|
||||
new JdbcTemplate(this.context.getBean(DataSource.class)).queryForObject(
|
||||
"SELECT COUNT(*) from CITY", Integer.class));
|
||||
new JdbcTemplate(this.context.getBean(DataSource.class))
|
||||
.queryForObject("SELECT COUNT(*) from CITY", Integer.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -92,8 +93,8 @@ public class HibernateJpaAutoConfigurationTests extends AbstractJpaAutoConfigura
|
||||
this.context.refresh();
|
||||
LocalContainerEntityManagerFactoryBean bean = this.context
|
||||
.getBean(LocalContainerEntityManagerFactoryBean.class);
|
||||
String actual = (String) bean.getJpaPropertyMap().get(
|
||||
"hibernate.ejb.naming_strategy");
|
||||
String actual = (String) bean.getJpaPropertyMap()
|
||||
.get("hibernate.ejb.naming_strategy");
|
||||
assertThat(actual, equalTo("org.hibernate.cfg.EJB3NamingStrategy"));
|
||||
}
|
||||
|
||||
@@ -106,8 +107,8 @@ public class HibernateJpaAutoConfigurationTests extends AbstractJpaAutoConfigura
|
||||
this.context.refresh();
|
||||
LocalContainerEntityManagerFactoryBean bean = this.context
|
||||
.getBean(LocalContainerEntityManagerFactoryBean.class);
|
||||
String actual = (String) bean.getJpaPropertyMap().get(
|
||||
"hibernate.ejb.naming_strategy");
|
||||
String actual = (String) bean.getJpaPropertyMap()
|
||||
.get("hibernate.ejb.naming_strategy");
|
||||
// You can't override this one from spring.jpa.properties because it has an
|
||||
// opinionated default
|
||||
assertThat(actual, not(equalTo("org.hibernate.cfg.EJB3NamingStrategy")));
|
||||
@@ -140,8 +141,9 @@ public class HibernateJpaAutoConfigurationTests extends AbstractJpaAutoConfigura
|
||||
this.context.register(JtaProperties.class, JtaAutoConfiguration.class);
|
||||
setupTestConfiguration();
|
||||
this.context.refresh();
|
||||
Map<String, Object> jpaPropertyMap = this.context.getBean(
|
||||
LocalContainerEntityManagerFactoryBean.class).getJpaPropertyMap();
|
||||
Map<String, Object> jpaPropertyMap = this.context
|
||||
.getBean(LocalContainerEntityManagerFactoryBean.class)
|
||||
.getJpaPropertyMap();
|
||||
assertThat(jpaPropertyMap.get("hibernate.transaction.jta.platform"),
|
||||
instanceOf(SpringJtaPlatform.class));
|
||||
}
|
||||
@@ -154,8 +156,9 @@ public class HibernateJpaAutoConfigurationTests extends AbstractJpaAutoConfigura
|
||||
this.context.register(JtaProperties.class, JtaAutoConfiguration.class);
|
||||
setupTestConfiguration();
|
||||
this.context.refresh();
|
||||
Map<String, Object> jpaPropertyMap = this.context.getBean(
|
||||
LocalContainerEntityManagerFactoryBean.class).getJpaPropertyMap();
|
||||
Map<String, Object> jpaPropertyMap = this.context
|
||||
.getBean(LocalContainerEntityManagerFactoryBean.class)
|
||||
.getJpaPropertyMap();
|
||||
assertThat((String) jpaPropertyMap.get("hibernate.transaction.jta.platform"),
|
||||
equalTo(TestJtaPlatform.class.getName()));
|
||||
}
|
||||
|
||||
@@ -90,8 +90,8 @@ public class SecurityAutoConfigurationTests {
|
||||
this.context.refresh();
|
||||
assertNotNull(this.context.getBean(AuthenticationManagerBuilder.class));
|
||||
// 5 for static resources and one for the rest
|
||||
List<SecurityFilterChain> filterChains = this.context.getBean(
|
||||
FilterChainProxy.class).getFilterChains();
|
||||
List<SecurityFilterChain> filterChains = this.context
|
||||
.getBean(FilterChainProxy.class).getFilterChains();
|
||||
assertEquals(5, filterChains.size());
|
||||
}
|
||||
|
||||
@@ -104,8 +104,7 @@ public class SecurityAutoConfigurationTests {
|
||||
ServerPropertiesAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
assertEquals(
|
||||
FilterRegistrationBean.REQUEST_WRAPPER_FILTER_MAX_ORDER - 100,
|
||||
assertEquals(FilterRegistrationBean.REQUEST_WRAPPER_FILTER_MAX_ORDER - 100,
|
||||
this.context.getBean("securityFilterChainRegistration",
|
||||
FilterRegistrationBean.class).getOrder());
|
||||
}
|
||||
@@ -135,8 +134,7 @@ public class SecurityAutoConfigurationTests {
|
||||
ServerPropertiesAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
assertEquals(
|
||||
FilterRegistrationBean.REQUEST_WRAPPER_FILTER_MAX_ORDER - 100,
|
||||
assertEquals(FilterRegistrationBean.REQUEST_WRAPPER_FILTER_MAX_ORDER - 100,
|
||||
this.context.getBean("securityFilterChainRegistration",
|
||||
FilterRegistrationBean.class).getOrder());
|
||||
}
|
||||
@@ -151,10 +149,9 @@ public class SecurityAutoConfigurationTests {
|
||||
ServerPropertiesAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
assertEquals(
|
||||
12345,
|
||||
this.context.getBean("securityFilterChainRegistration",
|
||||
FilterRegistrationBean.class).getOrder());
|
||||
assertEquals(12345, this.context
|
||||
.getBean("securityFilterChainRegistration", FilterRegistrationBean.class)
|
||||
.getOrder());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -167,8 +164,8 @@ public class SecurityAutoConfigurationTests {
|
||||
EnvironmentTestUtils.addEnvironment(this.context, "security.ignored:none");
|
||||
this.context.refresh();
|
||||
// Just the application endpoints now
|
||||
assertEquals(1, this.context.getBean(FilterChainProxy.class).getFilterChains()
|
||||
.size());
|
||||
assertEquals(1,
|
||||
this.context.getBean(FilterChainProxy.class).getFilterChains().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -225,7 +222,8 @@ public class SecurityAutoConfigurationTests {
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
assertEquals(
|
||||
this.context.getBean(TestAuthenticationConfiguration.class).authenticationManager,
|
||||
this.context.getBean(
|
||||
TestAuthenticationConfiguration.class).authenticationManager,
|
||||
this.context.getBean(AuthenticationManager.class));
|
||||
}
|
||||
|
||||
@@ -253,7 +251,8 @@ public class SecurityAutoConfigurationTests {
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
assertEquals(
|
||||
this.context.getBean(TestAuthenticationConfiguration.class).authenticationManager,
|
||||
this.context.getBean(
|
||||
TestAuthenticationConfiguration.class).authenticationManager,
|
||||
this.context.getBean(AuthenticationManager.class));
|
||||
}
|
||||
|
||||
@@ -270,8 +269,8 @@ public class SecurityAutoConfigurationTests {
|
||||
UsernamePasswordAuthenticationToken user = new UsernamePasswordAuthenticationToken(
|
||||
"foo", "bar",
|
||||
AuthorityUtils.commaSeparatedStringToAuthorityList("ROLE_USER"));
|
||||
assertNotNull(this.context.getBean(AuthenticationManager.class)
|
||||
.authenticate(user));
|
||||
assertNotNull(
|
||||
this.context.getBean(AuthenticationManager.class).authenticate(user));
|
||||
pingAuthenticationListener();
|
||||
}
|
||||
|
||||
@@ -288,8 +287,8 @@ public class SecurityAutoConfigurationTests {
|
||||
UsernamePasswordAuthenticationToken user = new UsernamePasswordAuthenticationToken(
|
||||
"foo", "bar",
|
||||
AuthorityUtils.commaSeparatedStringToAuthorityList("ROLE_USER"));
|
||||
assertNotNull(this.context.getBean(AuthenticationManager.class)
|
||||
.authenticate(user));
|
||||
assertNotNull(
|
||||
this.context.getBean(AuthenticationManager.class).authenticate(user));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -364,8 +363,8 @@ public class SecurityAutoConfigurationTests {
|
||||
assertNotNull(this.context.getBean(SecurityEvaluationContextExtension.class));
|
||||
}
|
||||
|
||||
private static final class AuthenticationListener implements
|
||||
ApplicationListener<AbstractAuthenticationEvent> {
|
||||
private static final class AuthenticationListener
|
||||
implements ApplicationListener<AbstractAuthenticationEvent> {
|
||||
|
||||
private ApplicationEvent event;
|
||||
|
||||
@@ -410,8 +409,8 @@ public class SecurityAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Configuration
|
||||
protected static class WorkaroundSecurityCustomizer extends
|
||||
WebSecurityConfigurerAdapter {
|
||||
protected static class WorkaroundSecurityCustomizer
|
||||
extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Autowired
|
||||
private AuthenticationManagerBuilder builder;
|
||||
@@ -435,8 +434,8 @@ public class SecurityAutoConfigurationTests {
|
||||
|
||||
@Configuration
|
||||
@Order(-1)
|
||||
protected static class AuthenticationManagerCustomizer extends
|
||||
GlobalAuthenticationConfigurerAdapter {
|
||||
protected static class AuthenticationManagerCustomizer
|
||||
extends GlobalAuthenticationConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
public void init(AuthenticationManagerBuilder auth) throws Exception {
|
||||
@@ -446,8 +445,8 @@ public class SecurityAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Configuration
|
||||
protected static class UserDetailsSecurityCustomizer extends
|
||||
WebSecurityConfigurerAdapter {
|
||||
protected static class UserDetailsSecurityCustomizer
|
||||
extends WebSecurityConfigurerAdapter {
|
||||
|
||||
private UserDetailsService userDetails;
|
||||
|
||||
|
||||
@@ -82,8 +82,8 @@ public class SpringBootWebSecurityConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void testDefaultIgnores() {
|
||||
assertTrue(SpringBootWebSecurityConfiguration
|
||||
.getIgnored(new SecurityProperties()).contains("/css/**"));
|
||||
assertTrue(SpringBootWebSecurityConfiguration.getIgnored(new SecurityProperties())
|
||||
.contains("/css/**"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -91,8 +91,8 @@ public class SpringBootWebSecurityConfigurationTests {
|
||||
this.context = SpringApplication.run(TestWebConfiguration.class,
|
||||
"--server.port=0");
|
||||
assertNotNull(this.context.getBean(AuthenticationManagerBuilder.class));
|
||||
assertNotNull(this.context.getBean(AuthenticationManager.class).authenticate(
|
||||
new UsernamePasswordAuthenticationToken("dave", "secret")));
|
||||
assertNotNull(this.context.getBean(AuthenticationManager.class)
|
||||
.authenticate(new UsernamePasswordAuthenticationToken("dave", "secret")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -106,9 +106,8 @@ public class SpringBootWebSecurityConfigurationTests {
|
||||
.build();
|
||||
mockMvc.perform(MockMvcRequestBuilders.get("/"))
|
||||
.andExpect(MockMvcResultMatchers.status().isUnauthorized())
|
||||
.andExpect(
|
||||
MockMvcResultMatchers.header().string("www-authenticate",
|
||||
Matchers.containsString("realm=\"Spring\"")));
|
||||
.andExpect(MockMvcResultMatchers.header().string("www-authenticate",
|
||||
Matchers.containsString("realm=\"Spring\"")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -121,8 +120,8 @@ public class SpringBootWebSecurityConfigurationTests {
|
||||
.addFilters(
|
||||
this.context.getBean("springSecurityFilterChain", Filter.class))
|
||||
.build();
|
||||
mockMvc.perform(MockMvcRequestBuilders.get("/")).andExpect(
|
||||
MockMvcResultMatchers.status().isNotFound());
|
||||
mockMvc.perform(MockMvcRequestBuilders.get("/"))
|
||||
.andExpect(MockMvcResultMatchers.status().isNotFound());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -137,9 +136,8 @@ public class SpringBootWebSecurityConfigurationTests {
|
||||
.build();
|
||||
mockMvc.perform(MockMvcRequestBuilders.get("/"))
|
||||
.andExpect(MockMvcResultMatchers.status().isUnauthorized())
|
||||
.andExpect(
|
||||
MockMvcResultMatchers.header().string("www-authenticate",
|
||||
Matchers.containsString("realm=\"Spring\"")));
|
||||
.andExpect(MockMvcResultMatchers.header().string("www-authenticate",
|
||||
Matchers.containsString("realm=\"Spring\"")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -154,9 +152,8 @@ public class SpringBootWebSecurityConfigurationTests {
|
||||
mockMvc.perform(
|
||||
MockMvcRequestBuilders.get("/").header("authorization", "Basic xxx"))
|
||||
.andExpect(MockMvcResultMatchers.status().isUnauthorized())
|
||||
.andExpect(
|
||||
MockMvcResultMatchers.header().string("www-authenticate",
|
||||
Matchers.containsString("realm=\"Spring\"")));
|
||||
.andExpect(MockMvcResultMatchers.header().string("www-authenticate",
|
||||
Matchers.containsString("realm=\"Spring\"")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -164,8 +161,8 @@ public class SpringBootWebSecurityConfigurationTests {
|
||||
this.context = SpringApplication.run(TestInjectWebConfiguration.class,
|
||||
"--server.port=0");
|
||||
assertNotNull(this.context.getBean(AuthenticationManagerBuilder.class));
|
||||
assertNotNull(this.context.getBean(AuthenticationManager.class).authenticate(
|
||||
new UsernamePasswordAuthenticationToken("dave", "secret")));
|
||||
assertNotNull(this.context.getBean(AuthenticationManager.class)
|
||||
.authenticate(new UsernamePasswordAuthenticationToken("dave", "secret")));
|
||||
}
|
||||
|
||||
// gh-3447
|
||||
@@ -173,15 +170,15 @@ public class SpringBootWebSecurityConfigurationTests {
|
||||
public void testHiddenHttpMethodFilterOrderedFirst() throws Exception {
|
||||
this.context = SpringApplication.run(DenyPostRequestConfig.class,
|
||||
"--server.port=0");
|
||||
int port = Integer.parseInt(this.context.getEnvironment().getProperty(
|
||||
"local.server.port"));
|
||||
int port = Integer
|
||||
.parseInt(this.context.getEnvironment().getProperty("local.server.port"));
|
||||
TestRestTemplate rest = new TestRestTemplate();
|
||||
|
||||
// not overriding causes forbidden
|
||||
MultiValueMap<String, String> form = new LinkedMultiValueMap<String, String>();
|
||||
|
||||
ResponseEntity<Object> result = rest.postForEntity("http://localhost:" + port
|
||||
+ "/", form, Object.class);
|
||||
ResponseEntity<Object> result = rest
|
||||
.postForEntity("http://localhost:" + port + "/", form, Object.class);
|
||||
assertEquals(HttpStatus.FORBIDDEN, result.getStatusCode());
|
||||
|
||||
// override method with GET
|
||||
@@ -195,8 +192,8 @@ public class SpringBootWebSecurityConfigurationTests {
|
||||
@Configuration
|
||||
@Import(TestWebConfiguration.class)
|
||||
@Order(Ordered.LOWEST_PRECEDENCE)
|
||||
protected static class TestInjectWebConfiguration extends
|
||||
WebSecurityConfigurerAdapter {
|
||||
protected static class TestInjectWebConfiguration
|
||||
extends WebSecurityConfigurerAdapter {
|
||||
|
||||
// It's a bad idea to inject an AuthenticationManager into a
|
||||
// WebSecurityConfigurerAdapter because it can cascade early instantiation,
|
||||
@@ -245,8 +242,8 @@ public class SpringBootWebSecurityConfigurationTests {
|
||||
@Import({ EmbeddedServletContainerAutoConfiguration.class,
|
||||
ServerPropertiesAutoConfiguration.class,
|
||||
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
|
||||
HttpMessageConvertersAutoConfiguration.class,
|
||||
ErrorMvcAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class })
|
||||
HttpMessageConvertersAutoConfiguration.class, ErrorMvcAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class })
|
||||
protected @interface MinimalWebConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@@ -124,12 +124,12 @@ public class OAuth2AutoConfigurationTests {
|
||||
ClientDetails config = this.context.getBean(BaseClientDetails.class);
|
||||
AuthorizationEndpoint endpoint = this.context
|
||||
.getBean(AuthorizationEndpoint.class);
|
||||
UserApprovalHandler handler = (UserApprovalHandler) ReflectionTestUtils.getField(
|
||||
endpoint, "userApprovalHandler");
|
||||
UserApprovalHandler handler = (UserApprovalHandler) ReflectionTestUtils
|
||||
.getField(endpoint, "userApprovalHandler");
|
||||
ClientDetailsService clientDetailsService = this.context
|
||||
.getBean(ClientDetailsService.class);
|
||||
ClientDetails clientDetails = clientDetailsService.loadClientByClientId(config
|
||||
.getClientId());
|
||||
ClientDetails clientDetails = clientDetailsService
|
||||
.loadClientByClientId(config.getClientId());
|
||||
assertThat(AopUtils.isJdkDynamicProxy(clientDetailsService), equalTo(true));
|
||||
assertThat(AopUtils.getTargetClass(clientDetailsService).getName(),
|
||||
is(equalTo(InMemoryClientDetailsService.class.getName())));
|
||||
@@ -279,8 +279,8 @@ public class OAuth2AutoConfigurationTests {
|
||||
@Test
|
||||
public void testMethodSecurityBackingOff() {
|
||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
|
||||
this.context.register(CustomMethodSecurity.class,
|
||||
TestSecurityConfiguration.class, MinimalSecureWebApplication.class);
|
||||
this.context.register(CustomMethodSecurity.class, TestSecurityConfiguration.class,
|
||||
MinimalSecureWebApplication.class);
|
||||
this.context.refresh();
|
||||
DelegatingMethodSecurityMetadataSource source = this.context
|
||||
.getBean(DelegatingMethodSecurityMetadataSource.class);
|
||||
@@ -319,12 +319,12 @@ public class OAuth2AutoConfigurationTests {
|
||||
assertThat(scope, equalTo("\"read\""));
|
||||
// Now we should be able to see that endpoint.
|
||||
headers.set("Authorization", "BEARER " + authorizationToken);
|
||||
ResponseEntity<String> securedResponse = rest.exchange(new RequestEntity<Void>(
|
||||
headers, HttpMethod.GET, URI.create(baseUrl + "/securedFind")),
|
||||
String.class);
|
||||
ResponseEntity<String> securedResponse = rest
|
||||
.exchange(new RequestEntity<Void>(headers, HttpMethod.GET,
|
||||
URI.create(baseUrl + "/securedFind")), String.class);
|
||||
assertThat(securedResponse.getStatusCode(), equalTo(HttpStatus.OK));
|
||||
assertThat(securedResponse.getBody(), equalTo("You reached an endpoint "
|
||||
+ "secured by Spring Security OAuth2"));
|
||||
assertThat(securedResponse.getBody(), equalTo(
|
||||
"You reached an endpoint " + "secured by Spring Security OAuth2"));
|
||||
ResponseEntity<String> entity = rest.exchange(new RequestEntity<Void>(headers,
|
||||
HttpMethod.POST, URI.create(baseUrl + "/securedSave")), String.class);
|
||||
assertThat(entity.getStatusCode(), equalTo(finalStatus));
|
||||
@@ -332,8 +332,8 @@ public class OAuth2AutoConfigurationTests {
|
||||
|
||||
private HttpHeaders getHeaders(ClientDetails config) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
String token = new String(Base64.encode((config.getClientId() + ":" + config
|
||||
.getClientSecret()).getBytes()));
|
||||
String token = new String(Base64.encode(
|
||||
(config.getClientId() + ":" + config.getClientSecret()).getBytes()));
|
||||
headers.set("Authorization", "Basic " + token);
|
||||
return headers;
|
||||
}
|
||||
@@ -349,8 +349,8 @@ public class OAuth2AutoConfigurationTests {
|
||||
|
||||
private void assertEndpointUnauthorized(String baseUrl, RestTemplate rest) {
|
||||
URI uri = URI.create(baseUrl + "/secured");
|
||||
ResponseEntity<String> entity = rest.exchange(new RequestEntity<Void>(
|
||||
HttpMethod.GET, uri), String.class);
|
||||
ResponseEntity<String> entity = rest
|
||||
.exchange(new RequestEntity<Void>(HttpMethod.GET, uri), String.class);
|
||||
assertThat(entity.getStatusCode(), equalTo(HttpStatus.UNAUTHORIZED));
|
||||
}
|
||||
|
||||
@@ -368,7 +368,8 @@ public class OAuth2AutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Configuration
|
||||
protected static class TestSecurityConfiguration extends WebSecurityConfigurerAdapter {
|
||||
protected static class TestSecurityConfiguration
|
||||
extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
@Bean
|
||||
@@ -397,8 +398,8 @@ public class OAuth2AutoConfigurationTests {
|
||||
@EnableAuthorizationServer
|
||||
@EnableResourceServer
|
||||
@EnableGlobalMethodSecurity(prePostEnabled = true)
|
||||
protected static class AuthorizationAndResourceServerConfiguration extends
|
||||
TestSecurityConfiguration {
|
||||
protected static class AuthorizationAndResourceServerConfiguration
|
||||
extends TestSecurityConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@@ -420,8 +421,8 @@ public class OAuth2AutoConfigurationTests {
|
||||
|
||||
@Configuration
|
||||
@EnableAuthorizationServer
|
||||
protected static class AuthorizationServerConfiguration extends
|
||||
TestSecurityConfiguration {
|
||||
protected static class AuthorizationServerConfiguration
|
||||
extends TestSecurityConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@@ -483,8 +484,8 @@ public class OAuth2AutoConfigurationTests {
|
||||
|
||||
@Configuration
|
||||
@EnableAuthorizationServer
|
||||
protected static class CustomAuthorizationServer extends
|
||||
AuthorizationServerConfigurerAdapter {
|
||||
protected static class CustomAuthorizationServer
|
||||
extends AuthorizationServerConfigurerAdapter {
|
||||
|
||||
@Autowired
|
||||
private AuthenticationManager authenticationManager;
|
||||
@@ -512,15 +513,16 @@ public class OAuth2AutoConfigurationTests {
|
||||
@Override
|
||||
public void configure(AuthorizationServerEndpointsConfigurer endpoints)
|
||||
throws Exception {
|
||||
endpoints.tokenStore(tokenStore()).authenticationManager(
|
||||
this.authenticationManager);
|
||||
endpoints.tokenStore(tokenStore())
|
||||
.authenticationManager(this.authenticationManager);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EnableGlobalMethodSecurity(prePostEnabled = true)
|
||||
protected static class CustomMethodSecurity extends GlobalMethodSecurityConfiguration {
|
||||
protected static class CustomMethodSecurity
|
||||
extends GlobalMethodSecurityConfiguration {
|
||||
|
||||
@Override
|
||||
protected MethodSecurityExpressionHandler createExpressionHandler() {
|
||||
|
||||
@@ -48,8 +48,8 @@ public class ResourceServerPropertiesTests {
|
||||
@Test
|
||||
public void tokenKeyDerived() throws Exception {
|
||||
this.properties.setUserInfoUri("http://example.com/userinfo");
|
||||
assertNotNull("Wrong properties: " + this.properties, this.properties.getJwt()
|
||||
.getKeyUri());
|
||||
assertNotNull("Wrong properties: " + this.properties,
|
||||
this.properties.getJwt().getKeyUri());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -73,8 +73,8 @@ public class ResourceServerTokenServicesConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void defaultIsRemoteTokenServices() {
|
||||
this.context = new SpringApplicationBuilder(ResourceConfiguration.class).web(
|
||||
false).run();
|
||||
this.context = new SpringApplicationBuilder(ResourceConfiguration.class)
|
||||
.web(false).run();
|
||||
RemoteTokenServices services = this.context.getBean(RemoteTokenServices.class);
|
||||
assertNotNull(services);
|
||||
}
|
||||
|
||||
@@ -62,13 +62,13 @@ public class UserInfoTokenServicesTests {
|
||||
@Before
|
||||
public void init() {
|
||||
this.resource.setClientId("foo");
|
||||
given(this.template.getForEntity(any(String.class), eq(Map.class))).willReturn(
|
||||
new ResponseEntity<Map>(this.map, HttpStatus.OK));
|
||||
given(this.template.getAccessToken()).willReturn(
|
||||
new DefaultOAuth2AccessToken("FOO"));
|
||||
given(this.template.getForEntity(any(String.class), eq(Map.class)))
|
||||
.willReturn(new ResponseEntity<Map>(this.map, HttpStatus.OK));
|
||||
given(this.template.getAccessToken())
|
||||
.willReturn(new DefaultOAuth2AccessToken("FOO"));
|
||||
given(this.template.getResource()).willReturn(this.resource);
|
||||
given(this.template.getOAuth2ClientContext()).willReturn(
|
||||
mock(OAuth2ClientContext.class));
|
||||
given(this.template.getOAuth2ClientContext())
|
||||
.willReturn(mock(OAuth2ClientContext.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -80,9 +80,9 @@ public class UserInfoTokenServicesTests {
|
||||
@Test
|
||||
public void badToken() {
|
||||
this.services.setRestTemplate(this.template);
|
||||
given(this.template.getForEntity(any(String.class), eq(Map.class))).willThrow(
|
||||
new UserRedirectRequiredException("foo:bar", Collections
|
||||
.<String, String>emptyMap()));
|
||||
given(this.template.getForEntity(any(String.class), eq(Map.class)))
|
||||
.willThrow(new UserRedirectRequiredException("foo:bar",
|
||||
Collections.<String, String>emptyMap()));
|
||||
this.expected.expect(InvalidTokenException.class);
|
||||
assertEquals("unknown", this.services.loadAuthentication("FOO").getName());
|
||||
}
|
||||
|
||||
@@ -38,10 +38,10 @@ import org.springframework.context.annotation.Import;
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Import({ EmbeddedServletContainerAutoConfiguration.class,
|
||||
ServerPropertiesAutoConfiguration.class,
|
||||
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
|
||||
HttpMessageConvertersAutoConfiguration.class, ErrorMvcAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class, SecurityAutoConfiguration.class })
|
||||
ServerPropertiesAutoConfiguration.class, DispatcherServletAutoConfiguration.class,
|
||||
WebMvcAutoConfiguration.class, HttpMessageConvertersAutoConfiguration.class,
|
||||
ErrorMvcAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class,
|
||||
SecurityAutoConfiguration.class })
|
||||
public @interface MinimalSecureWebConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@@ -76,12 +76,13 @@ public class SendGridAutoConfigurationTests {
|
||||
@Test
|
||||
public void expectedSendGridBeanWithProxyCreated() {
|
||||
loadContext("spring.sendgrid.username:user", "spring.sendgrid.password:secret",
|
||||
"spring.sendgrid.proxy.host:localhost", "spring.sendgrid.proxy.port:5678");
|
||||
"spring.sendgrid.proxy.host:localhost",
|
||||
"spring.sendgrid.proxy.port:5678");
|
||||
SendGrid sendGrid = this.context.getBean(SendGrid.class);
|
||||
CloseableHttpClient client = (CloseableHttpClient) ReflectionTestUtils.getField(
|
||||
sendGrid, "client");
|
||||
HttpRoutePlanner routePlanner = (HttpRoutePlanner) ReflectionTestUtils.getField(
|
||||
client, "routePlanner");
|
||||
CloseableHttpClient client = (CloseableHttpClient) ReflectionTestUtils
|
||||
.getField(sendGrid, "client");
|
||||
HttpRoutePlanner routePlanner = (HttpRoutePlanner) ReflectionTestUtils
|
||||
.getField(client, "routePlanner");
|
||||
assertThat(routePlanner, instanceOf(DefaultProxyRoutePlanner.class));
|
||||
}
|
||||
|
||||
|
||||
@@ -79,8 +79,8 @@ public class ImportAutoConfigurationImportSelectorTests {
|
||||
|
||||
private void configureValue(String... value) {
|
||||
String name = ImportAutoConfiguration.class.getName();
|
||||
given(this.annotationMetadata.getAnnotationAttributes(name, true)).willReturn(
|
||||
this.annotationAttributes);
|
||||
given(this.annotationMetadata.getAnnotationAttributes(name, true))
|
||||
.willReturn(this.annotationAttributes);
|
||||
given(this.annotationAttributes.getStringArray("value")).willReturn(value);
|
||||
}
|
||||
|
||||
|
||||
@@ -205,8 +205,8 @@ public class ThymeleafAutoConfigurationTests {
|
||||
this.context.register(ThymeleafAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
assertEquals(0, this.context.getBeansOfType(ResourceUrlEncodingFilter.class)
|
||||
.size());
|
||||
assertEquals(0,
|
||||
this.context.getBeansOfType(ResourceUrlEncodingFilter.class).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -88,8 +88,8 @@ public class VelocityAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void nonExistentTemplateLocation() {
|
||||
registerAndRefreshContext("spring.velocity.resourceLoaderPath:"
|
||||
+ "classpath:/does-not-exist/");
|
||||
registerAndRefreshContext(
|
||||
"spring.velocity.resourceLoaderPath:" + "classpath:/does-not-exist/");
|
||||
this.output.expect(containsString("Cannot find template location"));
|
||||
}
|
||||
|
||||
@@ -143,7 +143,8 @@ public class VelocityAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void customTemplateLoaderPath() throws Exception {
|
||||
registerAndRefreshContext("spring.velocity.resourceLoaderPath:classpath:/custom-templates/");
|
||||
registerAndRefreshContext(
|
||||
"spring.velocity.resourceLoaderPath:classpath:/custom-templates/");
|
||||
MockHttpServletResponse response = render("custom");
|
||||
String result = response.getContentAsString();
|
||||
assertThat(result, containsString("custom"));
|
||||
@@ -158,9 +159,12 @@ public class VelocityAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void customVelocitySettings() {
|
||||
registerAndRefreshContext("spring.velocity.properties.directive.parse.max.depth:10");
|
||||
assertThat(this.context.getBean(VelocityConfigurer.class).getVelocityEngine()
|
||||
.getProperty("directive.parse.max.depth"), equalTo((Object) "10"));
|
||||
registerAndRefreshContext(
|
||||
"spring.velocity.properties.directive.parse.max.depth:10");
|
||||
assertThat(
|
||||
this.context.getBean(VelocityConfigurer.class).getVelocityEngine()
|
||||
.getProperty("directive.parse.max.depth"),
|
||||
equalTo((Object) "10"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -205,8 +209,8 @@ public class VelocityAutoConfigurationTests {
|
||||
@Test
|
||||
public void registerResourceHandlingFilterDisabledByDefault() throws Exception {
|
||||
registerAndRefreshContext();
|
||||
assertEquals(0, this.context.getBeansOfType(ResourceUrlEncodingFilter.class)
|
||||
.size());
|
||||
assertEquals(0,
|
||||
this.context.getBeansOfType(ResourceUrlEncodingFilter.class).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user