Merge branch '6.2.x'
This commit is contained in:
commit
8db1340263
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2023 the original author or authors.
|
* Copyright 2002-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -46,8 +46,8 @@ public class AspectEntry implements ParseState.Entry {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Aspect: " + (StringUtils.hasLength(this.id) ? "id='" + this.id + "'"
|
return "Aspect: " + (StringUtils.hasLength(this.id) ? "id='" + this.id + "'" :
|
||||||
: "ref='" + this.ref + "'");
|
"ref='" + this.ref + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2023 the original author or authors.
|
* Copyright 2002-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -199,8 +199,8 @@ public abstract class ClassFilters {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object other) {
|
public boolean equals(Object other) {
|
||||||
return (this == other || (other instanceof NegateClassFilter that
|
return (this == other || (other instanceof NegateClassFilter that &&
|
||||||
&& this.original.equals(that.original)));
|
this.original.equals(that.original)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2023 the original author or authors.
|
* Copyright 2002-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -379,8 +379,8 @@ public abstract class MethodMatchers {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object other) {
|
public boolean equals(Object other) {
|
||||||
return (this == other || (other instanceof NegateMethodMatcher that
|
return (this == other || (other instanceof NegateMethodMatcher that &&
|
||||||
&& this.original.equals(that.original)));
|
this.original.equals(that.original)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2022 the original author or authors.
|
* Copyright 2002-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -211,9 +211,9 @@ public final class AotServices<T> implements Iterable<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T> Map<String, T> loadBeans(Class<T> type) {
|
private <T> Map<String, T> loadBeans(Class<T> type) {
|
||||||
return (this.beanFactory != null) ? BeanFactoryUtils
|
return (this.beanFactory != null ?
|
||||||
.beansOfTypeIncludingAncestors(this.beanFactory, type, true, false)
|
BeanFactoryUtils.beansOfTypeIncludingAncestors(this.beanFactory, type, true, false) :
|
||||||
: Collections.emptyMap();
|
Collections.emptyMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,8 +69,8 @@ class BeanDefinitionMethodGeneratorFactory {
|
||||||
this.excludeFilters = loader.load(BeanRegistrationExcludeFilter.class);
|
this.excludeFilters = loader.load(BeanRegistrationExcludeFilter.class);
|
||||||
for (BeanRegistrationExcludeFilter excludeFilter : this.excludeFilters) {
|
for (BeanRegistrationExcludeFilter excludeFilter : this.excludeFilters) {
|
||||||
if (this.excludeFilters.getSource(excludeFilter) == Source.BEAN_FACTORY) {
|
if (this.excludeFilters.getSource(excludeFilter) == Source.BEAN_FACTORY) {
|
||||||
Assert.state(excludeFilter instanceof BeanRegistrationAotProcessor
|
Assert.state(excludeFilter instanceof BeanRegistrationAotProcessor ||
|
||||||
|| excludeFilter instanceof BeanFactoryInitializationAotProcessor,
|
excludeFilter instanceof BeanFactoryInitializationAotProcessor,
|
||||||
() -> "BeanRegistrationExcludeFilter bean of type %s must also implement an AOT processor interface"
|
() -> "BeanRegistrationExcludeFilter bean of type %s must also implement an AOT processor interface"
|
||||||
.formatted(excludeFilter.getClass().getName()));
|
.formatted(excludeFilter.getClass().getName()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -233,8 +233,7 @@ public class InstanceSupplierCodeGenerator {
|
||||||
|
|
||||||
CodeBlock arguments = hasArguments ?
|
CodeBlock arguments = hasArguments ?
|
||||||
new AutowiredArgumentsCodeGenerator(actualType, constructor)
|
new AutowiredArgumentsCodeGenerator(actualType, constructor)
|
||||||
.generateCode(constructor.getParameterTypes(), (onInnerClass ? 1 : 0))
|
.generateCode(constructor.getParameterTypes(), (onInnerClass ? 1 : 0)) : NO_ARGS;
|
||||||
: NO_ARGS;
|
|
||||||
|
|
||||||
CodeBlock newInstance = generateNewInstanceCodeForConstructor(actualType, arguments);
|
CodeBlock newInstance = generateNewInstanceCodeForConstructor(actualType, arguments);
|
||||||
code.add(generateWithGeneratorCode(hasArguments, newInstance));
|
code.add(generateWithGeneratorCode(hasArguments, newInstance));
|
||||||
|
@ -324,8 +323,7 @@ public class InstanceSupplierCodeGenerator {
|
||||||
boolean hasArguments = factoryMethod.getParameterCount() > 0;
|
boolean hasArguments = factoryMethod.getParameterCount() > 0;
|
||||||
CodeBlock arguments = hasArguments ?
|
CodeBlock arguments = hasArguments ?
|
||||||
new AutowiredArgumentsCodeGenerator(ClassUtils.getUserClass(targetClass), factoryMethod)
|
new AutowiredArgumentsCodeGenerator(ClassUtils.getUserClass(targetClass), factoryMethod)
|
||||||
.generateCode(factoryMethod.getParameterTypes())
|
.generateCode(factoryMethod.getParameterTypes()) : NO_ARGS;
|
||||||
: NO_ARGS;
|
|
||||||
|
|
||||||
CodeBlock newInstance = generateNewInstanceCodeForMethod(
|
CodeBlock newInstance = generateNewInstanceCodeForMethod(
|
||||||
factoryBeanName, ClassUtils.getUserClass(targetClass), factoryMethodName, arguments);
|
factoryBeanName, ClassUtils.getUserClass(targetClass), factoryMethodName, arguments);
|
||||||
|
|
|
@ -66,8 +66,8 @@ public abstract class AbstractBeanDefinitionParser implements BeanDefinitionPars
|
||||||
String id = resolveId(element, definition, parserContext);
|
String id = resolveId(element, definition, parserContext);
|
||||||
if (!StringUtils.hasText(id)) {
|
if (!StringUtils.hasText(id)) {
|
||||||
parserContext.getReaderContext().error(
|
parserContext.getReaderContext().error(
|
||||||
"Id is required for element '" + parserContext.getDelegate().getLocalName(element)
|
"Id is required for element '" + parserContext.getDelegate().getLocalName(element) +
|
||||||
+ "' when used as a top-level tag", element);
|
"' when used as a top-level tag", element);
|
||||||
}
|
}
|
||||||
String[] aliases = null;
|
String[] aliases = null;
|
||||||
if (shouldParseNameAsAliases()) {
|
if (shouldParseNameAsAliases()) {
|
||||||
|
|
|
@ -71,8 +71,8 @@ class ParameterResolutionTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertAutowirableParameters(Executable executable) {
|
private void assertAutowirableParameters(Executable executable) {
|
||||||
int startIndex = (executable instanceof Constructor)
|
int startIndex = (executable instanceof Constructor) &&
|
||||||
&& ClassUtils.isInnerClass(executable.getDeclaringClass()) ? 1 : 0;
|
ClassUtils.isInnerClass(executable.getDeclaringClass()) ? 1 : 0;
|
||||||
Parameter[] parameters = executable.getParameters();
|
Parameter[] parameters = executable.getParameters();
|
||||||
for (int parameterIndex = startIndex; parameterIndex < parameters.length; parameterIndex++) {
|
for (int parameterIndex = startIndex; parameterIndex < parameters.length; parameterIndex++) {
|
||||||
Parameter parameter = parameters[parameterIndex];
|
Parameter parameter = parameters[parameterIndex];
|
||||||
|
|
|
@ -102,8 +102,8 @@ class BeanInstanceSupplierTests {
|
||||||
RegisteredBean registerBean = source.registerBean(this.beanFactory);
|
RegisteredBean registerBean = source.registerBean(this.beanFactory);
|
||||||
assertThatIllegalArgumentException()
|
assertThatIllegalArgumentException()
|
||||||
.isThrownBy(() -> resolver.get(registerBean)).withMessage(
|
.isThrownBy(() -> resolver.get(registerBean)).withMessage(
|
||||||
"Constructor with parameter types [java.io.InputStream] cannot be found on "
|
"Constructor with parameter types [java.io.InputStream] cannot be found on " +
|
||||||
+ SingleArgConstructor.class.getName());
|
SingleArgConstructor.class.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -150,8 +150,8 @@ class BeanInstanceSupplierTests {
|
||||||
RegisteredBean registerBean = source.registerBean(this.beanFactory);
|
RegisteredBean registerBean = source.registerBean(this.beanFactory);
|
||||||
assertThatIllegalArgumentException()
|
assertThatIllegalArgumentException()
|
||||||
.isThrownBy(() -> resolver.get(registerBean)).withMessage(
|
.isThrownBy(() -> resolver.get(registerBean)).withMessage(
|
||||||
"Factory method 'single' with parameter types [java.io.InputStream] declared on class "
|
"Factory method 'single' with parameter types [java.io.InputStream] declared on class " +
|
||||||
+ SingleArgFactory.class.getName() + " cannot be found");
|
SingleArgFactory.class.getName() + " cannot be found");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -86,8 +86,8 @@ class DefaultBeanRegistrationCodeFragmentsTests {
|
||||||
BeanRegistrationCodeFragments codeFragments = createInstance(registeredBean);
|
BeanRegistrationCodeFragments codeFragments = createInstance(registeredBean);
|
||||||
assertThatExceptionOfType(AotBeanProcessingException.class)
|
assertThatExceptionOfType(AotBeanProcessingException.class)
|
||||||
.isThrownBy(() -> codeFragments.getTarget(registeredBean))
|
.isThrownBy(() -> codeFragments.getTarget(registeredBean))
|
||||||
.withMessageContaining("Error processing bean with name 'testBean' defined in my test resource: "
|
.withMessageContaining("Error processing bean with name 'testBean' defined in my test resource: " +
|
||||||
+ "instance supplier is not supported");
|
"instance supplier is not supported");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -93,8 +93,8 @@ class MetadataCollector {
|
||||||
|
|
||||||
private boolean shouldBeMerged(ItemMetadata itemMetadata) {
|
private boolean shouldBeMerged(ItemMetadata itemMetadata) {
|
||||||
String sourceType = itemMetadata.getType();
|
String sourceType = itemMetadata.getType();
|
||||||
return (sourceType != null && !deletedInCurrentBuild(sourceType)
|
return (sourceType != null && !deletedInCurrentBuild(sourceType) &&
|
||||||
&& !processedInCurrentBuild(sourceType));
|
!processedInCurrentBuild(sourceType));
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean deletedInCurrentBuild(String sourceType) {
|
private boolean deletedInCurrentBuild(String sourceType) {
|
||||||
|
|
|
@ -42,8 +42,8 @@ class Metadata {
|
||||||
ItemMetadata itemMetadata = metadata.getItems().stream()
|
ItemMetadata itemMetadata = metadata.getItems().stream()
|
||||||
.filter(item -> item.getType().equals(type))
|
.filter(item -> item.getType().equals(type))
|
||||||
.findFirst().orElse(null);
|
.findFirst().orElse(null);
|
||||||
return itemMetadata != null && itemMetadata.getStereotypes().size() == stereotypes.size()
|
return (itemMetadata != null && itemMetadata.getStereotypes().size() == stereotypes.size() &&
|
||||||
&& itemMetadata.getStereotypes().containsAll(stereotypes);
|
itemMetadata.getStereotypes().containsAll(stereotypes));
|
||||||
}, "Candidates with type %s and stereotypes %s", type, stereotypes);
|
}, "Candidates with type %s and stereotypes %s", type, stereotypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,8 +81,8 @@ abstract class AbstractJCacheKeyOperation<A extends Annotation> extends Abstract
|
||||||
for (CacheParameterDetail keyParameterDetail : this.keyParameterDetails) {
|
for (CacheParameterDetail keyParameterDetail : this.keyParameterDetails) {
|
||||||
int parameterPosition = keyParameterDetail.getParameterPosition();
|
int parameterPosition = keyParameterDetail.getParameterPosition();
|
||||||
if (parameterPosition >= values.length) {
|
if (parameterPosition >= values.length) {
|
||||||
throw new IllegalStateException("Values mismatch, key parameter at position "
|
throw new IllegalStateException("Values mismatch, key parameter at position " +
|
||||||
+ parameterPosition + " cannot be matched against " + values.length + " value(s)");
|
parameterPosition + " cannot be matched against " + values.length + " value(s)");
|
||||||
}
|
}
|
||||||
result.add(keyParameterDetail.toCacheInvocationParameter(values[parameterPosition]));
|
result.add(keyParameterDetail.toCacheInvocationParameter(values[parameterPosition]));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2024 the original author or authors.
|
* Copyright 2002-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -17,7 +17,6 @@
|
||||||
package org.springframework.cache.jcache.interceptor;
|
package org.springframework.cache.jcache.interceptor;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
import javax.cache.annotation.CacheDefaults;
|
import javax.cache.annotation.CacheDefaults;
|
||||||
|
@ -150,9 +149,9 @@ class JCacheKeyGeneratorTests {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object generate(Object target, Method method, Object... params) {
|
public Object generate(Object target, Method method, Object... params) {
|
||||||
assertThat(Arrays.equals(expectedParams, params)).as("Unexpected parameters: expected: "
|
assertThat(params).as("Unexpected parameters").isEqualTo(expectedParams);
|
||||||
+ Arrays.toString(this.expectedParams) + " but got: " + Arrays.toString(params)).isTrue();
|
|
||||||
return new SimpleKey(params);
|
return new SimpleKey(params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -282,8 +282,8 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (NoSuchBeanDefinitionException ex) {
|
catch (NoSuchBeanDefinitionException ex) {
|
||||||
throw new NoSuchBeanDefinitionException(CacheManager.class, "no CacheResolver specified - "
|
throw new NoSuchBeanDefinitionException(CacheManager.class, "no CacheResolver specified - " +
|
||||||
+ "register a CacheManager bean or remove the @EnableCaching annotation from your configuration.");
|
"register a CacheManager bean or remove the @EnableCaching annotation from your configuration.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.initialized = true;
|
this.initialized = true;
|
||||||
|
|
|
@ -84,8 +84,8 @@ public class NameMatchCacheOperationSource implements CacheOperationSource, Seri
|
||||||
// Look for most specific name match.
|
// Look for most specific name match.
|
||||||
String bestNameMatch = null;
|
String bestNameMatch = null;
|
||||||
for (String mappedName : this.nameMap.keySet()) {
|
for (String mappedName : this.nameMap.keySet()) {
|
||||||
if (isMatch(methodName, mappedName)
|
if (isMatch(methodName, mappedName) &&
|
||||||
&& (bestNameMatch == null || bestNameMatch.length() <= mappedName.length())) {
|
(bestNameMatch == null || bestNameMatch.length() <= mappedName.length())) {
|
||||||
ops = this.nameMap.get(mappedName);
|
ops = this.nameMap.get(mappedName);
|
||||||
bestNameMatch = mappedName;
|
bestNameMatch = mappedName;
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,8 +107,8 @@ class ConfigurationClassParser {
|
||||||
(className.startsWith("java.lang.annotation.") || className.startsWith("org.springframework.stereotype."));
|
(className.startsWith("java.lang.annotation.") || className.startsWith("org.springframework.stereotype."));
|
||||||
|
|
||||||
private static final Predicate<Condition> REGISTER_BEAN_CONDITION_FILTER = condition ->
|
private static final Predicate<Condition> REGISTER_BEAN_CONDITION_FILTER = condition ->
|
||||||
(condition instanceof ConfigurationCondition configurationCondition
|
(condition instanceof ConfigurationCondition configurationCondition &&
|
||||||
&& ConfigurationPhase.REGISTER_BEAN.equals(configurationCondition.getConfigurationPhase()));
|
ConfigurationPhase.REGISTER_BEAN.equals(configurationCondition.getConfigurationPhase()));
|
||||||
|
|
||||||
private static final Comparator<DeferredImportSelectorHolder> DEFERRED_IMPORT_COMPARATOR =
|
private static final Comparator<DeferredImportSelectorHolder> DEFERRED_IMPORT_COMPARATOR =
|
||||||
(o1, o2) -> AnnotationAwareOrderComparator.INSTANCE.compare(o1.getImportSelector(), o2.getImportSelector());
|
(o1, o2) -> AnnotationAwareOrderComparator.INSTANCE.compare(o1.getImportSelector(), o2.getImportSelector());
|
||||||
|
|
|
@ -150,13 +150,13 @@ class ApplicationContextInitializationCodeGenerator implements BeanFactoryInitia
|
||||||
|
|
||||||
private @Nullable CodeBlock apply(ClassName className) {
|
private @Nullable CodeBlock apply(ClassName className) {
|
||||||
String name = className.canonicalName();
|
String name = className.canonicalName();
|
||||||
if (name.equals(DefaultListableBeanFactory.class.getName())
|
if (name.equals(DefaultListableBeanFactory.class.getName()) ||
|
||||||
|| name.equals(ListableBeanFactory.class.getName())
|
name.equals(ListableBeanFactory.class.getName()) ||
|
||||||
|| name.equals(ConfigurableListableBeanFactory.class.getName())) {
|
name.equals(ConfigurableListableBeanFactory.class.getName())) {
|
||||||
return CodeBlock.of(BEAN_FACTORY_VARIABLE);
|
return CodeBlock.of(BEAN_FACTORY_VARIABLE);
|
||||||
}
|
}
|
||||||
else if (name.equals(ConfigurableEnvironment.class.getName())
|
else if (name.equals(ConfigurableEnvironment.class.getName()) ||
|
||||||
|| name.equals(Environment.class.getName())) {
|
name.equals(Environment.class.getName())) {
|
||||||
return CodeBlock.of("$L.getEnvironment()", APPLICATION_CONTEXT_VARIABLE);
|
return CodeBlock.of("$L.getEnvironment()", APPLICATION_CONTEXT_VARIABLE);
|
||||||
}
|
}
|
||||||
else if (name.equals(ResourceLoader.class.getName())) {
|
else if (name.equals(ResourceLoader.class.getName())) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2024 the original author or authors.
|
* Copyright 2002-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -201,8 +201,8 @@ public class StandardBeanExpressionResolver implements BeanExpressionResolver {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
int maxLength = Integer.parseInt(value.trim());
|
int maxLength = Integer.parseInt(value.trim());
|
||||||
Assert.isTrue(maxLength > 0, () -> "Value [" + maxLength + "] for system property ["
|
Assert.isTrue(maxLength > 0, () -> "Value [" + maxLength + "] for system property [" +
|
||||||
+ MAX_SPEL_EXPRESSION_LENGTH_PROPERTY_NAME + "] must be positive");
|
MAX_SPEL_EXPRESSION_LENGTH_PROPERTY_NAME + "] must be positive");
|
||||||
return maxLength;
|
return maxLength;
|
||||||
}
|
}
|
||||||
catch (NumberFormatException ex) {
|
catch (NumberFormatException ex) {
|
||||||
|
|
|
@ -493,8 +493,8 @@ final class PostProcessorRegistrationDelegate {
|
||||||
|
|
||||||
private void postProcessValue(List<MergedBeanDefinitionPostProcessor> postProcessors,
|
private void postProcessValue(List<MergedBeanDefinitionPostProcessor> postProcessors,
|
||||||
BeanDefinitionValueResolver valueResolver, @Nullable Object value) {
|
BeanDefinitionValueResolver valueResolver, @Nullable Object value) {
|
||||||
if (value instanceof BeanDefinitionHolder bdh
|
if (value instanceof BeanDefinitionHolder bdh &&
|
||||||
&& bdh.getBeanDefinition() instanceof AbstractBeanDefinition innerBd) {
|
bdh.getBeanDefinition() instanceof AbstractBeanDefinition innerBd) {
|
||||||
|
|
||||||
Class<?> innerBeanType = resolveBeanType(innerBd);
|
Class<?> innerBeanType = resolveBeanType(innerBd);
|
||||||
resolveInnerBeanDefinition(valueResolver, innerBd, (innerBeanName, innerBeanDefinition)
|
resolveInnerBeanDefinition(valueResolver, innerBd, (innerBeanName, innerBeanDefinition)
|
||||||
|
|
|
@ -144,8 +144,8 @@ public abstract class DurationFormatterUtils {
|
||||||
|
|
||||||
private static final Pattern ISO_8601_PATTERN = Pattern.compile("^[+-]?[pP].*$");
|
private static final Pattern ISO_8601_PATTERN = Pattern.compile("^[+-]?[pP].*$");
|
||||||
private static final Pattern SIMPLE_PATTERN = Pattern.compile("^([+-]?\\d+)([a-zA-Z]{0,2})$");
|
private static final Pattern SIMPLE_PATTERN = Pattern.compile("^([+-]?\\d+)([a-zA-Z]{0,2})$");
|
||||||
private static final Pattern COMPOSITE_PATTERN = Pattern.compile("^([+-]?)\\(?\\s?(\\d+d)?\\s?(\\d+h)?\\s?(\\d+m)?"
|
private static final Pattern COMPOSITE_PATTERN = Pattern.compile("^([+-]?)\\(?\\s?(\\d+d)?\\s?(\\d+h)?\\s?(\\d+m)?" +
|
||||||
+ "\\s?(\\d+s)?\\s?(\\d+ms)?\\s?(\\d+us)?\\s?(\\d+ns)?\\)?$");
|
"\\s?(\\d+s)?\\s?(\\d+ms)?\\s?(\\d+us)?\\s?(\\d+ns)?\\)?$");
|
||||||
|
|
||||||
private static Duration parseIso8601(String value) {
|
private static Duration parseIso8601(String value) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -48,8 +48,8 @@ public class DefaultScheduledTaskObservationConvention implements ScheduledTaskO
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getContextualName(ScheduledTaskObservationContext context) {
|
public String getContextualName(ScheduledTaskObservationContext context) {
|
||||||
return "task " + StringUtils.uncapitalize(context.getTargetClass().getSimpleName())
|
return "task " + StringUtils.uncapitalize(context.getTargetClass().getSimpleName()) +
|
||||||
+ "." + context.getMethod().getName();
|
"." + context.getMethod().getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -106,8 +106,8 @@ class AspectAndAdvicePrecedenceTests {
|
||||||
private void checkAdvice(String whatJustHappened) {
|
private void checkAdvice(String whatJustHappened) {
|
||||||
//System.out.println("[" + adviceInvocationNumber + "] " + whatJustHappened + " ==> " + EXPECTED[adviceInvocationNumber]);
|
//System.out.println("[" + adviceInvocationNumber + "] " + whatJustHappened + " ==> " + EXPECTED[adviceInvocationNumber]);
|
||||||
if (adviceInvocationNumber > (EXPECTED.length - 1)) {
|
if (adviceInvocationNumber > (EXPECTED.length - 1)) {
|
||||||
throw new AssertionError("Too many advice invocations, expecting " + EXPECTED.length
|
throw new AssertionError("Too many advice invocations, expecting " + EXPECTED.length +
|
||||||
+ " but had " + adviceInvocationNumber);
|
" but had " + adviceInvocationNumber);
|
||||||
}
|
}
|
||||||
String expecting = EXPECTED[adviceInvocationNumber++];
|
String expecting = EXPECTED[adviceInvocationNumber++];
|
||||||
if (!whatJustHappened.equals(expecting)) {
|
if (!whatJustHappened.equals(expecting)) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2024 the original author or authors.
|
* Copyright 2002-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -277,8 +277,8 @@ public class GroovyScriptFactoryTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testScriptCompilationException() {
|
void testScriptCompilationException() {
|
||||||
assertThatExceptionOfType(NestedRuntimeException.class).isThrownBy(() ->
|
assertThatExceptionOfType(NestedRuntimeException.class)
|
||||||
new ClassPathXmlApplicationContext("org/springframework/scripting/groovy/groovyBrokenContext.xml"))
|
.isThrownBy(() -> new ClassPathXmlApplicationContext("org/springframework/scripting/groovy/groovyBrokenContext.xml"))
|
||||||
.matches(ex -> ex.contains(ScriptCompilationException.class));
|
.matches(ex -> ex.contains(ScriptCompilationException.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,10 +288,9 @@ public class GroovyScriptFactoryTests {
|
||||||
String badScript = "class Foo { public Foo(String foo) {}}";
|
String badScript = "class Foo { public Foo(String foo) {}}";
|
||||||
given(script.getScriptAsString()).willReturn(badScript);
|
given(script.getScriptAsString()).willReturn(badScript);
|
||||||
given(script.suggestedClassName()).willReturn("someName");
|
given(script.suggestedClassName()).willReturn("someName");
|
||||||
GroovyScriptFactory factory = new GroovyScriptFactory(ScriptFactoryPostProcessor.INLINE_SCRIPT_PREFIX
|
GroovyScriptFactory factory = new GroovyScriptFactory(ScriptFactoryPostProcessor.INLINE_SCRIPT_PREFIX + badScript);
|
||||||
+ badScript);
|
assertThatExceptionOfType(ScriptCompilationException.class)
|
||||||
assertThatExceptionOfType(ScriptCompilationException.class).isThrownBy(() ->
|
.isThrownBy(() -> factory.getScriptedObject(script))
|
||||||
factory.getScriptedObject(script))
|
|
||||||
.matches(ex -> ex.contains(NoSuchMethodException.class));
|
.matches(ex -> ex.contains(NoSuchMethodException.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,26 +326,23 @@ public class GroovyScriptFactoryTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testCtorWithNullScriptSourceLocator() {
|
void testCtorWithNullScriptSourceLocator() {
|
||||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
assertThatIllegalArgumentException().isThrownBy(() -> new GroovyScriptFactory(null));
|
||||||
new GroovyScriptFactory(null));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testCtorWithEmptyScriptSourceLocator() {
|
void testCtorWithEmptyScriptSourceLocator() {
|
||||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
assertThatIllegalArgumentException().isThrownBy(() -> new GroovyScriptFactory(""));
|
||||||
new GroovyScriptFactory(""));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testCtorWithWhitespacedScriptSourceLocator() {
|
void testCtorWithWhitespacedScriptSourceLocator() {
|
||||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
assertThatIllegalArgumentException().isThrownBy(() -> new GroovyScriptFactory("\n "));
|
||||||
new GroovyScriptFactory("\n "));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testWithInlineScriptWithLeadingWhitespace() {
|
void testWithInlineScriptWithLeadingWhitespace() {
|
||||||
assertThatExceptionOfType(BeanCreationException.class).as("'inline:' prefix was preceded by whitespace").isThrownBy(() ->
|
assertThatExceptionOfType(BeanCreationException.class).as("'inline:' prefix was preceded by whitespace")
|
||||||
new ClassPathXmlApplicationContext("lwspBadGroovyContext.xml", getClass()))
|
.isThrownBy(() -> new ClassPathXmlApplicationContext("lwspBadGroovyContext.xml", getClass()))
|
||||||
.matches(ex -> ex.contains(FileNotFoundException.class));
|
.matches(ex -> ex.contains(FileNotFoundException.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,8 +360,8 @@ public class GroovyScriptFactoryTests {
|
||||||
@Test
|
@Test
|
||||||
void testGetScriptedObjectDoesChokeOnNullScriptSourceBeingPassedIn() {
|
void testGetScriptedObjectDoesChokeOnNullScriptSourceBeingPassedIn() {
|
||||||
GroovyScriptFactory factory = new GroovyScriptFactory("a script source locator (doesn't matter here)");
|
GroovyScriptFactory factory = new GroovyScriptFactory("a script source locator (doesn't matter here)");
|
||||||
assertThatNullPointerException().as("NullPointerException as per contract ('null' ScriptSource supplied)").isThrownBy(() ->
|
assertThatNullPointerException().as("NullPointerException as per contract ('null' ScriptSource supplied)")
|
||||||
factory.getScriptedObject(null));
|
.isThrownBy(() -> factory.getScriptedObject(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -334,8 +334,8 @@ public abstract class InstrumentedBridgeMethods {
|
||||||
Object result = null;
|
Object result = null;
|
||||||
boolean accessibilityChanged = false;
|
boolean accessibilityChanged = false;
|
||||||
try {
|
try {
|
||||||
if (!Modifier.isPublic(method.getModifiers())
|
if (!Modifier.isPublic(method.getModifiers()) ||
|
||||||
|| !Modifier.isPublic(method.getDeclaringClass().getModifiers())) {
|
!Modifier.isPublic(method.getDeclaringClass().getModifiers())) {
|
||||||
method.setAccessible(true);
|
method.setAccessible(true);
|
||||||
accessibilityChanged = true;
|
accessibilityChanged = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,8 +78,8 @@ class InvocationsRecorderClassVisitor extends ClassVisitor implements Opcodes {
|
||||||
static {
|
static {
|
||||||
for (InstrumentedMethod method : InstrumentedMethod.values()) {
|
for (InstrumentedMethod method : InstrumentedMethod.values()) {
|
||||||
MethodReference methodReference = method.methodReference();
|
MethodReference methodReference = method.methodReference();
|
||||||
instrumentedMethods.add(methodReference.getClassName().replace('.', '/')
|
instrumentedMethods.add(methodReference.getClassName().replace('.', '/') +
|
||||||
+ "#" + methodReference.getMethodName());
|
"#" + methodReference.getMethodName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -108,8 +108,8 @@ public class RuntimeHintsInvocationsAssert extends AbstractAssert<RuntimeHintsIn
|
||||||
|
|
||||||
private String formatStackTrace(Stream<StackWalker.StackFrame> stackTraceElements) {
|
private String formatStackTrace(Stream<StackWalker.StackFrame> stackTraceElements) {
|
||||||
return stackTraceElements
|
return stackTraceElements
|
||||||
.map(f -> f.getClassName() + "#" + f.getMethodName()
|
.map(f -> f.getClassName() + "#" + f.getMethodName() + ", Line " +
|
||||||
+ ", Line " + f.getLineNumber()).collect(Collectors.joining(System.lineSeparator()));
|
f.getLineNumber()).collect(Collectors.joining(System.lineSeparator()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -122,8 +122,8 @@ public class MockSpringFactoriesLoader extends SpringFactoriesLoader {
|
||||||
public <T> void addInstance(String factoryType, T... factoryInstance) {
|
public <T> void addInstance(String factoryType, T... factoryInstance) {
|
||||||
List<String> implementations = this.factories.computeIfAbsent(factoryType, key -> new ArrayList<>());
|
List<String> implementations = this.factories.computeIfAbsent(factoryType, key -> new ArrayList<>());
|
||||||
for (T factoryImplementation : factoryInstance) {
|
for (T factoryImplementation : factoryInstance) {
|
||||||
String reference = "!" + factoryType + ":" + factoryImplementation.getClass().getName()
|
String reference = "!" + factoryType + ":" + factoryImplementation.getClass().getName() +
|
||||||
+ this.sequence.getAndIncrement();
|
this.sequence.getAndIncrement();
|
||||||
implementations.add(reference);
|
implementations.add(reference);
|
||||||
this.implementations.put(reference, factoryImplementation);
|
this.implementations.put(reference, factoryImplementation);
|
||||||
}
|
}
|
||||||
|
|
|
@ -298,8 +298,8 @@ public final class TestCompiler {
|
||||||
}
|
}
|
||||||
|
|
||||||
private DynamicClassLoader compile() {
|
private DynamicClassLoader compile() {
|
||||||
ClassLoader classLoaderToUse = (this.classLoader != null ? this.classLoader
|
ClassLoader classLoaderToUse = (this.classLoader != null ? this.classLoader :
|
||||||
: Thread.currentThread().getContextClassLoader());
|
Thread.currentThread().getContextClassLoader());
|
||||||
List<DynamicJavaFileObject> compilationUnits = this.sourceFiles.stream().map(
|
List<DynamicJavaFileObject> compilationUnits = this.sourceFiles.stream().map(
|
||||||
DynamicJavaFileObject::new).toList();
|
DynamicJavaFileObject::new).toList();
|
||||||
StandardJavaFileManager standardFileManager = this.compiler.getStandardFileManager(
|
StandardJavaFileManager standardFileManager = this.compiler.getStandardFileManager(
|
||||||
|
|
|
@ -102,8 +102,8 @@ public class DefaultMethodReference implements MethodReference {
|
||||||
TypeName argumentType = argumentTypes[i];
|
TypeName argumentType = argumentTypes[i];
|
||||||
CodeBlock argumentCode = argumentCodeGenerator.generateCode(argumentType);
|
CodeBlock argumentCode = argumentCodeGenerator.generateCode(argumentType);
|
||||||
if (argumentCode == null) {
|
if (argumentCode == null) {
|
||||||
throw new IllegalArgumentException("Could not generate code for " + this
|
throw new IllegalArgumentException("Could not generate code for " + this +
|
||||||
+ ": parameter " + i + " of type " + argumentType + " is not supported");
|
": parameter " + i + " of type " + argumentType + " is not supported");
|
||||||
}
|
}
|
||||||
arguments.add(argumentCode);
|
arguments.add(argumentCode);
|
||||||
}
|
}
|
||||||
|
|
|
@ -193,9 +193,9 @@ public interface GeneratedFiles {
|
||||||
|
|
||||||
private static void validatePackage(String packageName, String className) {
|
private static void validatePackage(String packageName, String className) {
|
||||||
if (!StringUtils.hasLength(packageName)) {
|
if (!StringUtils.hasLength(packageName)) {
|
||||||
throw new IllegalArgumentException("Could not add '" + className + "', "
|
throw new IllegalArgumentException("Could not add '" + className + "', " +
|
||||||
+ "processing classes in the default package is not supported. "
|
"processing classes in the default package is not supported. " +
|
||||||
+ "Did you forget to add a package statement?");
|
"Did you forget to add a package statement?");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -237,8 +237,8 @@ public abstract class ValueCodeGeneratorDelegates {
|
||||||
if (escaped != null) {
|
if (escaped != null) {
|
||||||
return escaped;
|
return escaped;
|
||||||
}
|
}
|
||||||
return (!Character.isISOControl(ch)) ? Character.toString(ch)
|
return (!Character.isISOControl(ch)) ? Character.toString(ch) :
|
||||||
: String.format("\\u%04x", (int) ch);
|
String.format("\\u%04x", (int) ch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -108,8 +108,8 @@ public class BindingReflectionHintsRegistrar {
|
||||||
registerPropertyHints(hints, seen, method, 0);
|
registerPropertyHints(hints, seen, method, 0);
|
||||||
}
|
}
|
||||||
else if ((methodName.startsWith("get") && method.getParameterCount() == 0 && method.getReturnType() != void.class) ||
|
else if ((methodName.startsWith("get") && method.getParameterCount() == 0 && method.getReturnType() != void.class) ||
|
||||||
(methodName.startsWith("is") && method.getParameterCount() == 0
|
(methodName.startsWith("is") && method.getParameterCount() == 0 &&
|
||||||
&& ClassUtils.resolvePrimitiveIfNecessary(method.getReturnType()) == Boolean.class)) {
|
ClassUtils.resolvePrimitiveIfNecessary(method.getReturnType()) == Boolean.class)) {
|
||||||
registerPropertyHints(hints, seen, method, -1);
|
registerPropertyHints(hints, seen, method, -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -369,8 +369,8 @@ final class TypeMappedAnnotation<A extends Annotation> extends AbstractMergedAnn
|
||||||
private Object getRequiredValue(int attributeIndex, String attributeName) {
|
private Object getRequiredValue(int attributeIndex, String attributeName) {
|
||||||
Object value = getValue(attributeIndex, Object.class);
|
Object value = getValue(attributeIndex, Object.class);
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
throw new NoSuchElementException("No element at attribute index "
|
throw new NoSuchElementException("No element at attribute index " +
|
||||||
+ attributeIndex + " for name " + attributeName);
|
attributeIndex + " for name " + attributeName);
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,8 +71,8 @@ public class ResourceRegionEncoder extends AbstractEncoder<ResourceRegion> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canEncode(ResolvableType elementType, @Nullable MimeType mimeType) {
|
public boolean canEncode(ResolvableType elementType, @Nullable MimeType mimeType) {
|
||||||
return super.canEncode(elementType, mimeType)
|
return super.canEncode(elementType, mimeType) &&
|
||||||
&& ResourceRegion.class.isAssignableFrom(elementType.toClass());
|
ResourceRegion.class.isAssignableFrom(elementType.toClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -461,8 +461,8 @@ public class SpringFactoriesLoader {
|
||||||
|
|
||||||
private static <T> void makeAccessible(Constructor<T> constructor,
|
private static <T> void makeAccessible(Constructor<T> constructor,
|
||||||
KFunction<T> kotlinConstructor) {
|
KFunction<T> kotlinConstructor) {
|
||||||
if ((!Modifier.isPublic(constructor.getModifiers())
|
if ((!Modifier.isPublic(constructor.getModifiers()) ||
|
||||||
|| !Modifier.isPublic(constructor.getDeclaringClass().getModifiers()))) {
|
!Modifier.isPublic(constructor.getDeclaringClass().getModifiers()))) {
|
||||||
KCallablesJvm.setAccessible(kotlinConstructor, true);
|
KCallablesJvm.setAccessible(kotlinConstructor, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -274,8 +274,8 @@ public class AntPathMatcher implements PathMatcher {
|
||||||
if (!matchStrings(pattDir, pathDirs[pathIdxEnd], uriTemplateVariables)) {
|
if (!matchStrings(pattDir, pathDirs[pathIdxEnd], uriTemplateVariables)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (pattIdxEnd == (pattDirs.length - 1)
|
if (pattIdxEnd == (pattDirs.length - 1) &&
|
||||||
&& pattern.endsWith(this.pathSeparator) != path.endsWith(this.pathSeparator)) {
|
pattern.endsWith(this.pathSeparator) != path.endsWith(this.pathSeparator)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
pattIdxEnd--;
|
pattIdxEnd--;
|
||||||
|
|
|
@ -549,9 +549,7 @@ public final class ConcurrentLruCache<K, V> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean contains(Node<K, V> e) {
|
private boolean contains(Node<K, V> e) {
|
||||||
return (e.getPrevious() != null)
|
return (e.getPrevious() != null) || (e.getNext() != null) || (e == this.first);
|
||||||
|| (e.getNext() != null)
|
|
||||||
|| (e == this.first);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void linkLast(final Node<K, V> e) {
|
private void linkLast(final Node<K, V> e) {
|
||||||
|
|
|
@ -71,8 +71,8 @@ class GeneratedFilesTests {
|
||||||
TypeSpec helloWorld = TypeSpec.classBuilder("HelloWorld").build();
|
TypeSpec helloWorld = TypeSpec.classBuilder("HelloWorld").build();
|
||||||
JavaFile javaFile = JavaFile.builder("", helloWorld).build();
|
JavaFile javaFile = JavaFile.builder("", helloWorld).build();
|
||||||
assertThatIllegalArgumentException().isThrownBy(() -> this.generatedFiles.addSourceFile(javaFile))
|
assertThatIllegalArgumentException().isThrownBy(() -> this.generatedFiles.addSourceFile(javaFile))
|
||||||
.withMessage("Could not add 'HelloWorld', processing classes in the "
|
.withMessage("Could not add 'HelloWorld', processing classes in the " +
|
||||||
+ "default package is not supported. Did you forget to add a package statement?");
|
"default package is not supported. Did you forget to add a package statement?");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -92,8 +92,8 @@ class GeneratedFilesTests {
|
||||||
void addSourceFileWithCharSequenceWhenClassNameIsInTheDefaultPackageThrowsException() {
|
void addSourceFileWithCharSequenceWhenClassNameIsInTheDefaultPackageThrowsException() {
|
||||||
assertThatIllegalArgumentException()
|
assertThatIllegalArgumentException()
|
||||||
.isThrownBy(() -> this.generatedFiles.addSourceFile("HelloWorld", "{}"))
|
.isThrownBy(() -> this.generatedFiles.addSourceFile("HelloWorld", "{}"))
|
||||||
.withMessage("Could not add 'HelloWorld', processing classes in the "
|
.withMessage("Could not add 'HelloWorld', processing classes in the " +
|
||||||
+ "default package is not supported. Did you forget to add a package statement?");
|
"default package is not supported. Did you forget to add a package statement?");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2024 the original author or authors.
|
* Copyright 2002-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -64,20 +64,17 @@ import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
*/
|
*/
|
||||||
class ValueCodeGeneratorTests {
|
class ValueCodeGeneratorTests {
|
||||||
|
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
class ConfigurationTests {
|
class ConfigurationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void createWithListOfDelegatesInvokeThemInOrder() {
|
void createWithListOfDelegatesInvokeThemInOrder() {
|
||||||
Delegate first = mock(Delegate.class);
|
Delegate first = mock();
|
||||||
Delegate second = mock(Delegate.class);
|
Delegate second = mock();
|
||||||
Delegate third = mock(Delegate.class);
|
Delegate third = mock();
|
||||||
ValueCodeGenerator codeGenerator = ValueCodeGenerator
|
ValueCodeGenerator codeGenerator = ValueCodeGenerator.with(List.of(first, second, third));
|
||||||
.with(List.of(first, second, third));
|
|
||||||
Object value = "";
|
Object value = "";
|
||||||
given(third.generateCode(codeGenerator, value))
|
given(third.generateCode(codeGenerator, value)).willReturn(CodeBlock.of("test"));
|
||||||
.willReturn(CodeBlock.of("test"));
|
|
||||||
CodeBlock code = codeGenerator.generateCode(value);
|
CodeBlock code = codeGenerator.generateCode(value);
|
||||||
assertThat(code).hasToString("test");
|
assertThat(code).hasToString("test");
|
||||||
InOrder ordered = inOrder(first, second, third);
|
InOrder ordered = inOrder(first, second, third);
|
||||||
|
@ -88,13 +85,11 @@ class ValueCodeGeneratorTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void generateCodeWithMatchingDelegateStops() {
|
void generateCodeWithMatchingDelegateStops() {
|
||||||
Delegate first = mock(Delegate.class);
|
Delegate first = mock();
|
||||||
Delegate second = mock(Delegate.class);
|
Delegate second = mock();
|
||||||
ValueCodeGenerator codeGenerator = ValueCodeGenerator
|
ValueCodeGenerator codeGenerator = ValueCodeGenerator.with(List.of(first, second));
|
||||||
.with(List.of(first, second));
|
|
||||||
Object value = "";
|
Object value = "";
|
||||||
given(first.generateCode(codeGenerator, value))
|
given(first.generateCode(codeGenerator, value)).willReturn(CodeBlock.of("test"));
|
||||||
.willReturn(CodeBlock.of("test"));
|
|
||||||
CodeBlock code = codeGenerator.generateCode(value);
|
CodeBlock code = codeGenerator.generateCode(value);
|
||||||
assertThat(code).hasToString("test");
|
assertThat(code).hasToString("test");
|
||||||
verify(first).generateCode(codeGenerator, value);
|
verify(first).generateCode(codeGenerator, value);
|
||||||
|
@ -198,7 +193,6 @@ class ValueCodeGeneratorTests {
|
||||||
assertThat(generateCode("test")).hasToString("\"test\"");
|
assertThat(generateCode("test")).hasToString("\"test\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void generateWhenStringWithCarriageReturn() {
|
void generateWhenStringWithCarriageReturn() {
|
||||||
assertThat(generateCode("test\n")).isEqualTo(CodeBlock.of("$S", "test\n"));
|
assertThat(generateCode("test\n")).isEqualTo(CodeBlock.of("$S", "test\n"));
|
||||||
|
@ -285,9 +279,9 @@ class ValueCodeGeneratorTests {
|
||||||
ResolvableType resolvableType = ResolvableType.forClassWithGenerics(Map.class,
|
ResolvableType resolvableType = ResolvableType.forClassWithGenerics(Map.class,
|
||||||
ResolvableType.forClass(Integer.class), stringList);
|
ResolvableType.forClass(Integer.class), stringList);
|
||||||
assertThat(resolve(generateCode(resolvableType)))
|
assertThat(resolve(generateCode(resolvableType)))
|
||||||
.hasImport(ResolvableType.class, List.class, Map.class).hasValueCode(
|
.hasImport(ResolvableType.class, List.class, Map.class).hasValueCode("""
|
||||||
"ResolvableType.forClassWithGenerics(Map.class, ResolvableType.forClass(Integer.class), "
|
ResolvableType.forClassWithGenerics(Map.class, ResolvableType.forClass(Integer.class), \
|
||||||
+ "ResolvableType.forClassWithGenerics(List.class, String.class))");
|
ResolvableType.forClassWithGenerics(List.class, String.class))""");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -217,10 +217,10 @@ class ReflectionHintsTests {
|
||||||
typeHint -> typeHint.withMembers(MemberCategory.INTROSPECT_PUBLIC_METHODS));
|
typeHint -> typeHint.withMembers(MemberCategory.INTROSPECT_PUBLIC_METHODS));
|
||||||
assertThat(this.reflectionHints.typeHints()).hasSize(2)
|
assertThat(this.reflectionHints.typeHints()).hasSize(2)
|
||||||
.noneMatch(typeHint -> typeHint.getType().getCanonicalName().equals(Serializable.class.getCanonicalName()))
|
.noneMatch(typeHint -> typeHint.getType().getCanonicalName().equals(Serializable.class.getCanonicalName()))
|
||||||
.anyMatch(typeHint -> typeHint.getType().getCanonicalName().equals(SecondInterface.class.getCanonicalName())
|
.anyMatch(typeHint -> typeHint.getType().getCanonicalName().equals(SecondInterface.class.getCanonicalName()) &&
|
||||||
&& typeHint.getMemberCategories().contains(MemberCategory.INTROSPECT_PUBLIC_METHODS))
|
typeHint.getMemberCategories().contains(MemberCategory.INTROSPECT_PUBLIC_METHODS))
|
||||||
.anyMatch(typeHint -> typeHint.getType().getCanonicalName().equals(FirstInterface.class.getCanonicalName())
|
.anyMatch(typeHint -> typeHint.getType().getCanonicalName().equals(FirstInterface.class.getCanonicalName()) &&
|
||||||
&& typeHint.getMemberCategories().contains(MemberCategory.INTROSPECT_PUBLIC_METHODS));
|
typeHint.getMemberCategories().contains(MemberCategory.INTROSPECT_PUBLIC_METHODS));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertTestTypeMethodHints(Consumer<ExecutableHint> methodHint) {
|
private void assertTestTypeMethodHints(Consumer<ExecutableHint> methodHint) {
|
||||||
|
|
|
@ -54,27 +54,24 @@ class AnnotationTypeMappingsTests {
|
||||||
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(SimpleAnnotation.class);
|
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(SimpleAnnotation.class);
|
||||||
assertThat(mappings.size()).isEqualTo(1);
|
assertThat(mappings.size()).isEqualTo(1);
|
||||||
assertThat(mappings.get(0).getAnnotationType()).isEqualTo(SimpleAnnotation.class);
|
assertThat(mappings.get(0).getAnnotationType()).isEqualTo(SimpleAnnotation.class);
|
||||||
assertThat(getAll(mappings)).flatExtracting(
|
assertThat(getAll(mappings)).flatExtracting(AnnotationTypeMapping::getAnnotationType)
|
||||||
AnnotationTypeMapping::getAnnotationType).containsExactly(SimpleAnnotation.class);
|
.containsExactly(SimpleAnnotation.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void forAnnotationTypeWhenMetaAnnotationsReturnsMappings() {
|
void forAnnotationTypeWhenMetaAnnotationsReturnsMappings() {
|
||||||
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(MetaAnnotated.class);
|
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(MetaAnnotated.class);
|
||||||
assertThat(mappings.size()).isEqualTo(6);
|
assertThat(mappings.size()).isEqualTo(6);
|
||||||
assertThat(getAll(mappings)).flatExtracting(
|
assertThat(getAll(mappings)).flatExtracting(AnnotationTypeMapping::getAnnotationType)
|
||||||
AnnotationTypeMapping::getAnnotationType).containsExactly(
|
.containsExactly(MetaAnnotated.class, A.class, B.class, AA.class, AB.class, ABC.class);
|
||||||
MetaAnnotated.class, A.class, B.class, AA.class, AB.class,
|
|
||||||
ABC.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void forAnnotationTypeWhenHasRepeatingMetaAnnotationReturnsMapping() {
|
void forAnnotationTypeWhenHasRepeatingMetaAnnotationReturnsMapping() {
|
||||||
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(WithRepeatedMetaAnnotations.class);
|
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(WithRepeatedMetaAnnotations.class);
|
||||||
assertThat(mappings.size()).isEqualTo(3);
|
assertThat(mappings.size()).isEqualTo(3);
|
||||||
assertThat(getAll(mappings)).flatExtracting(
|
assertThat(getAll(mappings)).flatExtracting(AnnotationTypeMapping::getAnnotationType)
|
||||||
AnnotationTypeMapping::getAnnotationType).containsExactly(
|
.containsExactly(WithRepeatedMetaAnnotations.class, Repeating.class, Repeating.class);
|
||||||
WithRepeatedMetaAnnotations.class, Repeating.class, Repeating.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -89,56 +86,52 @@ class AnnotationTypeMappingsTests {
|
||||||
void forAnnotationTypeWhenSelfAnnotatedReturnsMapping() {
|
void forAnnotationTypeWhenSelfAnnotatedReturnsMapping() {
|
||||||
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(SelfAnnotated.class);
|
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(SelfAnnotated.class);
|
||||||
assertThat(mappings.size()).isEqualTo(1);
|
assertThat(mappings.size()).isEqualTo(1);
|
||||||
assertThat(getAll(mappings)).flatExtracting(
|
assertThat(getAll(mappings)).flatExtracting(AnnotationTypeMapping::getAnnotationType)
|
||||||
AnnotationTypeMapping::getAnnotationType).containsExactly(SelfAnnotated.class);
|
.containsExactly(SelfAnnotated.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void forAnnotationTypeWhenFormsLoopReturnsMapping() {
|
void forAnnotationTypeWhenFormsLoopReturnsMapping() {
|
||||||
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(LoopA.class);
|
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(LoopA.class);
|
||||||
assertThat(mappings.size()).isEqualTo(2);
|
assertThat(mappings.size()).isEqualTo(2);
|
||||||
assertThat(getAll(mappings)).flatExtracting(
|
assertThat(getAll(mappings)).flatExtracting(AnnotationTypeMapping::getAnnotationType)
|
||||||
AnnotationTypeMapping::getAnnotationType).containsExactly(LoopA.class, LoopB.class);
|
.containsExactly(LoopA.class, LoopB.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void forAnnotationTypeWhenHasAliasForWithBothValueAndAttributeThrowsException() {
|
void forAnnotationTypeWhenHasAliasForWithBothValueAndAttributeThrowsException() {
|
||||||
assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
|
assertThatExceptionOfType(AnnotationConfigurationException.class)
|
||||||
AnnotationTypeMappings.forAnnotationType(AliasForWithBothValueAndAttribute.class))
|
.isThrownBy(() -> AnnotationTypeMappings.forAnnotationType(AliasForWithBothValueAndAttribute.class))
|
||||||
.withMessage("In @AliasFor declared on attribute 'test' in annotation ["
|
.withMessage("In @AliasFor declared on attribute 'test' in annotation [%s], attribute 'attribute' " +
|
||||||
+ AliasForWithBothValueAndAttribute.class.getName()
|
"and its alias 'value' are present with values of 'foo' and 'bar', but only one is permitted.",
|
||||||
+ "], attribute 'attribute' and its alias 'value' are present with values of 'foo' and 'bar', but only one is permitted.");
|
AliasForWithBothValueAndAttribute.class.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void forAnnotationTypeWhenAliasForToSelfNonExistingAttribute() {
|
void forAnnotationTypeWhenAliasForToSelfNonExistingAttribute() {
|
||||||
assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
|
assertThatExceptionOfType(AnnotationConfigurationException.class)
|
||||||
AnnotationTypeMappings.forAnnotationType(AliasForToSelfNonExistingAttribute.class))
|
.isThrownBy(() -> AnnotationTypeMappings.forAnnotationType(AliasForToSelfNonExistingAttribute.class))
|
||||||
.withMessage("@AliasFor declaration on attribute 'test' in annotation ["
|
.withMessage("@AliasFor declaration on attribute 'test' in annotation [%s] " +
|
||||||
+ AliasForToSelfNonExistingAttribute.class.getName()
|
"declares an alias for 'missing' which is not present.",
|
||||||
+ "] declares an alias for 'missing' which is not present.");
|
AliasForToSelfNonExistingAttribute.class.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void forAnnotationTypeWhenAliasForToOtherNonExistingAttribute() {
|
void forAnnotationTypeWhenAliasForToOtherNonExistingAttribute() {
|
||||||
assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
|
assertThatExceptionOfType(AnnotationConfigurationException.class)
|
||||||
AnnotationTypeMappings.forAnnotationType(AliasForToOtherNonExistingAttribute.class))
|
.isThrownBy(() -> AnnotationTypeMappings.forAnnotationType(AliasForToOtherNonExistingAttribute.class))
|
||||||
.withMessage("Attribute 'test' in annotation ["
|
.withMessage("Attribute 'test' in annotation [%s] is declared as an @AliasFor nonexistent " +
|
||||||
+ AliasForToOtherNonExistingAttribute.class.getName()
|
"attribute 'missing' in annotation [%s].", AliasForToOtherNonExistingAttribute.class.getName(),
|
||||||
+ "] is declared as an @AliasFor nonexistent "
|
AliasForToOtherNonExistingAttributeTarget.class.getName());
|
||||||
+ "attribute 'missing' in annotation ["
|
|
||||||
+ AliasForToOtherNonExistingAttributeTarget.class.getName()
|
|
||||||
+ "].");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void forAnnotationTypeWhenAliasForToSelf() {
|
void forAnnotationTypeWhenAliasForToSelf() {
|
||||||
assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
|
assertThatExceptionOfType(AnnotationConfigurationException.class)
|
||||||
AnnotationTypeMappings.forAnnotationType(AliasForToSelf.class))
|
.isThrownBy(() -> AnnotationTypeMappings.forAnnotationType(AliasForToSelf.class))
|
||||||
.withMessage("@AliasFor declaration on attribute 'test' in annotation ["
|
.withMessage("@AliasFor declaration on attribute 'test' in annotation [%s] points to itself. " +
|
||||||
+ AliasForToSelf.class.getName()
|
"Specify 'annotation' to point to a same-named attribute on a meta-annotation.",
|
||||||
+ "] points to itself. Specify 'annotation' to point to "
|
AliasForToSelf.class.getName());
|
||||||
+ "a same-named attribute on a meta-annotation.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -152,13 +145,12 @@ class AnnotationTypeMappingsTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void forAnnotationTypeWhenAliasForWithIncompatibleReturnTypes() {
|
void forAnnotationTypeWhenAliasForWithIncompatibleReturnTypes() {
|
||||||
assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
|
assertThatExceptionOfType(AnnotationConfigurationException.class)
|
||||||
AnnotationTypeMappings.forAnnotationType(AliasForWithIncompatibleReturnTypes.class))
|
.isThrownBy(() -> AnnotationTypeMappings.forAnnotationType(AliasForWithIncompatibleReturnTypes.class))
|
||||||
.withMessage("Misconfigured aliases: attribute 'test' in annotation ["
|
.withMessage("Misconfigured aliases: attribute 'test' in annotation [%s] and attribute 'test' " +
|
||||||
+ AliasForWithIncompatibleReturnTypes.class.getName()
|
"in annotation [%s] must declare the same return type.",
|
||||||
+ "] and attribute 'test' in annotation ["
|
AliasForWithIncompatibleReturnTypes.class.getName(),
|
||||||
+ AliasForWithIncompatibleReturnTypesTarget.class.getName()
|
AliasForWithIncompatibleReturnTypesTarget.class.getName());
|
||||||
+ "] must declare the same return type.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -166,9 +158,8 @@ class AnnotationTypeMappingsTests {
|
||||||
String annotationType = AliasForToSelfAnnotatedToOtherAttribute.class.getName();
|
String annotationType = AliasForToSelfAnnotatedToOtherAttribute.class.getName();
|
||||||
assertThatExceptionOfType(AnnotationConfigurationException.class)
|
assertThatExceptionOfType(AnnotationConfigurationException.class)
|
||||||
.isThrownBy(() -> AnnotationTypeMappings.forAnnotationType(AliasForToSelfAnnotatedToOtherAttribute.class))
|
.isThrownBy(() -> AnnotationTypeMappings.forAnnotationType(AliasForToSelfAnnotatedToOtherAttribute.class))
|
||||||
.withMessage("Attribute 'b' in annotation [" + annotationType
|
.withMessage("Attribute 'b' in annotation [%1$s] must be declared as an @AliasFor attribute 'a' in " +
|
||||||
+ "] must be declared as an @AliasFor attribute 'a' in annotation [" + annotationType
|
"annotation [%1$s], not attribute 'c' in annotation [%1$s].", annotationType);
|
||||||
+ "], not attribute 'c' in annotation [" + annotationType + "].");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -182,53 +173,45 @@ class AnnotationTypeMappingsTests {
|
||||||
String metaAnnotationName = AliasPair.class.getName();
|
String metaAnnotationName = AliasPair.class.getName();
|
||||||
assertThatExceptionOfType(AnnotationConfigurationException.class)
|
assertThatExceptionOfType(AnnotationConfigurationException.class)
|
||||||
.isThrownBy(() -> AnnotationTypeMappings.forAnnotationType(annotationType))
|
.isThrownBy(() -> AnnotationTypeMappings.forAnnotationType(annotationType))
|
||||||
.withMessage("Attribute 'b' in annotation [" + annotationName
|
.withMessage("Attribute 'b' in annotation [" + annotationName +
|
||||||
+ "] must be declared as an @AliasFor attribute 'a' in annotation [" + annotationName
|
"] must be declared as an @AliasFor attribute 'a' in annotation [" + annotationName +
|
||||||
+ "], not attribute '" + overriddenAttribute + "' in annotation [" + metaAnnotationName + "].");
|
"], not attribute '" + overriddenAttribute + "' in annotation [" + metaAnnotationName + "].");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void forAnnotationTypeWhenAliasForNonMetaAnnotated() {
|
void forAnnotationTypeWhenAliasForNonMetaAnnotated() {
|
||||||
assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
|
assertThatExceptionOfType(AnnotationConfigurationException.class)
|
||||||
AnnotationTypeMappings.forAnnotationType(AliasForNonMetaAnnotated.class))
|
.isThrownBy(() -> AnnotationTypeMappings.forAnnotationType(AliasForNonMetaAnnotated.class))
|
||||||
.withMessage("@AliasFor declaration on attribute 'test' in annotation ["
|
.withMessage("@AliasFor declaration on attribute 'test' in annotation [" + AliasForNonMetaAnnotated.class.getName() +
|
||||||
+ AliasForNonMetaAnnotated.class.getName()
|
"] declares an alias for attribute 'test' in annotation [" + AliasForNonMetaAnnotatedTarget.class.getName() +
|
||||||
+ "] declares an alias for attribute 'test' in annotation ["
|
"] which is not meta-present.");
|
||||||
+ AliasForNonMetaAnnotatedTarget.class.getName()
|
|
||||||
+ "] which is not meta-present.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void forAnnotationTypeWhenAliasForSelfWithDifferentDefaults() {
|
void forAnnotationTypeWhenAliasForSelfWithDifferentDefaults() {
|
||||||
assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
|
assertThatExceptionOfType(AnnotationConfigurationException.class)
|
||||||
AnnotationTypeMappings.forAnnotationType(AliasForSelfWithDifferentDefaults.class))
|
.isThrownBy(() -> AnnotationTypeMappings.forAnnotationType(AliasForSelfWithDifferentDefaults.class))
|
||||||
.withMessage("Misconfigured aliases: attribute 'a' in annotation ["
|
.withMessage("Misconfigured aliases: attribute 'a' in annotation [" + AliasForSelfWithDifferentDefaults.class.getName() +
|
||||||
+ AliasForSelfWithDifferentDefaults.class.getName()
|
"] and attribute 'b' in annotation [" + AliasForSelfWithDifferentDefaults.class.getName() +
|
||||||
+ "] and attribute 'b' in annotation ["
|
"] must declare the same default value.");
|
||||||
+ AliasForSelfWithDifferentDefaults.class.getName()
|
|
||||||
+ "] must declare the same default value.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void forAnnotationTypeWhenAliasForSelfWithMissingDefault() {
|
void forAnnotationTypeWhenAliasForSelfWithMissingDefault() {
|
||||||
assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
|
assertThatExceptionOfType(AnnotationConfigurationException.class)
|
||||||
AnnotationTypeMappings.forAnnotationType(AliasForSelfWithMissingDefault.class))
|
.isThrownBy(() -> AnnotationTypeMappings.forAnnotationType(AliasForSelfWithMissingDefault.class))
|
||||||
.withMessage("Misconfigured aliases: attribute 'a' in annotation ["
|
.withMessage("Misconfigured aliases: attribute 'a' in annotation [" + AliasForSelfWithMissingDefault.class.getName() +
|
||||||
+ AliasForSelfWithMissingDefault.class.getName()
|
"] and attribute 'b' in annotation [" + AliasForSelfWithMissingDefault.class.getName() +
|
||||||
+ "] and attribute 'b' in annotation ["
|
"] must declare default values.");
|
||||||
+ AliasForSelfWithMissingDefault.class.getName()
|
|
||||||
+ "] must declare default values.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void forAnnotationTypeWhenAliasWithExplicitMirrorAndDifferentDefaults() {
|
void forAnnotationTypeWhenAliasWithExplicitMirrorAndDifferentDefaults() {
|
||||||
assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
|
assertThatExceptionOfType(AnnotationConfigurationException.class)
|
||||||
AnnotationTypeMappings.forAnnotationType(AliasWithExplicitMirrorAndDifferentDefaults.class))
|
.isThrownBy(() -> AnnotationTypeMappings.forAnnotationType(AliasWithExplicitMirrorAndDifferentDefaults.class))
|
||||||
.withMessage("Misconfigured aliases: attribute 'a' in annotation ["
|
.withMessage("Misconfigured aliases: attribute 'a' in annotation [" + AliasWithExplicitMirrorAndDifferentDefaults.class.getName() +
|
||||||
+ AliasWithExplicitMirrorAndDifferentDefaults.class.getName()
|
"] and attribute 'c' in annotation [" + AliasWithExplicitMirrorAndDifferentDefaults.class.getName() +
|
||||||
+ "] and attribute 'c' in annotation ["
|
"] must declare the same default value.");
|
||||||
+ AliasWithExplicitMirrorAndDifferentDefaults.class.getName()
|
|
||||||
+ "] must declare the same default value.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -369,18 +352,16 @@ class AnnotationTypeMappingsTests {
|
||||||
@Test
|
@Test
|
||||||
void resolveMirrorsWhenHasDifferentValuesThrowsException() {
|
void resolveMirrorsWhenHasDifferentValuesThrowsException() {
|
||||||
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(AliasPair.class).get(0);
|
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(AliasPair.class).get(0);
|
||||||
assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
|
assertThatExceptionOfType(AnnotationConfigurationException.class)
|
||||||
resolveMirrorSets(mapping, WithDifferentValueAliasPair.class, AliasPair.class))
|
.isThrownBy(() -> resolveMirrorSets(mapping, WithDifferentValueAliasPair.class, AliasPair.class))
|
||||||
.withMessage("Different @AliasFor mirror values for annotation ["
|
.withMessage("Different @AliasFor mirror values for annotation [" + AliasPair.class.getName() + "] declared on " +
|
||||||
+ AliasPair.class.getName() + "] declared on "
|
WithDifferentValueAliasPair.class.getName() +
|
||||||
+ WithDifferentValueAliasPair.class.getName()
|
"; attribute 'a' and its alias 'b' are declared with values of [test1] and [test2].");
|
||||||
+ "; attribute 'a' and its alias 'b' are declared with values of [test1] and [test2].");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void resolveMirrorsWhenHasWithMultipleRoutesToAliasReturnsMirrors() {
|
void resolveMirrorsWhenHasWithMultipleRoutesToAliasReturnsMirrors() {
|
||||||
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(
|
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(MultipleRoutesToAliasA.class);
|
||||||
MultipleRoutesToAliasA.class);
|
|
||||||
AnnotationTypeMapping mappingsA = getMapping(mappings, MultipleRoutesToAliasA.class);
|
AnnotationTypeMapping mappingsA = getMapping(mappings, MultipleRoutesToAliasA.class);
|
||||||
assertThat(mappingsA.getMirrorSets().size()).isZero();
|
assertThat(mappingsA.getMirrorSets().size()).isZero();
|
||||||
AnnotationTypeMapping mappingsB = getMapping(mappings, MultipleRoutesToAliasB.class);
|
AnnotationTypeMapping mappingsB = getMapping(mappings, MultipleRoutesToAliasB.class);
|
||||||
|
@ -391,8 +372,7 @@ class AnnotationTypeMappingsTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void getAliasMappingWhenHasWithMultipleRoutesToAliasReturnsMappedAttributes() {
|
void getAliasMappingWhenHasWithMultipleRoutesToAliasReturnsMappedAttributes() {
|
||||||
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(
|
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(MultipleRoutesToAliasA.class);
|
||||||
MultipleRoutesToAliasA.class);
|
|
||||||
AnnotationTypeMapping mappingsA = getMapping(mappings, MultipleRoutesToAliasA.class);
|
AnnotationTypeMapping mappingsA = getMapping(mappings, MultipleRoutesToAliasA.class);
|
||||||
assertThat(getAliasMapping(mappingsA, 0)).isNull();
|
assertThat(getAliasMapping(mappingsA, 0)).isNull();
|
||||||
AnnotationTypeMapping mappingsB = getMapping(mappings, MultipleRoutesToAliasB.class);
|
AnnotationTypeMapping mappingsB = getMapping(mappings, MultipleRoutesToAliasB.class);
|
||||||
|
|
|
@ -923,8 +923,8 @@ class AnnotationUtilsTests {
|
||||||
Map<String, Object> map = Collections.singletonMap(VALUE, 42L);
|
Map<String, Object> map = Collections.singletonMap(VALUE, 42L);
|
||||||
assertThatIllegalStateException().isThrownBy(() ->
|
assertThatIllegalStateException().isThrownBy(() ->
|
||||||
synthesizeAnnotation(map, Component.class, null).value())
|
synthesizeAnnotation(map, Component.class, null).value())
|
||||||
.withMessageContaining("Attribute 'value' in annotation org.springframework.core.testfixture.stereotype.Component "
|
.withMessageContaining("Attribute 'value' in annotation org.springframework.core.testfixture.stereotype.Component " +
|
||||||
+ "should be compatible with java.lang.String but a java.lang.Long value was returned");
|
"should be compatible with java.lang.String but a java.lang.Long value was returned");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -120,9 +120,7 @@ class MergedAnnotationClassLoaderTests {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isEligibleForOverriding(String className) {
|
protected boolean isEligibleForOverriding(String className) {
|
||||||
return WITH_TEST_ANNOTATION.equals(className)
|
return WITH_TEST_ANNOTATION.equals(className) || TEST_ANNOTATION.equals(className) || TEST_REFERENCE.equals(className);
|
||||||
|| TEST_ANNOTATION.equals(className)
|
|
||||||
|| TEST_REFERENCE.equals(className);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,8 +171,7 @@ class MergedAnnotationsCollectionTests {
|
||||||
void getWithSelectorReturnsSelected() {
|
void getWithSelectorReturnsSelected() {
|
||||||
MergedAnnotations annotations = getMultiRoute1();
|
MergedAnnotations annotations = getMultiRoute1();
|
||||||
MergedAnnotationSelector<MultiRouteTarget> deepest = (existing,
|
MergedAnnotationSelector<MultiRouteTarget> deepest = (existing,
|
||||||
candidate) -> candidate.getDistance() > existing.getDistance() ? candidate
|
candidate) -> candidate.getDistance() > existing.getDistance() ? candidate : existing;
|
||||||
: existing;
|
|
||||||
assertThat(annotations.get(MultiRouteTarget.class, null, deepest).getString(
|
assertThat(annotations.get(MultiRouteTarget.class, null, deepest).getString(
|
||||||
MergedAnnotation.VALUE)).isEqualTo("111");
|
MergedAnnotation.VALUE)).isEqualTo("111");
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,8 +99,8 @@ class SpringFactoriesLoaderTests {
|
||||||
void loadWhenIncompatibleTypeThrowsException() {
|
void loadWhenIncompatibleTypeThrowsException() {
|
||||||
assertThatIllegalArgumentException()
|
assertThatIllegalArgumentException()
|
||||||
.isThrownBy(() -> SpringFactoriesLoader.forDefaultResourceLocation().load(String.class))
|
.isThrownBy(() -> SpringFactoriesLoader.forDefaultResourceLocation().load(String.class))
|
||||||
.withMessageContaining("Unable to instantiate factory class "
|
.withMessageContaining("Unable to instantiate factory class " +
|
||||||
+ "[org.springframework.core.io.support.MyDummyFactory1] for factory type [java.lang.String]");
|
"[org.springframework.core.io.support.MyDummyFactory1] for factory type [java.lang.String]");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -127,8 +127,8 @@ class SpringFactoriesLoaderTests {
|
||||||
assertThatIllegalArgumentException()
|
assertThatIllegalArgumentException()
|
||||||
.isThrownBy(() -> SpringFactoriesLoader.forDefaultResourceLocation(LimitedClassLoader.multipleArgumentFactories)
|
.isThrownBy(() -> SpringFactoriesLoader.forDefaultResourceLocation(LimitedClassLoader.multipleArgumentFactories)
|
||||||
.load(DummyFactory.class, resolver))
|
.load(DummyFactory.class, resolver))
|
||||||
.withMessageContaining("Unable to instantiate factory class "
|
.withMessageContaining("Unable to instantiate factory class " +
|
||||||
+ "[org.springframework.core.io.support.MultipleConstructorArgsDummyFactory] for factory type [org.springframework.core.io.support.DummyFactory]")
|
"[org.springframework.core.io.support.MultipleConstructorArgsDummyFactory] for factory type [org.springframework.core.io.support.DummyFactory]")
|
||||||
.havingRootCause().withMessageContaining("Class [org.springframework.core.io.support.MultipleConstructorArgsDummyFactory] has no suitable constructor");
|
.havingRootCause().withMessageContaining("Class [org.springframework.core.io.support.MultipleConstructorArgsDummyFactory] has no suitable constructor");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -218,8 +218,8 @@ abstract class AbstractStaxXMLReaderTests {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object[] adaptArguments(Object[] arguments) {
|
public Object[] adaptArguments(Object[] arguments) {
|
||||||
if (arguments.length == 3 && arguments[0] instanceof char[]
|
if (arguments.length == 3 && arguments[0] instanceof char[] &&
|
||||||
&& arguments[1] instanceof Integer && arguments[2] instanceof Integer) {
|
arguments[1] instanceof Integer && arguments[2] instanceof Integer) {
|
||||||
return new Object[] {new String((char[]) arguments[0], (Integer) arguments[1], (Integer) arguments[2])};
|
return new Object[] {new String((char[]) arguments[0], (Integer) arguments[1], (Integer) arguments[2])};
|
||||||
}
|
}
|
||||||
return arguments;
|
return arguments;
|
||||||
|
@ -271,10 +271,10 @@ abstract class AbstractStaxXMLReaderTests {
|
||||||
for (int i = 0; i < other.getLength(); i++) {
|
for (int i = 0; i < other.getLength(); i++) {
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
for (int j = 0; j < attributes.getLength(); j++) {
|
for (int j = 0; j < attributes.getLength(); j++) {
|
||||||
if (other.getURI(i).equals(attributes.getURI(j))
|
if (other.getURI(i).equals(attributes.getURI(j)) &&
|
||||||
&& other.getQName(i).equals(attributes.getQName(j))
|
other.getQName(i).equals(attributes.getQName(j)) &&
|
||||||
&& other.getType(i).equals(attributes.getType(j))
|
other.getType(i).equals(attributes.getType(j)) &&
|
||||||
&& other.getValue(i).equals(attributes.getValue(j))) {
|
other.getValue(i).equals(attributes.getValue(j))) {
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -737,8 +737,8 @@ class SpelDocumentationTests extends AbstractExpressionTests {
|
||||||
parser.parseExpression("Name").setValue(societyContext, "IEEE");
|
parser.parseExpression("Name").setValue(societyContext, "IEEE");
|
||||||
societyContext.setVariable("queryName", "Nikola Tesla");
|
societyContext.setVariable("queryName", "Nikola Tesla");
|
||||||
|
|
||||||
String expression = "isMember(#queryName) ? #queryName + ' is a member of the ' "
|
String expression = "isMember(#queryName) ? #queryName + ' is a member of the ' " +
|
||||||
+ "+ Name + ' Society' : #queryName + ' is not a member of the ' + Name + ' Society'";
|
"+ Name + ' Society' : #queryName + ' is not a member of the ' + Name + ' Society'";
|
||||||
|
|
||||||
String queryResultString = parser.parseExpression(expression).getValue(societyContext, String.class);
|
String queryResultString = parser.parseExpression(expression).getValue(societyContext, String.class);
|
||||||
assertThat(queryResultString).isEqualTo("Nikola Tesla is a member of the IEEE Society");
|
assertThat(queryResultString).isEqualTo("Nikola Tesla is a member of the IEEE Society");
|
||||||
|
|
|
@ -293,10 +293,10 @@ class JmsNamespaceHandlerTests {
|
||||||
assertThat(context.containsComponentDefinition("listener1")).as("Parser should have registered a component named 'listener1'").isTrue();
|
assertThat(context.containsComponentDefinition("listener1")).as("Parser should have registered a component named 'listener1'").isTrue();
|
||||||
assertThat(context.containsComponentDefinition("listener2")).as("Parser should have registered a component named 'listener2'").isTrue();
|
assertThat(context.containsComponentDefinition("listener2")).as("Parser should have registered a component named 'listener2'").isTrue();
|
||||||
assertThat(context.containsComponentDefinition("listener3")).as("Parser should have registered a component named 'listener3'").isTrue();
|
assertThat(context.containsComponentDefinition("listener3")).as("Parser should have registered a component named 'listener3'").isTrue();
|
||||||
assertThat(context.containsComponentDefinition(DefaultMessageListenerContainer.class.getName() + "#0")).as("Parser should have registered a component named '"
|
assertThat(context.containsComponentDefinition(DefaultMessageListenerContainer.class.getName() + "#0")).as("Parser should have registered a component named '" +
|
||||||
+ DefaultMessageListenerContainer.class.getName() + "#0'").isTrue();
|
DefaultMessageListenerContainer.class.getName() + "#0'").isTrue();
|
||||||
assertThat(context.containsComponentDefinition(JmsMessageEndpointManager.class.getName() + "#0")).as("Parser should have registered a component named '"
|
assertThat(context.containsComponentDefinition(JmsMessageEndpointManager.class.getName() + "#0")).as("Parser should have registered a component named '" +
|
||||||
+ JmsMessageEndpointManager.class.getName() + "#0'").isTrue();
|
JmsMessageEndpointManager.class.getName() + "#0'").isTrue();
|
||||||
assertThat(context.containsComponentDefinition("testJmsFactory")).as("Parser should have registered a component named 'testJmsFactory").isTrue();
|
assertThat(context.containsComponentDefinition("testJmsFactory")).as("Parser should have registered a component named 'testJmsFactory").isTrue();
|
||||||
assertThat(context.containsComponentDefinition("testJcaFactory")).as("Parser should have registered a component named 'testJcaFactory").isTrue();
|
assertThat(context.containsComponentDefinition("testJcaFactory")).as("Parser should have registered a component named 'testJcaFactory").isTrue();
|
||||||
assertThat(context.containsComponentDefinition("onlyJmsFactory")).as("Parser should have registered a component named 'testJcaFactory").isTrue();
|
assertThat(context.containsComponentDefinition("onlyJmsFactory")).as("Parser should have registered a component named 'testJcaFactory").isTrue();
|
||||||
|
|
|
@ -530,8 +530,7 @@ class JmsTemplateTests {
|
||||||
|
|
||||||
if (!useTransactedTemplate() && !useTransactedSession()) {
|
if (!useTransactedTemplate() && !useTransactedSession()) {
|
||||||
given(this.session.getAcknowledgeMode()).willReturn(
|
given(this.session.getAcknowledgeMode()).willReturn(
|
||||||
clientAcknowledge ? Session.CLIENT_ACKNOWLEDGE
|
clientAcknowledge ? Session.CLIENT_ACKNOWLEDGE : Session.AUTO_ACKNOWLEDGE);
|
||||||
: Session.AUTO_ACKNOWLEDGE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TextMessage textMessage = mock();
|
TextMessage textMessage = mock();
|
||||||
|
|
|
@ -70,8 +70,8 @@ public class MessagingException extends NestedRuntimeException {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return super.toString() + (this.failedMessage == null ? ""
|
return super.toString() + (this.failedMessage == null ? "" :
|
||||||
: (", failedMessage=" + this.failedMessage));
|
(", failedMessage=" + this.failedMessage));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -201,8 +201,8 @@ public class MappingJackson2MessageConverter extends AbstractMessageConverter {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do not log warning for serializer not found (note: different message wording on Jackson 2.9)
|
// Do not log warning for serializer not found (note: different message wording on Jackson 2.9)
|
||||||
boolean debugLevel = (cause instanceof JsonMappingException && cause.getMessage() != null
|
boolean debugLevel = (cause instanceof JsonMappingException && cause.getMessage() != null &&
|
||||||
&& cause.getMessage().startsWith("Cannot find"));
|
cause.getMessage().startsWith("Cannot find"));
|
||||||
|
|
||||||
if (debugLevel ? logger.isDebugEnabled() : logger.isWarnEnabled()) {
|
if (debugLevel ? logger.isDebugEnabled() : logger.isWarnEnabled()) {
|
||||||
String msg = "Failed to evaluate Jackson " + (type instanceof JavaType ? "de" : "") +
|
String msg = "Failed to evaluate Jackson " + (type instanceof JavaType ? "de" : "") +
|
||||||
|
|
|
@ -176,8 +176,8 @@ public class GenericMessagingTemplate extends AbstractDestinationResolvingMessag
|
||||||
accessor.removeHeader(this.receiveTimeoutHeader);
|
accessor.removeHeader(this.receiveTimeoutHeader);
|
||||||
accessor.setImmutable();
|
accessor.setImmutable();
|
||||||
}
|
}
|
||||||
else if (message.getHeaders().containsKey(this.sendTimeoutHeader)
|
else if (message.getHeaders().containsKey(this.sendTimeoutHeader) ||
|
||||||
|| message.getHeaders().containsKey(this.receiveTimeoutHeader)) {
|
message.getHeaders().containsKey(this.receiveTimeoutHeader)) {
|
||||||
messageToSend = MessageBuilder.fromMessage(message)
|
messageToSend = MessageBuilder.fromMessage(message)
|
||||||
.setHeader(this.sendTimeoutHeader, null)
|
.setHeader(this.sendTimeoutHeader, null)
|
||||||
.setHeader(this.receiveTimeoutHeader, null)
|
.setHeader(this.receiveTimeoutHeader, null)
|
||||||
|
|
|
@ -193,8 +193,8 @@ public class HandlerMethod extends AnnotatedMethod {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(@Nullable Object other) {
|
public boolean equals(@Nullable Object other) {
|
||||||
return (this == other || (super.equals(other) && other instanceof HandlerMethod otherMethod
|
return (this == other || (super.equals(other) && other instanceof HandlerMethod otherMethod &&
|
||||||
&& this.bean.equals(otherMethod.bean)));
|
this.bean.equals(otherMethod.bean)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -126,8 +126,8 @@ public class StompEncoder {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean shouldEscape = (command != StompCommand.CONNECT && command != StompCommand.STOMP
|
boolean shouldEscape = (command != StompCommand.CONNECT && command != StompCommand.STOMP &&
|
||||||
&& command != StompCommand.CONNECTED);
|
command != StompCommand.CONNECTED);
|
||||||
|
|
||||||
for (Entry<String, List<String>> entry : nativeHeaders.entrySet()) {
|
for (Entry<String, List<String>> entry : nativeHeaders.entrySet()) {
|
||||||
if (command.requiresContentLength() && "content-length".equals(entry.getKey())) {
|
if (command.requiresContentLength() && "content-length".equals(entry.getKey())) {
|
||||||
|
|
|
@ -538,8 +538,8 @@ public abstract class AbstractStompBrokerRelayIntegrationTests {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return super.toString() + ", subscriptionId=\"" + this.subscriptionId
|
return super.toString() + ", subscriptionId=\"" + this.subscriptionId +
|
||||||
+ "\", destination=\"" + this.destination + "\", payload=\"" + getPayloadAsText() + "\"";
|
"\", destination=\"" + this.destination + "\", payload=\"" + getPayloadAsText() + "\"";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getPayloadAsText() {
|
protected String getPayloadAsText() {
|
||||||
|
|
|
@ -96,8 +96,8 @@ class R2dbcBeanPropertyRowMapperTests {
|
||||||
|
|
||||||
assertThatExceptionOfType(TypeMismatchException.class)
|
assertThatExceptionOfType(TypeMismatchException.class)
|
||||||
.isThrownBy(() -> mapper.apply(EXTENDED_PERSON_ROW))
|
.isThrownBy(() -> mapper.apply(EXTENDED_PERSON_ROW))
|
||||||
.withMessage("Failed to convert property value of type 'java.lang.String' to required type "
|
.withMessage("Failed to convert property value of type 'java.lang.String' to required type " +
|
||||||
+ "'java.lang.String' for property 'address'; simulating type mismatch for address");
|
"'java.lang.String' for property 'address'; simulating type mismatch for address");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2024 the original author or authors.
|
* Copyright 2002-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -118,8 +118,8 @@ abstract class AbstractExpressionEvaluatingCondition implements ExecutionConditi
|
||||||
if (logger.isInfoEnabled()) {
|
if (logger.isInfoEnabled()) {
|
||||||
logger.info(reason);
|
logger.info(reason);
|
||||||
}
|
}
|
||||||
result = (enabledOnTrue ? ConditionEvaluationResult.enabled(reason)
|
result = (enabledOnTrue ? ConditionEvaluationResult.enabled(reason) :
|
||||||
: ConditionEvaluationResult.disabled(reason));
|
ConditionEvaluationResult.disabled(reason));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
String adjective = (enabledOnTrue ? "disabled" : "enabled");
|
String adjective = (enabledOnTrue ? "disabled" : "enabled");
|
||||||
|
|
|
@ -252,8 +252,8 @@ abstract class ContextLoaderUtils {
|
||||||
// annotated class.
|
// annotated class.
|
||||||
if (currentAnnotation.equals(previousAnnotation) && hasResources(currentAnnotation)) {
|
if (currentAnnotation.equals(previousAnnotation) && hasResources(currentAnnotation)) {
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug(String.format("Ignoring duplicate %s declaration on [%s], "
|
logger.debug(String.format("Ignoring duplicate %s declaration on [%s], " +
|
||||||
+ "since it is also declared on [%s].", currentAnnotation,
|
"since it is also declared on [%s].", currentAnnotation,
|
||||||
previousDeclaringClass.getName(), descriptor.getRootDeclaringClass().getName()));
|
previousDeclaringClass.getName(), descriptor.getRootDeclaringClass().getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,13 +36,15 @@ import org.springframework.util.ClassUtils;
|
||||||
*/
|
*/
|
||||||
public class DelegatingSmartContextLoader extends AbstractDelegatingSmartContextLoader {
|
public class DelegatingSmartContextLoader extends AbstractDelegatingSmartContextLoader {
|
||||||
|
|
||||||
private static final String GROOVY_XML_CONTEXT_LOADER_CLASS_NAME = "org.springframework.test.context.support.GenericGroovyXmlContextLoader";
|
private static final String GROOVY_XML_CONTEXT_LOADER_CLASS_NAME =
|
||||||
|
"org.springframework.test.context.support.GenericGroovyXmlContextLoader";
|
||||||
|
|
||||||
private static final boolean groovyPresent = ClassUtils.isPresent("groovy.lang.Closure",
|
private static final boolean groovyPresent = ClassUtils.isPresent("groovy.lang.Closure",
|
||||||
DelegatingSmartContextLoader.class.getClassLoader())
|
DelegatingSmartContextLoader.class.getClassLoader()) &&
|
||||||
&& ClassUtils.isPresent(GROOVY_XML_CONTEXT_LOADER_CLASS_NAME,
|
ClassUtils.isPresent(GROOVY_XML_CONTEXT_LOADER_CLASS_NAME,
|
||||||
DelegatingSmartContextLoader.class.getClassLoader());
|
DelegatingSmartContextLoader.class.getClassLoader());
|
||||||
|
|
||||||
|
|
||||||
private final SmartContextLoader xmlLoader;
|
private final SmartContextLoader xmlLoader;
|
||||||
private final SmartContextLoader annotationConfigLoader;
|
private final SmartContextLoader annotationConfigLoader;
|
||||||
|
|
||||||
|
@ -55,8 +57,8 @@ public class DelegatingSmartContextLoader extends AbstractDelegatingSmartContext
|
||||||
this.xmlLoader = (SmartContextLoader) BeanUtils.instantiateClass(loaderClass);
|
this.xmlLoader = (SmartContextLoader) BeanUtils.instantiateClass(loaderClass);
|
||||||
}
|
}
|
||||||
catch (Throwable ex) {
|
catch (Throwable ex) {
|
||||||
throw new IllegalStateException("Failed to enable support for Groovy scripts; "
|
throw new IllegalStateException("Failed to enable support for Groovy scripts; " +
|
||||||
+ "could not load class: " + GROOVY_XML_CONTEXT_LOADER_CLASS_NAME, ex);
|
"could not load class: " + GROOVY_XML_CONTEXT_LOADER_CLASS_NAME, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2024 the original author or authors.
|
* Copyright 2002-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -92,9 +92,9 @@ class TestPropertySourceAttributes {
|
||||||
*/
|
*/
|
||||||
void mergeWith(TestPropertySourceAttributes attributes) {
|
void mergeWith(TestPropertySourceAttributes attributes) {
|
||||||
Assert.state(attributes.declaringClass == this.declaringClass,
|
Assert.state(attributes.declaringClass == this.declaringClass,
|
||||||
() -> "Detected @TestPropertySource declarations within an aggregate index "
|
() -> "Detected @TestPropertySource declarations within an aggregate index " +
|
||||||
+ "with different sources: " + this.declaringClass.getName() + " and "
|
"with different sources: " + this.declaringClass.getName() + " and " +
|
||||||
+ attributes.declaringClass.getName());
|
attributes.declaringClass.getName());
|
||||||
logger.trace(LogMessage.format("Retrieved %s for declaring class [%s].",
|
logger.trace(LogMessage.format("Retrieved %s for declaring class [%s].",
|
||||||
attributes, this.declaringClass.getName()));
|
attributes, this.declaringClass.getName()));
|
||||||
assertSameBooleanAttribute(this.inheritLocations, attributes.inheritLocations,
|
assertSameBooleanAttribute(this.inheritLocations, attributes.inheritLocations,
|
||||||
|
|
|
@ -39,8 +39,8 @@ public class WebDelegatingSmartContextLoader extends AbstractDelegatingSmartCont
|
||||||
private static final String GROOVY_XML_WEB_CONTEXT_LOADER_CLASS_NAME = "org.springframework.test.context.web.GenericGroovyXmlWebContextLoader";
|
private static final String GROOVY_XML_WEB_CONTEXT_LOADER_CLASS_NAME = "org.springframework.test.context.web.GenericGroovyXmlWebContextLoader";
|
||||||
|
|
||||||
private static final boolean groovyPresent = ClassUtils.isPresent("groovy.lang.Closure",
|
private static final boolean groovyPresent = ClassUtils.isPresent("groovy.lang.Closure",
|
||||||
WebDelegatingSmartContextLoader.class.getClassLoader())
|
WebDelegatingSmartContextLoader.class.getClassLoader()) &&
|
||||||
&& ClassUtils.isPresent(GROOVY_XML_WEB_CONTEXT_LOADER_CLASS_NAME,
|
ClassUtils.isPresent(GROOVY_XML_WEB_CONTEXT_LOADER_CLASS_NAME,
|
||||||
WebDelegatingSmartContextLoader.class.getClassLoader());
|
WebDelegatingSmartContextLoader.class.getClassLoader());
|
||||||
|
|
||||||
private final SmartContextLoader xmlLoader;
|
private final SmartContextLoader xmlLoader;
|
||||||
|
@ -55,8 +55,8 @@ public class WebDelegatingSmartContextLoader extends AbstractDelegatingSmartCont
|
||||||
this.xmlLoader = (SmartContextLoader) BeanUtils.instantiateClass(loaderClass);
|
this.xmlLoader = (SmartContextLoader) BeanUtils.instantiateClass(loaderClass);
|
||||||
}
|
}
|
||||||
catch (Throwable ex) {
|
catch (Throwable ex) {
|
||||||
throw new IllegalStateException("Failed to enable support for Groovy scripts; "
|
throw new IllegalStateException("Failed to enable support for Groovy scripts; " +
|
||||||
+ "could not load class: " + GROOVY_XML_WEB_CONTEXT_LOADER_CLASS_NAME, ex);
|
"could not load class: " + GROOVY_XML_WEB_CONTEXT_LOADER_CLASS_NAME, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2024 the original author or authors.
|
* Copyright 2002-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -40,8 +40,8 @@ public abstract class JsonAssert {
|
||||||
* @see JSONCompareMode#LENIENT
|
* @see JSONCompareMode#LENIENT
|
||||||
*/
|
*/
|
||||||
public static JsonComparator comparator(JsonCompareMode compareMode) {
|
public static JsonComparator comparator(JsonCompareMode compareMode) {
|
||||||
JSONCompareMode jsonAssertCompareMode = (compareMode != JsonCompareMode.LENIENT
|
JSONCompareMode jsonAssertCompareMode = (compareMode != JsonCompareMode.LENIENT ?
|
||||||
? JSONCompareMode.STRICT : JSONCompareMode.LENIENT);
|
JSONCompareMode.STRICT : JSONCompareMode.LENIENT);
|
||||||
return comparator(jsonAssertCompareMode);
|
return comparator(jsonAssertCompareMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,18 +80,14 @@ public abstract class JsonAssert {
|
||||||
@Override
|
@Override
|
||||||
public JsonComparison compare(@Nullable String expectedJson, @Nullable String actualJson) {
|
public JsonComparison compare(@Nullable String expectedJson, @Nullable String actualJson) {
|
||||||
if (actualJson == null) {
|
if (actualJson == null) {
|
||||||
return (expectedJson != null)
|
return (expectedJson != null) ? JsonComparison.mismatch("Expected null JSON") : JsonComparison.match();
|
||||||
? JsonComparison.mismatch("Expected null JSON")
|
|
||||||
: JsonComparison.match();
|
|
||||||
}
|
}
|
||||||
if (expectedJson == null) {
|
if (expectedJson == null) {
|
||||||
return JsonComparison.mismatch("Expected non-null JSON");
|
return JsonComparison.mismatch("Expected non-null JSON");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
JSONCompareResult result = JSONCompare.compareJSON(expectedJson, actualJson, this.jsonAssertComparator);
|
JSONCompareResult result = JSONCompare.compareJSON(expectedJson, actualJson, this.jsonAssertComparator);
|
||||||
return (!result.passed())
|
return (!result.passed()) ? JsonComparison.mismatch(result.getMessage()) : JsonComparison.match();
|
||||||
? JsonComparison.mismatch(result.getMessage())
|
|
||||||
: JsonComparison.match();
|
|
||||||
}
|
}
|
||||||
catch (JSONException ex) {
|
catch (JSONException ex) {
|
||||||
throw new IllegalStateException(ex);
|
throw new IllegalStateException(ex);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2024 the original author or authors.
|
* Copyright 2002-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -47,35 +47,45 @@ class ProfileValueUtilsTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertClassIsEnabled(Class<?> testClass) {
|
private void assertClassIsEnabled(Class<?> testClass) {
|
||||||
assertThat(ProfileValueUtils.isTestEnabledInThisEnvironment(testClass)).as("Test class [" + testClass + "] should be enabled.").isTrue();
|
assertThat(ProfileValueUtils.isTestEnabledInThisEnvironment(testClass))
|
||||||
|
.as("Test class [" + testClass + "] should be enabled.")
|
||||||
|
.isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertClassIsDisabled(Class<?> testClass) {
|
private void assertClassIsDisabled(Class<?> testClass) {
|
||||||
assertThat(ProfileValueUtils.isTestEnabledInThisEnvironment(testClass)).as("Test class [" + testClass + "] should be disabled.").isFalse();
|
assertThat(ProfileValueUtils.isTestEnabledInThisEnvironment(testClass))
|
||||||
|
.as("Test class [" + testClass + "] should be disabled.")
|
||||||
|
.isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertMethodIsEnabled(String methodName, Class<?> testClass) throws Exception {
|
private void assertMethodIsEnabled(String methodName, Class<?> testClass) throws Exception {
|
||||||
Method testMethod = testClass.getMethod(methodName);
|
Method testMethod = testClass.getMethod(methodName);
|
||||||
assertThat(ProfileValueUtils.isTestEnabledInThisEnvironment(testMethod, testClass)).as("Test method [" + testMethod + "] should be enabled.").isTrue();
|
assertThat(ProfileValueUtils.isTestEnabledInThisEnvironment(testMethod, testClass))
|
||||||
|
.as("Test method [" + testMethod + "] should be enabled.")
|
||||||
|
.isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertMethodIsDisabled(String methodName, Class<?> testClass) throws Exception {
|
private void assertMethodIsDisabled(String methodName, Class<?> testClass) throws Exception {
|
||||||
Method testMethod = testClass.getMethod(methodName);
|
Method testMethod = testClass.getMethod(methodName);
|
||||||
assertThat(ProfileValueUtils.isTestEnabledInThisEnvironment(testMethod, testClass)).as("Test method [" + testMethod + "] should be disabled.").isFalse();
|
assertThat(ProfileValueUtils.isTestEnabledInThisEnvironment(testMethod, testClass))
|
||||||
|
.as("Test method [" + testMethod + "] should be disabled.")
|
||||||
|
.isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertMethodIsEnabled(ProfileValueSource profileValueSource, String methodName, Class<?> testClass)
|
private void assertMethodIsEnabled(ProfileValueSource profileValueSource, String methodName, Class<?> testClass)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
Method testMethod = testClass.getMethod(methodName);
|
Method testMethod = testClass.getMethod(methodName);
|
||||||
assertThat(ProfileValueUtils.isTestEnabledInThisEnvironment(profileValueSource, testMethod, testClass)).as("Test method [" + testMethod + "] should be enabled for ProfileValueSource [" + profileValueSource
|
assertThat(ProfileValueUtils.isTestEnabledInThisEnvironment(profileValueSource, testMethod, testClass))
|
||||||
+ "].").isTrue();
|
.as("Test method [" + testMethod + "] should be enabled for ProfileValueSource [" + profileValueSource + "].")
|
||||||
|
.isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertMethodIsDisabled(ProfileValueSource profileValueSource, String methodName, Class<?> testClass)
|
private void assertMethodIsDisabled(ProfileValueSource profileValueSource, String methodName, Class<?> testClass)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
Method testMethod = testClass.getMethod(methodName);
|
Method testMethod = testClass.getMethod(methodName);
|
||||||
assertThat(ProfileValueUtils.isTestEnabledInThisEnvironment(profileValueSource, testMethod, testClass)).as("Test method [" + testMethod + "] should be disabled for ProfileValueSource [" + profileValueSource
|
assertThat(ProfileValueUtils.isTestEnabledInThisEnvironment(profileValueSource, testMethod, testClass))
|
||||||
+ "].").isFalse();
|
.as("Test method [" + testMethod + "] should be disabled for ProfileValueSource [" + profileValueSource + "].")
|
||||||
|
.isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
|
|
@ -106,8 +106,8 @@ class FailingBeforeAndAfterMethodsSpringExtensionTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getExpectedFailedCount(Class<?> testClass) {
|
private int getExpectedFailedCount(Class<?> testClass) {
|
||||||
if (testClass == AlwaysFailingBeforeTestClassTestCase.class
|
if (testClass == AlwaysFailingBeforeTestClassTestCase.class ||
|
||||||
|| testClass == AlwaysFailingAfterTestClassTestCase.class) {
|
testClass == AlwaysFailingAfterTestClassTestCase.class) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -98,8 +98,7 @@ public class BeforeAndAfterTransactionAnnotationTests extends AbstractTransactio
|
||||||
@Before
|
@Before
|
||||||
public void before() {
|
public void before() {
|
||||||
assertShouldBeInTransaction();
|
assertShouldBeInTransaction();
|
||||||
long expected = (this.inTransaction ? 1
|
long expected = (this.inTransaction ? 1 : 0);
|
||||||
: 0);
|
|
||||||
assertThat(countRowsInPersonTable(jdbcTemplate)).as("Verifying the number of rows in the person table before a test method.").isEqualTo(expected);
|
assertThat(countRowsInPersonTable(jdbcTemplate)).as("Verifying the number of rows in the person table before a test method.").isEqualTo(expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,8 +42,9 @@ public class ClassPathResourceSpringJUnit4ClassRunnerAppCtxTests extends SpringJ
|
||||||
* @see SpringJUnit4ClassRunnerAppCtxTests#DEFAULT_CONTEXT_RESOURCE_PATH
|
* @see SpringJUnit4ClassRunnerAppCtxTests#DEFAULT_CONTEXT_RESOURCE_PATH
|
||||||
* @see ResourceUtils#CLASSPATH_URL_PREFIX
|
* @see ResourceUtils#CLASSPATH_URL_PREFIX
|
||||||
*/
|
*/
|
||||||
public static final String CLASSPATH_CONTEXT_RESOURCE_PATH = ResourceUtils.CLASSPATH_URL_PREFIX
|
public static final String CLASSPATH_CONTEXT_RESOURCE_PATH = ResourceUtils.CLASSPATH_URL_PREFIX +
|
||||||
+ SpringJUnit4ClassRunnerAppCtxTests.DEFAULT_CONTEXT_RESOURCE_PATH;
|
SpringJUnit4ClassRunnerAppCtxTests.DEFAULT_CONTEXT_RESOURCE_PATH;
|
||||||
|
|
||||||
/* all tests are in the parent class. */
|
/* all tests are in the parent class. */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,10 +37,11 @@ import org.springframework.util.ResourceUtils;
|
||||||
MultipleResourcesSpringJUnit4ClassRunnerAppCtxTests.ABSOLUTE_RESOURCE_PATH })
|
MultipleResourcesSpringJUnit4ClassRunnerAppCtxTests.ABSOLUTE_RESOURCE_PATH })
|
||||||
public class MultipleResourcesSpringJUnit4ClassRunnerAppCtxTests extends SpringJUnit4ClassRunnerAppCtxTests {
|
public class MultipleResourcesSpringJUnit4ClassRunnerAppCtxTests extends SpringJUnit4ClassRunnerAppCtxTests {
|
||||||
|
|
||||||
public static final String CLASSPATH_RESOURCE_PATH = ResourceUtils.CLASSPATH_URL_PREFIX
|
public static final String CLASSPATH_RESOURCE_PATH = ResourceUtils.CLASSPATH_URL_PREFIX +
|
||||||
+ "/org/springframework/test/context/junit4/MultipleResourcesSpringJUnit4ClassRunnerAppCtxTests-context1.xml";
|
"/org/springframework/test/context/junit4/MultipleResourcesSpringJUnit4ClassRunnerAppCtxTests-context1.xml";
|
||||||
public static final String LOCAL_RESOURCE_PATH = "MultipleResourcesSpringJUnit4ClassRunnerAppCtxTests-context2.xml";
|
public static final String LOCAL_RESOURCE_PATH = "MultipleResourcesSpringJUnit4ClassRunnerAppCtxTests-context2.xml";
|
||||||
public static final String ABSOLUTE_RESOURCE_PATH = "/org/springframework/test/context/junit4/MultipleResourcesSpringJUnit4ClassRunnerAppCtxTests-context3.xml";
|
public static final String ABSOLUTE_RESOURCE_PATH = "/org/springframework/test/context/junit4/MultipleResourcesSpringJUnit4ClassRunnerAppCtxTests-context3.xml";
|
||||||
|
|
||||||
/* all tests are in the parent class. */
|
/* all tests are in the parent class. */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,8 +84,8 @@ public @interface ConfigClassesAndProfileResolverWithCustomDefaultsMetaConfig {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] resolve(Class<?> testClass) {
|
public String[] resolve(Class<?> testClass) {
|
||||||
return testClass.getSimpleName().equals("ConfigClassesAndProfileResolverWithCustomDefaultsMetaConfigTests") ? new String[] { "resolver" }
|
return testClass.getSimpleName().equals("ConfigClassesAndProfileResolverWithCustomDefaultsMetaConfigTests") ?
|
||||||
: new String[] {};
|
new String[] { "resolver" } : new String[] {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -372,8 +372,8 @@ class ActiveProfilesUtilsTests extends AbstractContextConfigurationUtilsTests {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] resolve(Class<?> testClass) {
|
public String[] resolve(Class<?> testClass) {
|
||||||
return testClass.isAnnotation() ? new String[] { "@" + testClass.getSimpleName() }
|
return testClass.isAnnotation() ? new String[] { "@" + testClass.getSimpleName() } :
|
||||||
: new String[] { testClass.getSimpleName() };
|
new String[] { testClass.getSimpleName() };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,8 +84,7 @@ public abstract class AbstractBasicWacTests implements ServletContextAware {
|
||||||
assertThat(webRequest).as("ServletWebRequest should have been autowired from the WAC.").isNotNull();
|
assertThat(webRequest).as("ServletWebRequest should have been autowired from the WAC.").isNotNull();
|
||||||
|
|
||||||
Object rootWac = mockServletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
|
Object rootWac = mockServletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
|
||||||
assertThat(rootWac).as("Root WAC must be stored in the ServletContext as: "
|
assertThat(rootWac).as("Root WAC must be stored in the ServletContext as: " + WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE).isNotNull();
|
||||||
+ WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE).isNotNull();
|
|
||||||
assertThat(rootWac).as("test WAC and Root WAC in ServletContext must be the same object.").isSameAs(wac);
|
assertThat(rootWac).as("test WAC and Root WAC in ServletContext must be the same object.").isSameAs(wac);
|
||||||
assertThat(wac.getServletContext()).as("ServletContext instances must be the same object.").isSameAs(mockServletContext);
|
assertThat(wac.getServletContext()).as("ServletContext instances must be the same object.").isSameAs(mockServletContext);
|
||||||
assertThat(request.getServletContext()).as("ServletContext in the WAC and in the mock request").isSameAs(mockServletContext);
|
assertThat(request.getServletContext()).as("ServletContext in the WAC and in the mock request").isSameAs(mockServletContext);
|
||||||
|
|
|
@ -99,8 +99,7 @@ public class JUnit4SpringContextWebTests extends AbstractJUnit4SpringContextTest
|
||||||
assertThat(webRequest).as("ServletWebRequest should have been autowired from the WAC.").isNotNull();
|
assertThat(webRequest).as("ServletWebRequest should have been autowired from the WAC.").isNotNull();
|
||||||
|
|
||||||
Object rootWac = mockServletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
|
Object rootWac = mockServletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
|
||||||
assertThat(rootWac).as("Root WAC must be stored in the ServletContext as: "
|
assertThat(rootWac).as("Root WAC must be stored in the ServletContext as: " + WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE).isNotNull();
|
||||||
+ WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE).isNotNull();
|
|
||||||
assertThat(rootWac).as("test WAC and Root WAC in ServletContext must be the same object.").isSameAs(wac);
|
assertThat(rootWac).as("test WAC and Root WAC in ServletContext must be the same object.").isSameAs(wac);
|
||||||
assertThat(wac.getServletContext()).as("ServletContext instances must be the same object.").isSameAs(mockServletContext);
|
assertThat(wac.getServletContext()).as("ServletContext instances must be the same object.").isSameAs(mockServletContext);
|
||||||
assertThat(request.getServletContext()).as("ServletContext in the WAC and in the mock request").isSameAs(mockServletContext);
|
assertThat(request.getServletContext()).as("ServletContext in the WAC and in the mock request").isSameAs(mockServletContext);
|
||||||
|
|
|
@ -63,8 +63,7 @@ class MetaAnnotationConfigWacTests {
|
||||||
assertThat(mockServletContext).as("ServletContext should have been autowired from the WAC.").isNotNull();
|
assertThat(mockServletContext).as("ServletContext should have been autowired from the WAC.").isNotNull();
|
||||||
|
|
||||||
Object rootWac = mockServletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
|
Object rootWac = mockServletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
|
||||||
assertThat(rootWac).as("Root WAC must be stored in the ServletContext as: "
|
assertThat(rootWac).as("Root WAC must be stored in the ServletContext as: " + WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE).isNotNull();
|
||||||
+ WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE).isNotNull();
|
|
||||||
assertThat(rootWac).as("test WAC and Root WAC in ServletContext must be the same object.").isSameAs(wac);
|
assertThat(rootWac).as("test WAC and Root WAC in ServletContext must be the same object.").isSameAs(wac);
|
||||||
assertThat(wac.getServletContext()).as("ServletContext instances must be the same object.").isSameAs(mockServletContext);
|
assertThat(wac.getServletContext()).as("ServletContext instances must be the same object.").isSameAs(mockServletContext);
|
||||||
|
|
||||||
|
|
|
@ -81,8 +81,8 @@ public class Person {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Person [name=" + this.name + ", someDouble=" + this.someDouble
|
return "Person [name=" + this.name + ", someDouble=" + this.someDouble +
|
||||||
+ ", someBoolean=" + this.someBoolean + "]";
|
", someBoolean=" + this.someBoolean + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2022 the original author or authors.
|
* Copyright 2002-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -48,13 +48,14 @@ import static org.hamcrest.Matchers.startsWith;
|
||||||
*/
|
*/
|
||||||
class XmlContentTests {
|
class XmlContentTests {
|
||||||
|
|
||||||
private static final String persons_XML =
|
private static final String persons_XML = """
|
||||||
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
+ "<persons>"
|
<persons>
|
||||||
+ "<person><name>Jane</name></person>"
|
<person><name>Jane</name></person>
|
||||||
+ "<person><name>Jason</name></person>"
|
<person><name>Jason</name></person>
|
||||||
+ "<person><name>John</name></person>"
|
<person><name>John</name></person>
|
||||||
+ "</persons>";
|
</persons>
|
||||||
|
""";
|
||||||
|
|
||||||
|
|
||||||
private final WebTestClient client = WebTestClient.bindToController(new PersonController()).build();
|
private final WebTestClient client = WebTestClient.bindToController(new PersonController()).build();
|
||||||
|
|
|
@ -706,8 +706,7 @@ public class HtmlUnitRequestBuilderTests {
|
||||||
webRequest.setAdditionalHeader("Cookie", "JSESSIONID=" + sessionId + "NEW");
|
webRequest.setAdditionalHeader("Cookie", "JSESSIONID=" + sessionId + "NEW");
|
||||||
actualRequest = requestBuilder.buildRequest(servletContext);
|
actualRequest = requestBuilder.buildRequest(servletContext);
|
||||||
assertThat(actualRequest.getSession()).isNotEqualTo(session);
|
assertThat(actualRequest.getSession()).isNotEqualTo(session);
|
||||||
assertSingleSessionCookie("JSESSIONID=" + actualRequest.getSession().getId()
|
assertSingleSessionCookie("JSESSIONID=" + actualRequest.getSession().getId() + "; Path=/test; Domain=example.com");
|
||||||
+ "; Path=/test; Domain=example.com");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -763,8 +762,8 @@ public class HtmlUnitRequestBuilderTests {
|
||||||
sessionToRemove.invalidate();
|
sessionToRemove.invalidate();
|
||||||
|
|
||||||
assertThat(sessions.containsKey(sessionToRemove.getId())).isFalse();
|
assertThat(sessions.containsKey(sessionToRemove.getId())).isFalse();
|
||||||
assertSingleSessionCookie("JSESSIONID=" + sessionToRemove.getId()
|
assertSingleSessionCookie("JSESSIONID=" + sessionToRemove.getId() +
|
||||||
+ "; Expires=Thu, 01-Jan-1970 00:00:01 GMT; Path=/test; Domain=example.com");
|
"; Expires=Thu, 01-Jan-1970 00:00:01 GMT; Path=/test; Domain=example.com");
|
||||||
|
|
||||||
webRequest.removeAdditionalHeader("Cookie");
|
webRequest.removeAdditionalHeader("Cookie");
|
||||||
requestBuilder = new HtmlUnitRequestBuilder(sessions, webClient, webRequest);
|
requestBuilder = new HtmlUnitRequestBuilder(sessions, webClient, webRequest);
|
||||||
|
|
|
@ -418,8 +418,7 @@ final class MultipartParser extends BaseSubscriber<DataBuffer> {
|
||||||
private boolean isLastBoundary(DataBuffer buf) {
|
private boolean isLastBoundary(DataBuffer buf) {
|
||||||
return (this.buffers.isEmpty() &&
|
return (this.buffers.isEmpty() &&
|
||||||
buf.readableByteCount() >= 2 &&
|
buf.readableByteCount() >= 2 &&
|
||||||
buf.getByte(0) == HYPHEN && buf.getByte(1) == HYPHEN)
|
buf.getByte(0) == HYPHEN && buf.getByte(1) == HYPHEN) ||
|
||||||
||
|
|
||||||
(this.buffers.size() == 1 &&
|
(this.buffers.size() == 1 &&
|
||||||
this.buffers.get(0).readableByteCount() == 1 &&
|
this.buffers.get(0).readableByteCount() == 1 &&
|
||||||
this.buffers.get(0).getByte(0) == HYPHEN &&
|
this.buffers.get(0).getByte(0) == HYPHEN &&
|
||||||
|
|
|
@ -104,7 +104,7 @@ abstract class MultipartUtils {
|
||||||
|
|
||||||
public static boolean isFormField(HttpHeaders headers) {
|
public static boolean isFormField(HttpHeaders headers) {
|
||||||
MediaType contentType = headers.getContentType();
|
MediaType contentType = headers.getContentType();
|
||||||
return (contentType == null || MediaType.TEXT_PLAIN.equalsTypeAndSubtype(contentType))
|
return (contentType == null || MediaType.TEXT_PLAIN.equalsTypeAndSubtype(contentType)) &&
|
||||||
&& headers.getContentDisposition().getFilename() == null;
|
headers.getContentDisposition().getFilename() == null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -212,8 +212,8 @@ public class PartEventHttpMessageReader extends LoggingCodecSupport implements H
|
||||||
this.maxPartSize + " bytes"));
|
this.maxPartSize + " bytes"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return isFilePart ? Mono.just(DefaultPartEvents.file(headers, buffer, body.isLast()))
|
return (isFilePart ? Mono.just(DefaultPartEvents.file(headers, buffer, body.isLast())) :
|
||||||
: Mono.just(DefaultPartEvents.create(headers, body.buffer(), body.isLast()));
|
Mono.just(DefaultPartEvents.create(headers, body.buffer(), body.isLast())));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.switchIfEmpty(Mono.fromCallable(() ->
|
.switchIfEmpty(Mono.fromCallable(() ->
|
||||||
|
|
|
@ -163,9 +163,8 @@ final class PartGenerator extends BaseSubscriber<MultipartParser.Token> {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
logger.warn("Could not switch from " + oldState +
|
logger.warn("Could not switch from " + oldState + " to " + newState +
|
||||||
" to " + newState + "; current state:"
|
"; current state:" + this.state.get());
|
||||||
+ this.state.get());
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -733,8 +733,8 @@ public class CorsConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean allowAnyHeader = this.allowedHeaders.contains(ALL);
|
boolean allowAnyHeader = this.allowedHeaders.contains(ALL);
|
||||||
int maxResultSize = allowAnyHeader ? requestHeaders.size()
|
int maxResultSize = (allowAnyHeader ? requestHeaders.size() :
|
||||||
: Math.min(requestHeaders.size(), this.allowedHeaders.size());
|
Math.min(requestHeaders.size(), this.allowedHeaders.size()));
|
||||||
List<String> result = new ArrayList<>(maxResultSize);
|
List<String> result = new ArrayList<>(maxResultSize);
|
||||||
for (String requestHeader : requestHeaders) {
|
for (String requestHeader : requestHeaders) {
|
||||||
if (StringUtils.hasText(requestHeader)) {
|
if (StringUtils.hasText(requestHeader)) {
|
||||||
|
|
|
@ -50,9 +50,9 @@ public abstract class CorsUtils {
|
||||||
*/
|
*/
|
||||||
public static boolean isPreFlightRequest(ServerHttpRequest request) {
|
public static boolean isPreFlightRequest(ServerHttpRequest request) {
|
||||||
HttpHeaders headers = request.getHeaders();
|
HttpHeaders headers = request.getHeaders();
|
||||||
return (request.getMethod() == HttpMethod.OPTIONS
|
return (request.getMethod() == HttpMethod.OPTIONS &&
|
||||||
&& headers.containsHeader(HttpHeaders.ORIGIN)
|
headers.containsHeader(HttpHeaders.ORIGIN) &&
|
||||||
&& headers.containsHeader(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD));
|
headers.containsHeader(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -316,9 +316,9 @@ public class InvocableHandlerMethod extends HandlerMethod {
|
||||||
Object arg = args[index];
|
Object arg = args[index];
|
||||||
if (!(parameter.isOptional() && arg == null)) {
|
if (!(parameter.isOptional() && arg == null)) {
|
||||||
KType type = parameter.getType();
|
KType type = parameter.getType();
|
||||||
if (!(type.isMarkedNullable() && arg == null)
|
if (!(type.isMarkedNullable() && arg == null) &&
|
||||||
&& type.getClassifier() instanceof KClass<?> kClass
|
type.getClassifier() instanceof KClass<?> kClass &&
|
||||||
&& KotlinDetector.isInlineClass(JvmClassMappingKt.getJavaClass(kClass))) {
|
KotlinDetector.isInlineClass(JvmClassMappingKt.getJavaClass(kClass))) {
|
||||||
arg = box(kClass, arg);
|
arg = box(kClass, arg);
|
||||||
}
|
}
|
||||||
argMap.put(parameter, arg);
|
argMap.put(parameter, arg);
|
||||||
|
@ -337,9 +337,9 @@ public class InvocableHandlerMethod extends HandlerMethod {
|
||||||
private static Object box(KClass<?> kClass, @Nullable Object arg) {
|
private static Object box(KClass<?> kClass, @Nullable Object arg) {
|
||||||
KFunction<?> constructor = Objects.requireNonNull(KClasses.getPrimaryConstructor(kClass));
|
KFunction<?> constructor = Objects.requireNonNull(KClasses.getPrimaryConstructor(kClass));
|
||||||
KType type = constructor.getParameters().get(0).getType();
|
KType type = constructor.getParameters().get(0).getType();
|
||||||
if (!(type.isMarkedNullable() && arg == null)
|
if (!(type.isMarkedNullable() && arg == null) &&
|
||||||
&& type.getClassifier() instanceof KClass<?> parameterClass
|
type.getClassifier() instanceof KClass<?> parameterClass &&
|
||||||
&& KotlinDetector.isInlineClass(JvmClassMappingKt.getJavaClass(parameterClass))) {
|
KotlinDetector.isInlineClass(JvmClassMappingKt.getJavaClass(parameterClass))) {
|
||||||
arg = box(parameterClass, arg);
|
arg = box(parameterClass, arg);
|
||||||
}
|
}
|
||||||
if (!KCallablesJvm.isAccessible(constructor)) {
|
if (!KCallablesJvm.isAccessible(constructor)) {
|
||||||
|
|
|
@ -88,8 +88,8 @@ class ErrorHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||||
// but an application can apply CompactPathRule via RewriteHandler:
|
// but an application can apply CompactPathRule via RewriteHandler:
|
||||||
// https://www.eclipse.org/jetty/documentation/jetty-11/programming_guide.php
|
// https://www.eclipse.org/jetty/documentation/jetty-11/programming_guide.php
|
||||||
|
|
||||||
HttpStatus expectedStatus = (httpServer instanceof JettyHttpServer || httpServer instanceof JettyCoreHttpServer
|
HttpStatus expectedStatus = (httpServer instanceof JettyHttpServer || httpServer instanceof JettyCoreHttpServer ?
|
||||||
? HttpStatus.BAD_REQUEST : HttpStatus.OK);
|
HttpStatus.BAD_REQUEST : HttpStatus.OK);
|
||||||
|
|
||||||
assertThat(response.getStatusCode()).isEqualTo(expectedStatus);
|
assertThat(response.getStatusCode()).isEqualTo(expectedStatus);
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,8 +55,8 @@ class ZeroCopyIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||||
|
|
||||||
@ParameterizedHttpServerTest
|
@ParameterizedHttpServerTest
|
||||||
void zeroCopy(HttpServer httpServer) throws Exception {
|
void zeroCopy(HttpServer httpServer) throws Exception {
|
||||||
assumeTrue(httpServer instanceof ReactorHttpServer || httpServer instanceof UndertowHttpServer
|
assumeTrue(httpServer instanceof ReactorHttpServer || httpServer instanceof UndertowHttpServer ||
|
||||||
|| httpServer instanceof JettyCoreHttpServer, "Zero-copy does not support Servlet");
|
httpServer instanceof JettyCoreHttpServer, "Zero-copy does not support Servlet");
|
||||||
|
|
||||||
startServer(httpServer);
|
startServer(httpServer);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2024 the original author or authors.
|
* Copyright 2002-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -258,23 +258,25 @@ class RequestLoggingFilterTests {
|
||||||
filter.doFilter(request, response, filterChain);
|
filter.doFilter(request, response, filterChain);
|
||||||
|
|
||||||
assertThat(filter.beforeRequestMessage)
|
assertThat(filter.beforeRequestMessage)
|
||||||
.isEqualTo("Before request ["
|
.isEqualTo("""
|
||||||
+ "POST /hotels?booking=42"
|
Before request [\
|
||||||
+ ", client=4.2.2.2"
|
POST /hotels?booking=42, \
|
||||||
+ ", session=42"
|
client=4.2.2.2, \
|
||||||
+ ", user=Arthur"
|
session=42, \
|
||||||
+ ", headers=[Content-Type:\"application/json;charset=ISO-8859-1\", Content-Length:\"22\"]"
|
user=Arthur, \
|
||||||
+ "]");
|
headers=[Content-Type:"application/json;charset=ISO-8859-1", Content-Length:"22"]\
|
||||||
|
]""");
|
||||||
|
|
||||||
assertThat(filter.afterRequestMessage)
|
assertThat(filter.afterRequestMessage)
|
||||||
.isEqualTo("After request ["
|
.isEqualTo("""
|
||||||
+ "POST /hotels?booking=42"
|
After request [\
|
||||||
+ ", client=4.2.2.2"
|
POST /hotels?booking=42, \
|
||||||
+ ", session=42"
|
client=4.2.2.2, \
|
||||||
+ ", user=Arthur"
|
session=42, \
|
||||||
+ ", headers=[Content-Type:\"application/json;charset=ISO-8859-1\", Content-Length:\"22\"]"
|
user=Arthur, \
|
||||||
+ ", payload={\"msg\": \"Hello World\"}"
|
headers=[Content-Type:"application/json;charset=ISO-8859-1", Content-Length:"22"], \
|
||||||
+ "]");
|
payload={"msg": "Hello World"}\
|
||||||
|
]""");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyFilter() throws Exception {
|
private void applyFilter() throws Exception {
|
||||||
|
|
|
@ -104,8 +104,7 @@ public class RequestedContentTypeResolverBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isMediaTypeAll(List<MediaType> mediaTypes) {
|
private boolean isMediaTypeAll(List<MediaType> mediaTypes) {
|
||||||
return mediaTypes.size() == 1
|
return mediaTypes.size() == 1 && mediaTypes.get(0).removeQualityValue().equals(MediaType.ALL);
|
||||||
&& mediaTypes.get(0).removeQualityValue().equals(MediaType.ALL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -354,9 +354,9 @@ public class InvocableHandlerMethod extends HandlerMethod {
|
||||||
Object arg = args[index];
|
Object arg = args[index];
|
||||||
if (!(parameter.isOptional() && arg == null)) {
|
if (!(parameter.isOptional() && arg == null)) {
|
||||||
KType type = parameter.getType();
|
KType type = parameter.getType();
|
||||||
if (!(type.isMarkedNullable() && arg == null)
|
if (!(type.isMarkedNullable() && arg == null) &&
|
||||||
&& type.getClassifier() instanceof KClass<?> kClass
|
type.getClassifier() instanceof KClass<?> kClass &&
|
||||||
&& KotlinDetector.isInlineClass(JvmClassMappingKt.getJavaClass(kClass))) {
|
KotlinDetector.isInlineClass(JvmClassMappingKt.getJavaClass(kClass))) {
|
||||||
arg = box(kClass, arg);
|
arg = box(kClass, arg);
|
||||||
}
|
}
|
||||||
argMap.put(parameter, arg);
|
argMap.put(parameter, arg);
|
||||||
|
@ -376,9 +376,9 @@ public class InvocableHandlerMethod extends HandlerMethod {
|
||||||
private static Object box(KClass<?> kClass, @Nullable Object arg) {
|
private static Object box(KClass<?> kClass, @Nullable Object arg) {
|
||||||
KFunction<?> constructor = Objects.requireNonNull(KClasses.getPrimaryConstructor(kClass));
|
KFunction<?> constructor = Objects.requireNonNull(KClasses.getPrimaryConstructor(kClass));
|
||||||
KType type = constructor.getParameters().get(0).getType();
|
KType type = constructor.getParameters().get(0).getType();
|
||||||
if (!(type.isMarkedNullable() && arg == null)
|
if (!(type.isMarkedNullable() && arg == null) &&
|
||||||
&& type.getClassifier() instanceof KClass<?> parameterClass
|
type.getClassifier() instanceof KClass<?> parameterClass &&
|
||||||
&& KotlinDetector.isInlineClass(JvmClassMappingKt.getJavaClass(parameterClass))) {
|
KotlinDetector.isInlineClass(JvmClassMappingKt.getJavaClass(parameterClass))) {
|
||||||
arg = box(parameterClass, arg);
|
arg = box(parameterClass, arg);
|
||||||
}
|
}
|
||||||
if (!KCallablesJvm.isAccessible(constructor)) {
|
if (!KCallablesJvm.isAccessible(constructor)) {
|
||||||
|
|
|
@ -362,8 +362,8 @@ public class RequestMappingHandlerAdapter
|
||||||
@Override
|
@Override
|
||||||
public boolean test(HandlerMethod handlerMethod) {
|
public boolean test(HandlerMethod handlerMethod) {
|
||||||
Class<?> returnType = handlerMethod.getReturnType().getParameterType();
|
Class<?> returnType = handlerMethod.getReturnType().getParameterType();
|
||||||
return (this.adapterRegistry.getAdapter(returnType) == null
|
return (this.adapterRegistry.getAdapter(returnType) == null &&
|
||||||
&& !KotlinDetector.isSuspendingFunction(handlerMethod.getMethod()));
|
!KotlinDetector.isSuspendingFunction(handlerMethod.getMethod()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -149,8 +149,8 @@ class NestedRouteIntegrationTests extends AbstractRouterFunctionIntegrationTests
|
||||||
Map<String, String> pathVariables = request.pathVariables();
|
Map<String, String> pathVariables = request.pathVariables();
|
||||||
Map<String, String> attributePathVariables =
|
Map<String, String> attributePathVariables =
|
||||||
(Map<String, String>) request.attributes().get(RouterFunctions.URI_TEMPLATE_VARIABLES_ATTRIBUTE);
|
(Map<String, String>) request.attributes().get(RouterFunctions.URI_TEMPLATE_VARIABLES_ATTRIBUTE);
|
||||||
assertThat((pathVariables.equals(attributePathVariables))
|
assertThat((pathVariables.equals(attributePathVariables)) ||
|
||||||
|| (pathVariables.isEmpty() && (attributePathVariables == null))).isTrue();
|
(pathVariables.isEmpty() && (attributePathVariables == null))).isTrue();
|
||||||
|
|
||||||
PathPattern pathPattern = matchingPattern(request);
|
PathPattern pathPattern = matchingPattern(request);
|
||||||
String pattern = pathPattern != null ? pathPattern.getPatternString() : "";
|
String pattern = pathPattern != null ? pathPattern.getPatternString() : "";
|
||||||
|
|
|
@ -243,8 +243,8 @@ public class HttpEntityMethodProcessor extends AbstractMessageConverterMethodPro
|
||||||
outputMessage.getServletResponse().setStatus(returnStatus.value());
|
outputMessage.getServletResponse().setStatus(returnStatus.value());
|
||||||
if (returnStatus.value() == HttpStatus.OK.value()) {
|
if (returnStatus.value() == HttpStatus.OK.value()) {
|
||||||
HttpMethod method = inputMessage.getMethod();
|
HttpMethod method = inputMessage.getMethod();
|
||||||
if ((HttpMethod.GET.equals(method) || HttpMethod.HEAD.equals(method))
|
if ((HttpMethod.GET.equals(method) || HttpMethod.HEAD.equals(method)) &&
|
||||||
&& isResourceNotModified(inputMessage, outputMessage)) {
|
isResourceNotModified(inputMessage, outputMessage)) {
|
||||||
outputMessage.flush();
|
outputMessage.flush();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -666,8 +666,8 @@ public class MvcUriComponentsBuilder {
|
||||||
private static String resolveEmbeddedValue(String value) {
|
private static String resolveEmbeddedValue(String value) {
|
||||||
if (value.contains(SystemPropertyUtils.PLACEHOLDER_PREFIX)) {
|
if (value.contains(SystemPropertyUtils.PLACEHOLDER_PREFIX)) {
|
||||||
WebApplicationContext webApplicationContext = getWebApplicationContext();
|
WebApplicationContext webApplicationContext = getWebApplicationContext();
|
||||||
if (webApplicationContext != null
|
if (webApplicationContext != null &&
|
||||||
&& webApplicationContext.getAutowireCapableBeanFactory() instanceof ConfigurableBeanFactory cbf) {
|
webApplicationContext.getAutowireCapableBeanFactory() instanceof ConfigurableBeanFactory cbf) {
|
||||||
String resolvedEmbeddedValue = cbf.resolveEmbeddedValue(value);
|
String resolvedEmbeddedValue = cbf.resolveEmbeddedValue(value);
|
||||||
if (resolvedEmbeddedValue != null) {
|
if (resolvedEmbeddedValue != null) {
|
||||||
return resolvedEmbeddedValue;
|
return resolvedEmbeddedValue;
|
||||||
|
|
|
@ -294,8 +294,8 @@ class ContextLoaderTests {
|
||||||
@Test
|
@Test
|
||||||
void frameworkServletWithCustomLocation() throws Exception {
|
void frameworkServletWithCustomLocation() throws Exception {
|
||||||
DispatcherServlet servlet = new DispatcherServlet();
|
DispatcherServlet servlet = new DispatcherServlet();
|
||||||
servlet.setContextConfigLocation("/org/springframework/web/context/WEB-INF/testNamespace.xml "
|
servlet.setContextConfigLocation("/org/springframework/web/context/WEB-INF/testNamespace.xml " +
|
||||||
+ "/org/springframework/web/context/WEB-INF/context-addition.xml");
|
"/org/springframework/web/context/WEB-INF/context-addition.xml");
|
||||||
servlet.init(new MockServletConfig(new MockServletContext(""), "test"));
|
servlet.init(new MockServletConfig(new MockServletContext(""), "test"));
|
||||||
assertThat(servlet.getWebApplicationContext().containsBean("kerry")).isTrue();
|
assertThat(servlet.getWebApplicationContext().containsBean("kerry")).isTrue();
|
||||||
assertThat(servlet.getWebApplicationContext().containsBean("kerryX")).isTrue();
|
assertThat(servlet.getWebApplicationContext().containsBean("kerryX")).isTrue();
|
||||||
|
|
|
@ -82,8 +82,8 @@ class InternalResourceViewTests {
|
||||||
view.render(model, request, response);
|
view.render(model, request, response);
|
||||||
assertThat(response.getForwardedUrl()).isEqualTo(url);
|
assertThat(response.getForwardedUrl()).isEqualTo(url);
|
||||||
|
|
||||||
model.forEach((key, value) -> assertThat(request.getAttribute(key)).as("Values for model key '" + key
|
model.forEach((key, value) -> assertThat(request.getAttribute(key))
|
||||||
+ "' must match").isEqualTo(value));
|
.as("Values for model key '%s' must match", key).isEqualTo(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -41,8 +41,8 @@ public class SockJsMessageDeliveryException extends SockJsException {
|
||||||
}
|
}
|
||||||
|
|
||||||
public SockJsMessageDeliveryException(String sessionId, List<String> undeliveredMessages, String message) {
|
public SockJsMessageDeliveryException(String sessionId, List<String> undeliveredMessages, String message) {
|
||||||
super("Failed to deliver message(s) " + undeliveredMessages + " for session "
|
super("Failed to deliver message(s) " + undeliveredMessages + " for session " + sessionId + ": " + message,
|
||||||
+ sessionId + ": " + message, sessionId, null);
|
sessionId, null);
|
||||||
this.undeliveredMessages = undeliveredMessages;
|
this.undeliveredMessages = undeliveredMessages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
<suppress files="ResolvableType" checks="FinalClass"/>
|
<suppress files="ResolvableType" checks="FinalClass"/>
|
||||||
<suppress files="[\\/]src[\\/]testFixtures[\\/]java[\\/].+" checks="IllegalImport" id="bannedJUnitJupiterImports"/>
|
<suppress files="[\\/]src[\\/]testFixtures[\\/]java[\\/].+" checks="IllegalImport" id="bannedJUnitJupiterImports"/>
|
||||||
<suppress files="Target_ClassFinder" checks="HideUtilityClassConstructor"/>
|
<suppress files="Target_ClassFinder" checks="HideUtilityClassConstructor"/>
|
||||||
|
<suppress files="StringDecoderBenchmark" checks="RegexpSinglelineJava" id="separatorSymbolLocation"/>
|
||||||
|
|
||||||
<!-- spring-core-test -->
|
<!-- spring-core-test -->
|
||||||
<suppress files="CompileWithForkedClassLoader" checks="IllegalImport" id="bannedJUnitJupiterImports" />
|
<suppress files="CompileWithForkedClassLoader" checks="IllegalImport" id="bannedJUnitJupiterImports" />
|
||||||
|
@ -128,6 +129,7 @@
|
||||||
<suppress files="ServletAnnotationControllerHandlerMethodTests" checks="InterfaceIsType"/>
|
<suppress files="ServletAnnotationControllerHandlerMethodTests" checks="InterfaceIsType"/>
|
||||||
<suppress files="src[\\/]test[\\/]java[\\/]org[\\/]springframework[\\/]web[\\/]servlet[\\/]resource[\\/]GzipSupport" checks="IllegalImport" id="bannedJUnitJupiterImports"/>
|
<suppress files="src[\\/]test[\\/]java[\\/]org[\\/]springframework[\\/]web[\\/]servlet[\\/]resource[\\/]GzipSupport" checks="IllegalImport" id="bannedJUnitJupiterImports"/>
|
||||||
<suppress files="src[\\/]test[\\/]java[\\/]org[\\/]springframework[\\/]web[\\/]servlet[\\/]handler[\\/]PathPatterns.+" checks="IllegalImport" id="bannedJUnitJupiterImports"/>
|
<suppress files="src[\\/]test[\\/]java[\\/]org[\\/]springframework[\\/]web[\\/]servlet[\\/]handler[\\/]PathPatterns.+" checks="IllegalImport" id="bannedJUnitJupiterImports"/>
|
||||||
|
<suppress files="(ResponseBodyEmitterReturnValueHandlerTests|SseServerResponseTests)" checks="RegexpSinglelineJava" id="separatorSymbolLocation"/>
|
||||||
|
|
||||||
<!-- spring-websocket -->
|
<!-- spring-websocket -->
|
||||||
<suppress files="web[\\/]socket[\\/]CloseStatus" checks="JavadocStyle"/>
|
<suppress files="web[\\/]socket[\\/]CloseStatus" checks="JavadocStyle"/>
|
||||||
|
|
|
@ -188,6 +188,14 @@
|
||||||
<property name="illegalPattern" value="true"/>
|
<property name="illegalPattern" value="true"/>
|
||||||
<property name="message" value="Trailing whitespace"/>
|
<property name="message" value="Trailing whitespace"/>
|
||||||
</module>
|
</module>
|
||||||
|
<module name="com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineJavaCheck">
|
||||||
|
<!-- https://github.com/spring-projects/spring-framework/wiki/Code-Style#line-wrapping-->
|
||||||
|
<property name="id" value="separatorSymbolLocation"/>
|
||||||
|
<property name="format" value="^\s+?([,?:]|(\+(?!\+))|&&|\|\|)"/>
|
||||||
|
<property name="message"
|
||||||
|
value="Separator symbols ('','', ''+'', ''?'', '':'', ''&&'', ''||'') must be declared at the end of the previous line."/>
|
||||||
|
<property name="ignoreComments" value="true"/>
|
||||||
|
</module>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineJavaCheck">
|
<module name="com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineJavaCheck">
|
||||||
<property name="id" value="atSinceVersionConvention"/>
|
<property name="id" value="atSinceVersionConvention"/>
|
||||||
<property name="format" value="\@since \d+\.\d+\.0"/>
|
<property name="format" value="\@since \d+\.\d+\.0"/>
|
||||||
|
|
Loading…
Reference in New Issue