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